Created
May 2, 2023 19:47
-
-
Save nwtnni/601b30463922052d2a09dd767b52988a to your computer and use it in GitHub Desktop.
Download and concatenate Linux Device Drivers (3ed.) chapters into one PDF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
chapters = [ | |
"TITLE", | |
"COPYRIGHT", | |
"ldr3TOC.fm", | |
*[f"ch{index:02}" for index in range(19)], | |
"ldr3IX.fm", | |
] | |
async def download(chapter): | |
wget = await asyncio.create_subprocess_exec( | |
"wget", | |
*[ | |
"--quiet", | |
f"https://lwn.net/images/pdf/LDD3/{chapter}.pdf" | |
] | |
) | |
await wget.wait() | |
async def main(): | |
await asyncio.gather(*[download(chapter) for chapter in chapters]) | |
paths = [f"{chapter}.pdf" for chapter in chapters] | |
pdfunite = await asyncio.create_subprocess_exec("pdfunite", *paths, "ldd3.pdf") | |
await pdfunite.wait() | |
rm = await asyncio.create_subprocess_exec("rm", *paths) | |
await rm.wait() | |
asyncio.run(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment