For anyone else that it's interested in capturing Fansly livestreams, I've written a Bash script that automates the process. I simply run this script as a cronjob (scheduled task) for the creators I want to capture.
Note that the script has only been run & tested on Linux (Debian/Ubuntu). It might work using Git Bash (or similar) on Windows, but I honestly don't know as I don't rely on Windows for these things.
It should work fine using Windows Subsystem for Linux (WSL) though, as that's practically a Linux virtual machine.
Mac? No idea. If you can somehow install the software listed in the software requirements, I don't see why not.
Script itself can be found on GitHub:
Here's also a copy of the script as of August 30th, 2023:
The GitHub link is your best bet for the most up-to-date script though, as I might forget to update this post with any changes.
For your user agent and Fansly token, you can do the following:
If the base path is not set, it will default to the current working directory where you are running the script.
All livestreams will be saved in a similar format of
For example if
If you're planning on running the script as a cronjob, I recommend setting the base path. Either in the file or as an environment variable.
Open your terminal, and run the script while passing the username as a parameter:
Note that the script has only been run & tested on Linux (Debian/Ubuntu). It might work using Git Bash (or similar) on Windows, but I honestly don't know as I don't rely on Windows for these things.
It should work fine using Windows Subsystem for Linux (WSL) though, as that's practically a Linux virtual machine.
Mac? No idea. If you can somehow install the software listed in the software requirements, I don't see why not.
Script itself can be found on GitHub:
Here's also a copy of the script as of August 30th, 2023:
The GitHub link is your best bet for the most up-to-date script though, as I might forget to update this post with any changes.
Software requirements
What you need to have installed where you run the script:curl
- Used for requesting info from Fansly's APIffmpeg
- Used for the actual video capturejq
- Used for parsing the info from Fansly's API
apt install curl ffmpeg jq
Getting your Fansly token & user agent
You need to have a Fansly account for this. Depending on the Fansly creator you're capturing, you may also need to be following and subscribed to them. Most of the ones I've seen simply need you to follow them though, which is free.For your user agent and Fansly token, you can do the following:
- Open Fansly.com in your browser, make sure you're logged in.
- Open the browser console in developer tools (
F12
/CTRL+Shift+I
) - Paste the following into the browser console input, it will copy your Fansly tokento the clipboard
copy(JSON.parse(localStorage.session_active_session).token);
- Open the
fansly-stream-capture.sh
file in your favorite text editor. - Set the
FANSLY_TOKEN
value in the beginning of the script, or as an environment variable. If setting it in the script, it is on line 14, at the time of writing this post.- If you paste it into the script, make sure to remove the hash symbol (
#
) at the beginning of the line. - Wrong:
# FANSLY_TOKEN="your-token-here"
- Correct:
FANSLY_TOKEN="your-token-here"
- If you paste it into the script, make sure to remove the hash symbol (
- For the user agent, paste the following into your browser console input and it will also be copied into the clipboard
copy(navigator.userAgent);
- Set the
USER_AGENT
value in the beginning of the script, or as an environment variable. If setting it in the script, it is on line 17, at the time of writing this post.- If you paste it into the script, make sure to remove the hash symbol (
#
) at the beginning of the line. - Wrong:
# USER_AGENT="your-user-agent-here"
- Correct:
USER_AGENT="your-user-agent-here"
- If you paste it into the script, make sure to remove the hash symbol (
[Optional] Setting the base path
Setting the base path will allow you to save all the streams in one main directory.If the base path is not set, it will default to the current working directory where you are running the script.
All livestreams will be saved in a similar format of
${BASE_PATH}/${FANSLY_USERNAME}/${YYYY-MM-DD}_${FANSLY_NUMERIC_CREATOR_ID]_${STREAM_ID}_${EPOCH_TIMESTAMP}.ts
For example if
BASE_PATH=/home/marcus/livestreams
, any livestreams I capture of Kati3kat would be saved under /home/marcus/livestreams/Kati3kat/2023-08-04_123456789_696969420_1691183787.ts
If you're planning on running the script as a cronjob, I recommend setting the base path. Either in the file or as an environment variable.
Using the script
Once you've set your values correctly, you can test it by finding someone that's live on Fansly (or waiting for someone to go live).Open your terminal, and run the script while passing the username as a parameter:
bash fansly-stream-capture.sh FanslyUsername
Last edited: