Source code
You can get the source code here.
If you encounter an issue/bug, feel free to open an issue here.
Setup
To install all necessary libraries run pip install -r requirements.txt
Downloading
To download a stream you need an URL template. You can get it by following those steps:
- open the stream
- open developer tools
- click on the “Network” tab
- wait until an entry with a
.tsfile extension appears - replace the number (counter) before the
.tswith%s
You have successfully generated your URL template.
Example
Example screenshot of developer tools network log:
In this case, the URL is https://rtvslolive.akamaized.net/hls/live/584144/tv_slo1/slo1_360p/6p4b4hy7/00000003/media_6618.ts.
After you replace the counter with %s, you get https://rtvslolive.akamaized.net/hls/live/584144/tv_slo1/slo1_360p/6p4b4hy7/00000003/media_%s.ts, which is your URL template.
Multithreaded downloader
Multithreaded downloader supports the following options:
-s(required) - the live stream URL template-z(default: 4) - how many places does the URL file template counter have-d(default: 0) - the default counter setting. If the stream doesn’t start at the specify number, the system will increment the counter until it reaches the beginning of the stream-c(default:mt_chunks/) - output directory for thetschunks-l(defualt:mt_logs/) - output directory for the logs-m(default: 10) - number of threads used for downloading
Singlethreaded downloader
Singlethreaded downloader supports the following options:
-s(required) - the live stream URL template-z(default: 4) - how many places does the URL file template counter have-d(default: 0) - the default counter setting. If the stream doesn’t start at the specify number, the system will increment the counter until it reaches the beginning of the stream-c(default:chunks/) - output directory for thetschunks-l(defualt:logs/) - output directory for the logs
Merging downloaded chunks
To merge all downloaded chunks into a single mp4 file run:
- If you used multithreaded downloader:
./mt_merge_ts.sh - If you used singlethreaded downloader:
./merge_ts.sh
The output files will be located in output folder.
Please note: you must have ffmpeg installed in order to use the merging script.