Merge branch 'extract_info_rewrite'
authorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Fri, 19 Apr 2013 19:57:08 +0000 (21:57 +0200)
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Fri, 19 Apr 2013 19:57:08 +0000 (21:57 +0200)
1  2 
README.md
youtube_dl/FileDownloader.py
youtube_dl/InfoExtractors.py

diff --cc README.md
Simple merge
index 96da754fb11ea083e4c2b04d4da53aa54869b3ed,4dabbb440837e0a3bbbf41032ef9d6001609f041..03346ab04263a9e7c11f829053f8e6d96101781e
@@@ -388,11 -388,9 +388,13 @@@ class FileDownloader(object)
              template_dict = dict(info_dict)
  
              template_dict['epoch'] = int(time.time())
 -            template_dict['autonumber'] = u'%05d' % self._num_downloads
 +            autonumber_size = self.params.get('autonumber_size')
 +            if autonumber_size is None:
 +                autonumber_size = 5
 +            autonumber_templ = u'%0' + str(autonumber_size) + u'd'
 +            template_dict['autonumber'] = autonumber_templ % self._num_downloads
+             if template_dict['playlist_index'] is not None:
+                 template_dict['playlist_index'] = u'%05d' % template_dict['playlist_index']
  
              sanitize = lambda k,v: sanitize_filename(
                  u'NA' if v is None else compat_str(v),
      def process_info(self, info_dict):
          """Process a single dictionary returned by an InfoExtractor."""
  
+         #We increment the download the download count here to match the previous behaviour.
+         self.increment_downloads()
+         
 +        info_dict['fulltitle'] = info_dict['title']
 +        if len(info_dict['title']) > 200:
 +            info_dict['title'] = info_dict['title'][:197] + u'...'
 +
          # Keep for backwards compatibility
          info_dict['stitle'] = info_dict['title']
  
index bac3a747d6ffcecc36af4e4518f8f97c118568c0,a7fdf1607c4c73e4caef623a1598065e84b3a834..ae36558d75839f68facb72300efb5b4c22bcd809
@@@ -134,15 -133,29 +134,37 @@@ class InfoExtractor(object)
          else:
              encoding = 'utf-8'
          webpage_bytes = urlh.read()
 +        if self._downloader.params.get('dump_intermediate_pages', False):
 +            try:
 +                url = url_or_request.get_full_url()
 +            except AttributeError:
 +                url = url_or_request
 +            self._downloader.to_screen(u'Dumping request to ' + url)
 +            dump = base64.b64encode(webpage_bytes).decode('ascii')
 +            self._downloader.to_screen(dump)
          return webpage_bytes.decode(encoding, 'replace')
+         
+     #Methods for following #608
+     #They set the correct value of the '_type' key
+     def video_result(self, video_info):
+         """Returns a video"""
+         video_info['_type'] = 'video'
+         return video_info
+     def url_result(self, url, ie=None):
+         """Returns a url that points to a page that should be processed"""
+         #TODO: ie should be the class used for getting the info
+         video_info = {'_type': 'url',
+                       'url': url}
+         return video_info
+     def playlist_result(self, entries, playlist_id=None, playlist_title=None):
+         """Returns a playlist"""
+         video_info = {'_type': 'playlist',
+                       'entries': entries}
+         if playlist_id:
+             video_info['id'] = playlist_id
+         if playlist_title:
+             video_info['title'] = playlist_title
+         return video_info
  
  
  class YoutubeIE(InfoExtractor):