From f4cb904a5e72169d84f286ecd06c770c1edb31ed Mon Sep 17 00:00:00 2001 From: Viktor Lindgren Date: Sat, 21 Sep 2013 20:56:03 +0200 Subject: [PATCH] Option --lastrun is now more tolerant for errors. Uses now .readline() and .strip() on date file. --- youtube_dl/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py index 983c70c8d..6e36b22a5 100644 --- a/youtube_dl/__init__.py +++ b/youtube_dl/__init__.py @@ -56,6 +56,7 @@ from .FileDownloader import * from .extractor import gen_extractors from .YoutubeDL import YoutubeDL from .PostProcessor import * +from datetime import date as dateh def parseOpts(overrideArguments=None): def _readOptions(filename_bytes): @@ -536,10 +537,10 @@ def _real_main(argv=None): if opts.lastrun: if not os.path.exists(opts.lastrun): with open(opts.lastrun, "w") as conf: - conf.write(date_from_str("now")) + conf.write(dateh.today().strftime("%Y%m%d")) with open(opts.lastrun, "r") as conf: - date = DateRange(conf.read(), opts.datebefore) + date = DateRange(conf.readline().strip(), opts.datebefore) else: date = DateRange(opts.dateafter, opts.datebefore) @@ -680,7 +681,7 @@ def _real_main(argv=None): if opts.lastrun and retcode is 0: with open(opts.lastrun, "w") as conf: - conf.write(date_from_str("now")) + conf.write(dateh.today().strftime("%Y%m%d")) sys.exit(retcode)