Created
March 21, 2020 12:15
-
-
Save rejsmont/2c2696587bbecf1e4ef613df8a9045f6 to your computer and use it in GitHub Desktop.
Download stream from Chrome playlist cURL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
print("Enter output filename:") | |
name = input() | |
print("Paste cURL command string:") | |
cmd = input() | |
headers = [] | |
lines = cmd.split(' -') | |
for param in lines: | |
if param.startswith("curl "): | |
url = param.replace("curl ", "").strip("'") | |
if param.startswith("H "): | |
header = param.replace("H '","").strip("'") | |
if "user-agent" in header: | |
user_agent = header.replace("user-agent: ", "") | |
else: | |
headers.append(header) | |
ffmpeg = "ffmpeg -user_agent '" + user_agent + "' -headers $'" + "\\r\\n".join(headers) + "\\r\\n' -i '" + url + "' -c copy -bsf:a aac_adtstoasc '" + name + "'" | |
os.system(ffmpeg) | |
print("Output saved to", name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment