aboutsummaryrefslogtreecommitdiffstats
path: root/youtube/watch.py
diff options
context:
space:
mode:
Diffstat (limited to 'youtube/watch.py')
-rw-r--r--youtube/watch.py11
1 files changed, 11 insertions, 0 deletions
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: