Pass the playlist info_dict to process_info

the playlist value can be used in the output template
This commit is contained in:
Jaime Marquínez Ferrándiz 2013-03-29 12:32:42 +01:00
parent d2c690828a
commit 7eab8dc750
2 changed files with 11 additions and 1 deletions

View File

@ -138,6 +138,7 @@ # OUTPUT TEMPLATE
- `ext`: The sequence will be replaced by the appropriate extension (like flv or mp4). - `ext`: The sequence will be replaced by the appropriate extension (like flv or mp4).
- `epoch`: The sequence will be replaced by the Unix epoch when creating the file. - `epoch`: The sequence will be replaced by the Unix epoch when creating the file.
- `autonumber`: The sequence will be replaced by a five-digit number that will be increased with each download, starting at zero. - `autonumber`: The sequence will be replaced by a five-digit number that will be increased with each download, starting at zero.
- `playlist`: The name or the id of the playlist that contains the video.
The current default template is `%(id)s.%(ext)s`, but that will be switchted to `%(title)s-%(id)s.%(ext)s` (which can be requested with `-t` at the moment). The current default template is `%(id)s.%(ext)s`, but that will be switchted to `%(title)s-%(id)s.%(ext)s` (which can be requested with `-t` at the moment).

View File

@ -460,12 +460,21 @@ def process_ie_results(self, ie_results, ie):
elif result_type == 'playlist': elif result_type == 'playlist':
#We process each entry in the playlist #We process each entry in the playlist
entries_result = self.process_ie_results(result['entries'], ie) entries_result = self.process_ie_results(result['entries'], ie)
results.extend(entries_result) result['entries'] = entries_result
results.extend([result])
return results return results
def process_info(self, info_dict): def process_info(self, info_dict):
"""Process a single dictionary returned by an InfoExtractor.""" """Process a single dictionary returned by an InfoExtractor."""
if info_dict.get('_type','video') == 'playlist':
playlist = info_dict.get('title', None) or info_dict.get('id', None)
self.to_screen(u'[download] Downloading playlist: %s' % playlist)
for video in info_dict['entries']:
video['playlist'] = playlist
self.process_info(video)
return
# Keep for backwards compatibility # Keep for backwards compatibility
info_dict['stitle'] = info_dict['title'] info_dict['stitle'] = info_dict['title']