Skip to content

Commit

Permalink
fixup! tumblr_backup: --json-dirs -> --prev-archives
Browse files Browse the repository at this point in the history
Correctly sort responses to avoid breaking most timestamp/id related
options. Everything was in reverse order and the key was wrong for
likes.
  • Loading branch information
cebtenzzre committed Oct 21, 2020
1 parent 28531df commit 593a2c1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tumblr_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
)

Expand Down

0 comments on commit 593a2c1

Please sign in to comment.