mirror of
https://gitlab.com/dstftw/youtube-dl.git
synced 2020-11-16 09:42:26 +00:00
Add a playlist_index key to the info_dict, can be used in the output template
This commit is contained in:
parent
bce878a7c1
commit
d281274bf2
|
@ -145,6 +145,7 @@ The `-o` option allows users to indicate a template for the output file names. T
|
||||||
- `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.
|
- `playlist`: The name or the id of the playlist that contains the video.
|
||||||
|
- `playlist_index`: The index of the video in the playlist, a five-digit number.
|
||||||
|
|
||||||
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).
|
||||||
|
|
||||||
|
|
|
@ -389,6 +389,8 @@ class FileDownloader(object):
|
||||||
|
|
||||||
template_dict['epoch'] = int(time.time())
|
template_dict['epoch'] = int(time.time())
|
||||||
template_dict['autonumber'] = u'%05d' % self._num_downloads
|
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(
|
sanitize = lambda k,v: sanitize_filename(
|
||||||
u'NA' if v is None else compat_str(v),
|
u'NA' if v is None else compat_str(v),
|
||||||
|
@ -473,6 +475,7 @@ class FileDownloader(object):
|
||||||
if 'playlist' not in ie_result:
|
if 'playlist' not in ie_result:
|
||||||
#It isn't part of a playlist
|
#It isn't part of a playlist
|
||||||
ie_result['playlist'] = None
|
ie_result['playlist'] = None
|
||||||
|
ie_result['playlist_index'] = None
|
||||||
if download:
|
if download:
|
||||||
#Do the download:
|
#Do the download:
|
||||||
self.process_info(ie_result)
|
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))
|
self.to_screen(u'[download] Downloading video #%s of %s' %(i, n_entries))
|
||||||
entry_result = self.process_ie_result(entry, False)
|
entry_result = self.process_ie_result(entry, False)
|
||||||
entry_result['playlist'] = playlist
|
entry_result['playlist'] = playlist
|
||||||
|
entry_result['playlist_index'] = i + playliststart
|
||||||
#We must do the download here to correctly set the 'playlist' key
|
#We must do the download here to correctly set the 'playlist' key
|
||||||
if download:
|
if download:
|
||||||
self.process_info(entry_result)
|
self.process_info(entry_result)
|
||||||
|
|
Loading…
Reference in a new issue