Skip to content

Instantly share code, notes, and snippets.

@rickerp
Created March 1, 2021 02:27
Show Gist options
  • Save rickerp/8a3788284408065558acf201b0d92436 to your computer and use it in GitHub Desktop.
Save rickerp/8a3788284408065558acf201b0d92436 to your computer and use it in GitHub Desktop.
Python script that converts streaming links m3u8 to any types of video downloaded
#!/usr/bin/python
import subprocess
import argparse
import os
if os.system('which ffmpeg') != 0:
print('Please install ffmpeg before using this script')
print('sudo apt install ffmpeg')
exit(1)
ap = argparse.ArgumentParser()
ap.add_argument('source', help="Path to .txt with streaming .m3u8 links separated with \\n")
ap.add_argument('-o', '--output', help="Path to .txt file with output filename paths seperated with \\n")
args = vars(ap.parse_args())
with open(args['source'], 'r') as videos_file:
vurls = videos_file.readlines()
if args['output']:
with open(args['output'], 'r') as outputs_file:
vnames = outputs_file.readlines()
else:
vnames = [f'video{i}.mp4\n' for i in range(len(vurls))]
for vurl, vname in zip(vurls, vnames):
subprocess.call(f"ffmpeg -i '{vurl[:-1]}' '{vname[:-1]}' &", shell=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment