aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/FileDownloader.py
diff options
context:
space:
mode:
authorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>2013-04-16 15:13:29 +0200
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>2013-04-16 15:13:29 +0200
commitd281274bf250065f876bb4f75fb6f711e1a26eba (patch)
tree57eb7a54818883d395becbf6922b012220eda970 /youtube_dl/FileDownloader.py
parentbce878a7c1678ac698ecd556b2c77a1e2f2306df (diff)
downloadyoutube-dl-d281274bf250065f876bb4f75fb6f711e1a26eba.tar.xz
Add a playlist_index key to the info_dict, can be used in the output template
Diffstat (limited to 'youtube_dl/FileDownloader.py')
-rw-r--r--youtube_dl/FileDownloader.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/youtube_dl/FileDownloader.py b/youtube_dl/FileDownloader.py
index 5a5141ba5..4dabbb440 100644
--- a/youtube_dl/FileDownloader.py
+++ b/youtube_dl/FileDownloader.py
@@ -389,6 +389,8 @@ class FileDownloader(object):
template_dict['epoch'] = int(time.time())
template_dict['autonumber'] = u'%05d' % 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),
@@ -473,6 +475,7 @@ class FileDownloader(object):
if 'playlist' not in ie_result:
#It isn't part of a playlist
ie_result['playlist'] = None
+ ie_result['playlist_index'] = None
if download:
#Do the download:
self.process_info(ie_result)
@@ -506,6 +509,7 @@ class FileDownloader(object):
self.to_screen(u'[download] Downloading video #%s of %s' %(i, n_entries))
entry_result = self.process_ie_result(entry, False)
entry_result['playlist'] = playlist
+ entry_result['playlist_index'] = i + playliststart
#We must do the download here to correctly set the 'playlist' key
if download:
self.process_info(entry_result)