From 3f67cef7971febf8b0db9a045b08ca7469593558 Mon Sep 17 00:00:00 2001 From: Thomas Perl Date: Sun, 23 Sep 2012 20:29:29 +0200 Subject: [PATCH] YouTube: Parse error messages, improve downloading --- src/gpodder/youtube.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gpodder/youtube.py b/src/gpodder/youtube.py index 2a90e2cb5..01113c4be 100644 --- a/src/gpodder/youtube.py +++ b/src/gpodder/youtube.py @@ -54,7 +54,7 @@ def get_real_download_url(url, preferred_fmt_id=18): vid = get_youtube_id(url) if vid is not None: page = None - url = 'http://www.youtube.com/get_video_info?&video_id=' + vid + url = 'http://www.youtube.com/get_video_info?&el=detailpage&video_id=' + vid while page is None: req = util.http_request(url, method='GET') @@ -72,6 +72,10 @@ def find_urls(page): for fmt_url_encoded in fmt_url_map.split(','): video_info = parse_qs(fmt_url_encoded) yield int(video_info['itag'][0]), video_info['url'][0] + else: + error_info = parse_qs(page) + error_message = util.remove_html_tags(error_info['reason'][0]) + raise YouTubeError('Cannot download video: %s' % error_message) fmt_id_url_map = sorted(find_urls(page), reverse=True) # Default to the highest fmt_id if we don't find a match below