From 593a2c1349a0e45a67d1ad36a68fdfa2e4d1e808 Mon Sep 17 00:00:00 2001 From: Cebtenzzre Date: Wed, 21 Oct 2020 12:59:07 -0400 Subject: [PATCH] fixup! tumblr_backup: --json-dirs -> --prev-archives Correctly sort responses to avoid breaking most timestamp/id related options. Everything was in reverse order and the key was wrong for likes. --- tumblr_backup.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tumblr_backup.py b/tumblr_backup.py index 4fcf7ae..7e43041 100755 --- a/tumblr_backup.py +++ b/tumblr_backup.py @@ -295,10 +295,18 @@ def mktime(tml): def initial_apiparse(base, prev_archive): prev_resps = None if prev_archive: + def read_resp(path): + with io.open(path, encoding=FILE_ENCODING) as jf: + return json.load(jf) + + if options.likes: + log('Reading liked timestamps from saved responses (may take a while)\n', account=True) + prev_resps = tuple( e.path for e in sorted( (e for e in scandir(join(prev_archive, 'json')) if (e.name.endswith('.json') and e.is_file())), - key=lambda e: e.name, + key=lambda e: read_resp(e)['liked_timestamp'] if options.likes else long(e.name[:-5]), + reverse=True, ) )