mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2025-01-28 21:59:47 +00:00
add autonumber_reset (closes #29158)
This commit is contained in:
parent
1980ff4550
commit
f2e30afecc
@ -192,6 +192,7 @@ class YoutubeDL(object):
|
|||||||
keepvideo: Keep the video file after post-processing
|
keepvideo: Keep the video file after post-processing
|
||||||
daterange: A DateRange object, download only if the upload_date is in the range.
|
daterange: A DateRange object, download only if the upload_date is in the range.
|
||||||
skip_download: Skip the actual download of the video file
|
skip_download: Skip the actual download of the video file
|
||||||
|
autonumber_reset: Reset autonumber counter to autonumber-start before each playlist
|
||||||
cachedir: Location of the cache files in the filesystem.
|
cachedir: Location of the cache files in the filesystem.
|
||||||
False to disable filesystem cache.
|
False to disable filesystem cache.
|
||||||
noplaylist: Download single video instead of a playlist if in doubt.
|
noplaylist: Download single video instead of a playlist if in doubt.
|
||||||
@ -339,6 +340,7 @@ class YoutubeDL(object):
|
|||||||
_pps = []
|
_pps = []
|
||||||
_download_retcode = None
|
_download_retcode = None
|
||||||
_num_downloads = None
|
_num_downloads = None
|
||||||
|
_autonumber_index = None
|
||||||
_playlist_level = 0
|
_playlist_level = 0
|
||||||
_playlist_urls = set()
|
_playlist_urls = set()
|
||||||
_screen_file = None
|
_screen_file = None
|
||||||
@ -353,6 +355,7 @@ class YoutubeDL(object):
|
|||||||
self._progress_hooks = []
|
self._progress_hooks = []
|
||||||
self._download_retcode = 0
|
self._download_retcode = 0
|
||||||
self._num_downloads = 0
|
self._num_downloads = 0
|
||||||
|
self._autonumber_index = 0
|
||||||
self._screen_file = [sys.stdout, sys.stderr][params.get('logtostderr', False)]
|
self._screen_file = [sys.stdout, sys.stderr][params.get('logtostderr', False)]
|
||||||
self._err_file = sys.stderr
|
self._err_file = sys.stderr
|
||||||
self.params = {
|
self.params = {
|
||||||
@ -643,7 +646,7 @@ class YoutubeDL(object):
|
|||||||
autonumber_size = self.params.get('autonumber_size')
|
autonumber_size = self.params.get('autonumber_size')
|
||||||
if autonumber_size is None:
|
if autonumber_size is None:
|
||||||
autonumber_size = 5
|
autonumber_size = 5
|
||||||
template_dict['autonumber'] = self.params.get('autonumber_start', 1) - 1 + self._num_downloads
|
template_dict['autonumber'] = self.params.get('autonumber_start', 1) - 1 + self._autonumber_index
|
||||||
if template_dict.get('resolution') is None:
|
if template_dict.get('resolution') is None:
|
||||||
if template_dict.get('width') and template_dict.get('height'):
|
if template_dict.get('width') and template_dict.get('height'):
|
||||||
template_dict['resolution'] = '%dx%d' % (template_dict['width'], template_dict['height'])
|
template_dict['resolution'] = '%dx%d' % (template_dict['width'], template_dict['height'])
|
||||||
@ -965,6 +968,9 @@ class YoutubeDL(object):
|
|||||||
|
|
||||||
self.to_screen('[download] Downloading playlist: %s' % playlist)
|
self.to_screen('[download] Downloading playlist: %s' % playlist)
|
||||||
|
|
||||||
|
if self.params.get('autonumber_reset'):
|
||||||
|
self._autonumber_index = 0
|
||||||
|
|
||||||
playlist_results = []
|
playlist_results = []
|
||||||
|
|
||||||
playliststart = self.params.get('playliststart', 1) - 1
|
playliststart = self.params.get('playliststart', 1) - 1
|
||||||
@ -1795,6 +1801,7 @@ class YoutubeDL(object):
|
|||||||
return
|
return
|
||||||
|
|
||||||
self._num_downloads += 1
|
self._num_downloads += 1
|
||||||
|
self._autonumber_index += 1
|
||||||
|
|
||||||
info_dict['_filename'] = filename = self.prepare_filename(info_dict)
|
info_dict['_filename'] = filename = self.prepare_filename(info_dict)
|
||||||
|
|
||||||
|
@ -343,6 +343,7 @@ def _real_main(argv=None):
|
|||||||
'outtmpl_na_placeholder': opts.outtmpl_na_placeholder,
|
'outtmpl_na_placeholder': opts.outtmpl_na_placeholder,
|
||||||
'autonumber_size': opts.autonumber_size,
|
'autonumber_size': opts.autonumber_size,
|
||||||
'autonumber_start': opts.autonumber_start,
|
'autonumber_start': opts.autonumber_start,
|
||||||
|
'autonumber_reset': opts.autonumber_reset,
|
||||||
'restrictfilenames': opts.restrictfilenames,
|
'restrictfilenames': opts.restrictfilenames,
|
||||||
'ignoreerrors': opts.ignoreerrors,
|
'ignoreerrors': opts.ignoreerrors,
|
||||||
'force_generic_extractor': opts.force_generic_extractor,
|
'force_generic_extractor': opts.force_generic_extractor,
|
||||||
|
@ -709,6 +709,10 @@ def parseOpts(overrideArguments=None):
|
|||||||
'-A', '--auto-number',
|
'-A', '--auto-number',
|
||||||
action='store_true', dest='autonumber', default=False,
|
action='store_true', dest='autonumber', default=False,
|
||||||
help=optparse.SUPPRESS_HELP)
|
help=optparse.SUPPRESS_HELP)
|
||||||
|
filesystem.add_option(
|
||||||
|
'--autonumber-reset',
|
||||||
|
action='store_true', dest='autonumber_reset', default=False,
|
||||||
|
help='Reset %(autonumber)s counter to %(autonumber_start)s before each playlist')
|
||||||
filesystem.add_option(
|
filesystem.add_option(
|
||||||
'-t', '--title',
|
'-t', '--title',
|
||||||
action='store_true', dest='usetitle', default=False,
|
action='store_true', dest='usetitle', default=False,
|
||||||
|
Loading…
Reference in New Issue
Block a user