Created
January 28, 2021 15:44
-
-
Save flavioribeiro/9b52c603c70cdb34c6910c1c5c4d240d to your computer and use it in GitHub Desktop.
Revisions
-
flavioribeiro created this gist
Jan 28, 2021 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ import datetime import os from concurrent.futures import ThreadPoolExecutor from requests import get import m3u8 from threefive import decode import time PLAYLIST = "" downloader = ThreadPoolExecutor(max_workers=10) def download(uri, output_dir): date = datetime.datetime.now().strftime("%Y_%m_%d_%H_%M_%S") file_path = os.path.join(output_dir, date + "_" + uri.split('/')[-1]) with open(file_path, "wb") as f: response = get(uri) f.write(response.content) print("decoding ", file_path) decode(file_path) if __name__ == "__main__": while True: master_manifest = m3u8.load(PLAYLIST) for manifest in master_manifest.playlists: rendition_manifest = m3u8.load(manifest.absolute_uri) for segment in rendition_manifest.segments: downloader.submit(download, segment.absolute_uri, "/tmp/") time.sleep(6)