Override local file names for downloaded vods

Sometimes the playlists contain more than just file names which can
break the ffmpeg join, so just name downloaded vods sequentially.

fixes #12
This commit is contained in:
Ivan Habunek 2020-04-11 13:20:59 +02:00
parent ebc754072d
commit 042d35ba1e
No known key found for this signature in database
GPG Key ID: CDBD63C43A30BB95
2 changed files with 5 additions and 5 deletions

View File

@ -49,11 +49,11 @@ def _select_quality(playlists):
return playlists[no - 1]
def _join_vods(directory, paths, target):
def _join_vods(directory, file_paths, target):
input_path = "{}/files.txt".format(directory)
with open(input_path, 'w') as f:
for path in paths:
for path in file_paths:
f.write('file {}\n'.format(os.path.basename(path)))
result = subprocess.run([
@ -157,11 +157,11 @@ def download(video_id, max_workers, format='mkv', start=None, end=None, keep=Fal
print_out("\nDownloading {} VODs using {} workers to {}".format(
len(filenames), max_workers, target_dir))
download_files(base_uri, target_dir, filenames, max_workers)
file_paths = download_files(base_uri, target_dir, filenames, max_workers)
print_out("\n\nJoining files...")
target = _video_target_filename(video, format)
_join_vods(target_dir, filenames, target)
_join_vods(target_dir, file_paths, target)
if keep:
print_out("\nTemporary files not deleted: {}".format(target_dir))

View File

@ -67,7 +67,7 @@ def _print_progress(futures):
def download_files(base_url, directory, filenames, max_workers):
urls = [base_url + f for f in filenames]
paths = ["/".join([directory, f]) for f in filenames]
paths = ["{}{:05d}.vod".format(directory, k) for k, _ in enumerate(filenames)]
partials = (partial(download_file, url, path) for url, path in zip(urls, paths))
with ThreadPoolExecutor(max_workers=max_workers) as executor: