From 5f4884dce8e3eb3215ee8b97469a741310669083 Mon Sep 17 00:00:00 2001 From: James Taylor Date: Thu, 22 Oct 2020 14:30:33 -0700 Subject: Put vid title at end of download urls so downloads w/ that filename --- youtube/watch.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'youtube/watch.py') diff --git a/youtube/watch.py b/youtube/watch.py index 11ef9f2..bc2008c 100644 --- a/youtube/watch.py +++ b/youtube/watch.py @@ -398,6 +398,17 @@ def get_watch_page(video_id=None): for fmt in info['formats']: fmt['url'] = util.prefix_url(fmt['url']) + # Add video title to end of url path so it has a filename other than just + # "videoplayback" when downloaded + title = urllib.parse.quote(util.to_valid_filename(info['title'])) + for fmt in info['formats']: + filename = title + ext = fmt.get('ext') + if ext: + filename += '.' + ext + fmt['url'] = fmt['url'].replace( + '/videoplayback', + '/videoplayback/name/' + filename) if settings.gather_googlevideo_domains: with open(os.path.join(settings.data_dir, 'googlevideo-domains.txt'), 'a+', encoding='utf-8') as f: -- cgit v1.2.3