Make the YouTube login mechanism work across countries
authorRicardo Garcia <sarbalap+freshmeat@gmail.com>
Thu, 16 Oct 2008 21:33:19 +0000 (23:33 +0200)
committerRicardo Garcia <sarbalap+freshmeat@gmail.com>
Sun, 31 Oct 2010 10:23:38 +0000 (11:23 +0100)
youtube-dl

index a19571c5ba0a6023e3861d99c598525b020ecd20..c58cb3cfd3cf1334f1f6ba49725954919981fc78 100755 (executable)
@@ -431,8 +431,8 @@ class YoutubeIE(InfoExtractor):
        """Information extractor for youtube.com."""
 
        _VALID_URL = r'^((?:http://)?(?:\w+\.)?youtube\.com/(?:(?:v/)|(?:(?:watch(?:\.php)?)?\?(?:.+&)?v=)))?([0-9A-Za-z_-]+)(?(1).+)?$'
-       _LOGIN_URL = 'http://www.youtube.com/login?next=/'
-       _AGE_URL = 'http://www.youtube.com/verify_age?next_url=/'
+       _LOGIN_URL = 'http://uk.youtube.com/login?next=/'
+       _AGE_URL = 'http://uk.youtube.com/verify_age?next_url=/'
        _NETRC_MACHINE = 'youtube'
 
        @staticmethod
@@ -537,7 +537,7 @@ class YoutubeIE(InfoExtractor):
                video_extension = {'18': 'mp4', '17': '3gp'}.get(format_param, 'flv')
 
                # Normalize URL, including format
-               normalized_url = 'http://www.youtube.com/watch?v=%s' % video_id
+               normalized_url = 'http://uk.youtube.com/watch?v=%s' % video_id
                if format_param is not None:
                        normalized_url = '%s&fmt=%s' % (normalized_url, format_param)
                request = urllib2.Request(normalized_url, None, std_headers)
@@ -554,7 +554,7 @@ class YoutubeIE(InfoExtractor):
                if mobj is None:
                        self.to_stderr(u'ERROR: unable to extract "t" parameter')
                        return [None]
-               video_real_url = 'http://www.youtube.com/get_video?video_id=%s&t=%s' % (video_id, mobj.group(1))
+               video_real_url = 'http://uk.youtube.com/get_video?video_id=%s&t=%s' % (video_id, mobj.group(1))
                if format_param is not None:
                        video_real_url = '%s&fmt=%s' % (video_real_url, format_param)
                self.report_video_url(video_id, video_real_url)
@@ -655,7 +655,7 @@ class MetacafeIE(InfoExtractor):
                # Check if video comes from YouTube
                mobj2 = re.match(r'^yt-(.*)$', video_id)
                if mobj2 is not None:
-                       return self._youtube_ie.extract('http://www.youtube.com/watch?v=%s' % mobj2.group(1))
+                       return self._youtube_ie.extract('http://uk.youtube.com/watch?v=%s' % mobj2.group(1))
 
                simple_title = mobj.group(2).decode('utf-8')
                video_extension = 'flv'
@@ -711,7 +711,7 @@ class YoutubePlaylistIE(InfoExtractor):
        """Information Extractor for YouTube playlists."""
 
        _VALID_URL = r'(?:http://)?(?:\w+\.)?youtube.com/view_play_list\?p=(.+)'
-       _TEMPLATE_URL = 'http://www.youtube.com/view_play_list?p=%s&page=%s'
+       _TEMPLATE_URL = 'http://uk.youtube.com/view_play_list?p=%s&page=%s'
        _VIDEO_INDICATOR = r'/watch\?v=(.+?)&'
        _MORE_PAGES_INDICATOR = r'/view_play_list?p=%s&amp;page=%s'
        _youtube_ie = None
@@ -764,7 +764,7 @@ class YoutubePlaylistIE(InfoExtractor):
 
                information = []
                for id in video_ids:
-                       information.extend(self._youtube_ie.extract('http://www.youtube.com/watch?v=%s' % id))
+                       information.extend(self._youtube_ie.extract('http://uk.youtube.com/watch?v=%s' % id))
                return information
 
 class PostProcessor(object):