Save playlists to temp dir for debugging

This commit is contained in:
Ivan Habunek 2019-08-23 13:08:35 +02:00
parent 000754af8c
commit e384f26444
No known key found for this signature in database
GPG Key ID: CDBD63C43A30BB95

View File

@ -229,12 +229,10 @@ def download(video_id, max_workers, format='mkv', start=None, end=None, keep=Fal
print_out("Fetching access token...")
access_token = twitch.get_access_token(video_id)
# TODO: save playlists for debugging purposes
print_out("Fetching playlists...")
playlists = twitch.get_playlists(video_id, access_token)
playlists = m3u8.loads(playlists)
selected = _select_quality(playlists.playlists)
parsed = m3u8.loads(playlists)
selected = _select_quality(parsed.playlists)
print_out("\nFetching playlist...")
response = requests.get(selected.uri)
@ -245,6 +243,12 @@ def download(video_id, max_workers, format='mkv', start=None, end=None, keep=Fal
target_dir = _crete_temp_dir(base_uri)
filenames = list(_get_files(playlist, start, end))
# Save playlists for debugging purposes
with open(target_dir + "playlists.m3u8", "w") as f:
f.write(playlists)
with open(target_dir + "playlist.m3u8", "w") as f:
f.write(response.text)
print_out("\nDownloading {} VODs using {} workers to {}".format(
len(filenames), max_workers, target_dir))
_download_files(base_uri, target_dir, filenames, max_workers)