From 37dcb4da77f96ebf86061b5c88ea2d1b212b1372 Mon Sep 17 00:00:00 2001 From: garret Date: Wed, 12 Jul 2023 18:14:05 +0100 Subject: fix error if page is not scrambled --- walker.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/walker.py b/walker.py index 803885e..42b9793 100644 --- a/walker.py +++ b/walker.py @@ -47,7 +47,7 @@ def undrm(url, headers, cid_info): print(f'Saving chapter to {save_path}\n') - for page in range(1, len(meta['data']['result']) + 1): + for num, page in enumerate(meta['data']['result']): if args.nolog: if page == 1: @@ -55,12 +55,16 @@ def undrm(url, headers, cid_info): else: logging.info('Progress: page ' + str(page)) - key = unhexlify(meta['data']['result'][page-1]['meta']['drm_hash'][:16]) - enc = requests.get(meta['data']['result'][page-1]['meta']['source_url'], headers=headers).content - pagination = str(page) + '.webp' + key = page['meta']['drm_hash'] + file = requests.get(page['meta']['source_url'], headers=headers).content + pagination = str(num + 1) + '.webp' + + if key is not None: + key = unhexlify(key[:16]) + file = xor(file, key) with open(f'{save_path}/{pagination}', 'wb') as f: - f.write(xor(enc, key)) + f.write(file) logging.info('Done.') -- cgit v1.2.3-70-g09d2