oreilly-downloader

download epub books from O'Reilly
git clone https://git.ce9e.org/oreilly-downloader.git

commit
dcaab1e657a82f9a351d496988c5fd1b53ee1ccb
parent
8c20833f9db46fdfc5237adbef70ecb80ab36f5f
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2025-06-18 13:05
refactor: use zip writestr()

Diffstat

M oreilly_downloader.py 10 +++-------

1 files changed, 3 insertions, 7 deletions


diff --git a/oreilly_downloader.py b/oreilly_downloader.py

@@ -29,14 +29,10 @@ async def fetch_book(book_id, zfh, session):
   29    29         async with session.get(url) as r:
   30    30             content = await r.read()
   31    31             content = content.replace(b_root_path, b'/EPUB/')
   32    -1             with zfh.open(path, 'w') as fh:
   33    -1                 fh.write(content)
   -1    32             zfh.writestr(path, content)
   34    33 
   35    -1     with zfh.open('mimetype', 'w') as fh:
   36    -1         fh.write(b'application/epub+zip\n')
   37    -1 
   38    -1     with zfh.open('META-INF/container.xml', 'w') as fh:
   39    -1         fh.write(CONTAINER)
   -1    34     zfh.writestr('mimetype', b'application/epub+zip\n')
   -1    35     zfh.writestr('META-INF/container.xml', CONTAINER)
   40    36 
   41    37     url = BASE_URL + root_path
   42    38     while url: