Skip to content

Instantly share code, notes, and snippets.

@nwtnni
Created May 2, 2023 19:47
Show Gist options
  • Save nwtnni/601b30463922052d2a09dd767b52988a to your computer and use it in GitHub Desktop.
Save nwtnni/601b30463922052d2a09dd767b52988a to your computer and use it in GitHub Desktop.
Download and concatenate Linux Device Drivers (3ed.) chapters into one PDF
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