Pass the playlist info_dict to process_info
authorJaime Marquínez Ferrándiz <jaimemf93@gmail.com>
Fri, 29 Mar 2013 11:32:42 +0000 (12:32 +0100)
committerJaime Marquínez Ferrándiz <jaimemf93@gmail.com>
Fri, 29 Mar 2013 11:32:42 +0000 (12:32 +0100)
the playlist value can be used in the output template

README.md
youtube_dl/FileDownloader.py

index 7c09d0c0d426221c7b6768219dae21bba3238e34..1f3422ef89e559cf573d2cd6b0ccbf0b434b82b3 100644 (file)
--- a/README.md
+++ b/README.md
@@ -138,6 +138,7 @@ The `-o` option allows users to indicate a template for the output file names. T
  - `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.
  - `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).
 
index 6af2acbeee73b1258c32134100eb3a6e4abac38a..d2b9be9ef88cb93e3e54fb0d3650880e35c36b43 100644 (file)
@@ -460,12 +460,21 @@ class FileDownloader(object):
             elif result_type == 'playlist':
                 #We process each entry in the playlist
                 entries_result = self.process_ie_results(result['entries'], ie)
-                results.extend(entries_result)
+                result['entries'] = entries_result
+                results.extend([result])
         return results
 
     def process_info(self, info_dict):
         """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
         info_dict['stitle'] = info_dict['title']