Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- import os
- import requests
- import re
- import time
- from datetime import datetime
- def get_playlist_url(url):
- response = requests.get(url)
- playlist_url = re.search(r"(/Transcoding.*m3u8)", response.text).group(1)
- playlist_url = re.search(r"(.*)/Transcoding", url).group(1) + playlist_url
- return playlist_url
- def get_m3u8(url, master_url):
- pre = master_url.replace("master_playlist.m3u8", "")
- with open("playlist.m3u8", "w") as file:
- response = requests.get(url)
- content = response.text.replace("chunk", f"{pre}chunk")
- file.write(content)
- if __name__ == '__main__':
- url = input("Enter m3u8 playlist URL: ")
- master_url = re.sub(r"dynamic.*", "master_playlist.m3u8", url)
- playlist_url = get_playlist_url(master_url)
- get_m3u8(playlist_url, master_url)
- print("Downloading...")
- t = datetime.now().strftime('%Y%m%d%H%M%S')
- os.system(f"ffmpeg -loglevel quiet -protocol_whitelist https,file,tls,tcp -i playlist.m3u8 -c copy {t}.m4a")
- os.remove("playlist.m3u8")
- print(f"Done, file: {t}.m4a")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement