From: Jaime Marquínez Ferrándiz Date: Fri, 19 Apr 2013 19:57:08 +0000 (+0200) Subject: Merge branch 'extract_info_rewrite' X-Git-Url: http://git.oshgnacknak.de/?a=commitdiff_plain;h=dce9027045f061649bc20f6ef48cbbce8cec87df;p=youtube-dl Merge branch 'extract_info_rewrite' --- dce9027045f061649bc20f6ef48cbbce8cec87df diff --cc youtube_dl/FileDownloader.py index 96da754fb,4dabbb440..03346ab04 --- a/youtube_dl/FileDownloader.py +++ b/youtube_dl/FileDownloader.py @@@ -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), @@@ -426,10 -521,9 +525,13 @@@ 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'] diff --cc youtube_dl/InfoExtractors.py index bac3a747d,a7fdf1607..ae36558d7 --- a/youtube_dl/InfoExtractors.py +++ b/youtube_dl/InfoExtractors.py @@@ -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):