From a02a3ecd5b23b5380cf41e161f02a044d1db00af Mon Sep 17 00:00:00 2001 From: mkaay Date: Mon, 8 Feb 2010 15:58:48 +0100 Subject: fixed youtube hd --- module/plugins/hoster/YoutubeCom.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'module') diff --git a/module/plugins/hoster/YoutubeCom.py b/module/plugins/hoster/YoutubeCom.py index 19fc1099d..a7c5a645d 100644 --- a/module/plugins/hoster/YoutubeCom.py +++ b/module/plugins/hoster/YoutubeCom.py @@ -20,6 +20,7 @@ class YoutubeCom(Plugin): self.parent = parent self.html = None self.read_config() + self.hd_available = False def download_html(self): url = self.parent.url @@ -36,10 +37,10 @@ class YoutubeCom(Plugin): quality = "" if self.config['quality'] == "sd": quality = "&fmt=6" - elif self.config['quality'] == "hq": - quality = "&fmt=18" - elif self.config['quality'] == "hd": + elif self.config['quality'] == "hd" and self.hd_available: quality = "&fmt=22" + else: + quality = "&fmt=18" file_url = 'http://youtube.com/get_video?video_id=' + videoId + '&t=' + videoHash + quality return file_url @@ -57,7 +58,10 @@ class YoutubeCom(Plugin): self.download_html() file_name_pattern = r"'VIDEO_TITLE': '(.*)'," + is_hd_pattern = r"'IS_HD_AVAILABLE': (false|true)" file_suffix = ".flv" + is_hd = re.search(is_hd_pattern, self.html).group(1) + self.hd_available = (is_hd == "true") if self.config['quality'] == "hd" or self.config['quality'] == "hq": file_suffix = ".mp4" name = re.search(file_name_pattern, self.html).group(1).replace("/", "") + file_suffix -- cgit v1.2.3