Compare commits
No commits in common. "master" and "main" have entirely different histories.
4 changed files with 3 additions and 3281 deletions
3
README.md
Normal file
3
README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Bookshelf
|
||||
|
||||
Downloader für raspi bookshelf
|
1608
magpi all.json
1608
magpi all.json
File diff suppressed because it is too large
Load diff
1608
magpi.json
1608
magpi.json
File diff suppressed because it is too large
Load diff
65
main.py
65
main.py
|
@ -1,65 +0,0 @@
|
|||
|
||||
import requests
|
||||
import xmltodict
|
||||
import json
|
||||
import os
|
||||
from tqdm import tqdm
|
||||
|
||||
os.makedirs('magpis', exist_ok=True)
|
||||
os.makedirs('hackspaces', exist_ok=True)
|
||||
os.makedirs('books', exist_ok=True)
|
||||
|
||||
# Laden der XML-Daten
|
||||
#bookshelf_xml = requests.get("https://magpi.raspberrypi.com/bookshelf.xml")
|
||||
#bookshelf_dict = xmltodict.parse(bookshelf_xml.content)
|
||||
#bookshelf_json = json.dumps(magpi_dict, indent=4)
|
||||
bookshelf_json = json.dumps(open("magpi.json","r").read())
|
||||
|
||||
for item in bookshelf_dict["PUBS"]["MAGPI"]["ITEM"]:
|
||||
title = item["TITLE"]
|
||||
pdf_url = item["PDF"]
|
||||
|
||||
print(f"Downloading MagPi:{title}... ")#, end="", flush=True)
|
||||
|
||||
# Herunterladen der PDF-Datei mit Fortschrittsanzeige
|
||||
response = requests.get(pdf_url, stream=True)
|
||||
total_size = int(response.headers.get('content-length', 0))
|
||||
block_size = 1024 # 1 Kibibyte
|
||||
|
||||
with open(f"magpis/{title}.pdf", "wb") as pdf:
|
||||
for data in tqdm(response.iter_content(block_size), total=total_size//block_size, unit='KiB', unit_scale=True):
|
||||
pdf.write(data)# Herunterladen der Magazine
|
||||
|
||||
|
||||
|
||||
for item in bookshelf_dict["PUBS"]["HACKSPACE"]["ITEM"]:
|
||||
title = item["TITLE"]
|
||||
pdf_url = item["PDF"]
|
||||
|
||||
print(f"Downloading Hackspace:{title}... ")#, end="", flush=True)
|
||||
|
||||
# Herunterladen der PDF-Datei mit Fortschrittsanzeige
|
||||
response = requests.get(pdf_url, stream=True)
|
||||
total_size = int(response.headers.get('content-length', 0))
|
||||
block_size = 1024 # 1 Kibibyte
|
||||
|
||||
with open(f"hackspaces/{title}.pdf", "wb") as pdf:
|
||||
for data in tqdm(response.iter_content(block_size), total=total_size//block_size, unit='KiB', unit_scale=True):
|
||||
pdf.write(data)
|
||||
|
||||
|
||||
|
||||
for item in bookshelf_dict["PUBS"]["BOOKS"]["ITEM"]:
|
||||
title = item["TITLE"]
|
||||
pdf_url = item["PDF"]
|
||||
|
||||
print(f"Downloading Book:{title}... ")#, end="", flush=True)
|
||||
|
||||
# Herunterladen der PDF-Datei mit Fortschrittsanzeige
|
||||
response = requests.get(pdf_url, stream=True)
|
||||
total_size = int(response.headers.get('content-length', 0))
|
||||
block_size = 1024 # 1 Kibibyte
|
||||
|
||||
with open(f"books/{title}.pdf", "wb") as pdf:
|
||||
for data in tqdm(response.iter_content(block_size), total=total_size//block_size, unit='KiB', unit_scale=True):
|
||||
pdf.write(data)
|
Loading…
Reference in a new issue