mirror of
https://github.com/ytdl-org/youtube-dl
synced 2025-07-14 15:34:15 +09:00
Added --lastrun option.
This feature is useful for subscription as it remember when it last time ran in order to not try to download earlier videos that may have been seen and deleted already.
This commit is contained in:
parent
b00ca882a4
commit
c93277812e
@ -46,6 +46,8 @@ which means you can modify it, redistribute it or use it however you like.
|
||||
--date DATE download only videos uploaded in this date
|
||||
--datebefore DATE download only videos uploaded before this date
|
||||
--dateafter DATE download only videos uploaded after this date
|
||||
--lastrun FILE reads and update the FILE with last completed run.
|
||||
It sets --dateafter to the DATE from the FILE.
|
||||
|
||||
## Download Options:
|
||||
-r, --rate-limit LIMIT maximum download rate (e.g. 50k or 44.6m)
|
||||
|
@ -181,6 +181,7 @@ def parseOpts(overrideArguments=None):
|
||||
selection.add_option('--date', metavar='DATE', dest='date', help='download only videos uploaded in this date', default=None)
|
||||
selection.add_option('--datebefore', metavar='DATE', dest='datebefore', help='download only videos uploaded before this date', default=None)
|
||||
selection.add_option('--dateafter', metavar='DATE', dest='dateafter', help='download only videos uploaded after this date', default=None)
|
||||
selection.add_option('--lastrun', metavar='FILE', dest='lastrun', help='reads and update the file with last completed run. It sets --dateafter to this value.', default=None)
|
||||
|
||||
|
||||
authentication.add_option('-u', '--username',
|
||||
@ -532,7 +533,12 @@ def _real_main(argv=None):
|
||||
if opts.date is not None:
|
||||
date = DateRange.day(opts.date)
|
||||
else:
|
||||
date = DateRange(opts.dateafter, opts.datebefore)
|
||||
if opts.lastrun:
|
||||
with open(opts.lastrun, "r") as conf:
|
||||
date = DateRange(conf.read(), opts.datebefore)
|
||||
else:
|
||||
date = DateRange(opts.dateafter, opts.datebefore)
|
||||
|
||||
|
||||
# --all-sub automatically sets --write-sub if --write-auto-sub is not given
|
||||
# this was the old behaviour if only --all-sub was given.
|
||||
@ -668,6 +674,10 @@ def _real_main(argv=None):
|
||||
except (IOError, OSError) as err:
|
||||
sys.exit(u'ERROR: unable to save cookie jar')
|
||||
|
||||
if opts.lastrun and retcode is 0:
|
||||
with open(opts.lastrun, "w") as conf:
|
||||
conf.write(date_from_str("now"))
|
||||
|
||||
sys.exit(retcode)
|
||||
|
||||
def main(argv=None):
|
||||
|
Loading…
x
Reference in New Issue
Block a user