]> gitweb @ CieloNegro.org - youtube-dl.git/blobdiff - youtube_dl/InfoExtractors.py
Simplified preferredencoding()
[youtube-dl.git] / youtube_dl / InfoExtractors.py
index ee8783ffd6bd3ad5ce72f4c93216e25f415ea07b..baf859ea8beac248c7cc9caf0a525a71ae4368fb 100644 (file)
@@ -181,8 +181,8 @@ class YoutubeIE(InfoExtractor):
                        start = "%02i:%02i:%02i,%03i" %(start/(60*60), start/60%60, start%60, start%1*1000)
                        end = "%02i:%02i:%02i,%03i" %(end/(60*60), end/60%60, end%60, end%1*1000)
                        caption = unescapeHTML(caption)
-                       caption = unescapeHTML(caption) # double cycle, inentional
-                       srt += str(n) + '\n'
+                       caption = unescapeHTML(caption) # double cycle, intentional
+                       srt += str(n+1) + '\n'
                        srt += start + ' --> ' + end + '\n'
                        srt += caption + '\n\n'
                return srt
@@ -311,6 +311,11 @@ class YoutubeIE(InfoExtractor):
                                self._downloader.trouble(u'ERROR: "token" parameter not in video info for unknown reason')
                        return
 
+               # Check for "rental" videos
+               if 'ypc_video_rental_bar_text' in video_info and 'author' not in video_info:
+                       self._downloader.trouble(u'ERROR: "rental" videos not supported')
+                       return
+
                # Start extracting information
                self.report_information_extraction(video_id)
 
@@ -1227,7 +1232,7 @@ class YoutubeSearchIE(InfoExtractor):
                InfoExtractor.__init__(self, downloader)
 
        def report_download_page(self, query, pagenum):
-               """Report attempt to download playlist page with given number."""
+               """Report attempt to download search page with given number."""
                query = query.decode(preferredencoding())
                self._downloader.to_screen(u'[youtube] query "%s": Downloading page %s' % (query, pagenum))
 
@@ -1463,8 +1468,8 @@ class YoutubePlaylistIE(InfoExtractor):
 
        _VALID_URL = r'(?:https?://)?(?:\w+\.)?youtube\.com/(?:(?:course|view_play_list|my_playlists|artist|playlist)\?.*?(p|a|list)=|user/.*?/user/|p/|user/.*?#[pg]/c/)(?:PL)?([0-9A-Za-z-_]+)(?:/.*?/([0-9A-Za-z_-]+))?.*'
        _TEMPLATE_URL = 'http://www.youtube.com/%s?%s=%s&page=%s&gl=US&hl=en'
-       _VIDEO_INDICATOR_TEMPLATE = r'/watch\?v=(.+?)&list=PL%s&'
-       _MORE_PAGES_INDICATOR = r'(?m)>\s*Next\s*</a>'
+       _VIDEO_INDICATOR_TEMPLATE = r'/watch\?v=(.+?)&amp;list=(PL)?%s&'
+       _MORE_PAGES_INDICATOR = r'yt-uix-pager-next'
        IE_NAME = u'youtube:playlist'
 
        def __init__(self, downloader=None):
@@ -2188,11 +2193,12 @@ class EscapistIE(InfoExtractor):
 
                self.report_extraction(showName)
                try:
-                       webPage = urllib2.urlopen(url).read()
+                       webPageBytes = urllib2.urlopen(url).read()
                except (urllib2.URLError, httplib.HTTPException, socket.error), err:
                        self._downloader.trouble(u'ERROR: unable to download webpage: ' + unicode(err))
                        return
 
+               webPage = webPageBytes.decode('utf-8')
                descMatch = re.search('<meta name="description" content="([^"]*)"', webPage)
                description = unescapeHTML(descMatch.group(1))
                imgMatch = re.search('<meta property="og:image" content="([^"]*)"', webPage)
@@ -2449,7 +2455,7 @@ class SoundcloudIE(InfoExtractor):
                        try:
                                upload_date = datetime.datetime.strptime(mobj.group(1), '%B %d, %Y %H:%M').strftime('%Y%m%d')
                        except Exception, e:
-                               print str(e)
+                               self._downloader.to_stderr(str(e))
 
                # for soundcloud, a request to a cross domain is required for cookies
                request = urllib2.Request('http://media.soundcloud.com/crossdomain.xml', std_headers)