Debug print

This commit is contained in:
itec78 2021-08-19 02:45:01 +02:00
parent 6ed57d322e
commit da36543168

View file

@ -16,15 +16,17 @@ locale.setlocale(locale.LC_TIME, 'it_IT.UTF-8')
# Scarica tutti i post da Mastodon # Scarica tutti i post da Mastodon
mastodon = Mastodon(api_base_url = "https://mastodon.bida.im") print("Scarico i post")
all_vgos = []
last_id = None
def default(o): def default(o):
if isinstance(o, (datetime.date, datetime.datetime)): if isinstance(o, (datetime.date, datetime.datetime)):
return o.isoformat() return o.isoformat()
if not os.path.isfile('oloturiadump.json'): if not os.path.isfile('oloturiadump.json'):
mastodon = Mastodon(api_base_url = "https://mastodon.bida.im")
all_vgos = []
last_id = None
while True: while True:
statuses = list(filter(lambda s: s['account']['username'] == 'oloturia', mastodon.timeline_hashtag("vgo", local=True, max_id=last_id))) statuses = list(filter(lambda s: s['account']['username'] == 'oloturia', mastodon.timeline_hashtag("vgo", local=True, max_id=last_id)))
if not statuses: if not statuses:
@ -53,6 +55,7 @@ if not os.path.isfile('oloturiadump.json'):
# Scarica tutte le immagini # Scarica tutte le immagini
print("Scarico le immagini")
with open('oloturiadump.json') as json_file: with open('oloturiadump.json') as json_file:
all_vgos = json.load(json_file) all_vgos = json.load(json_file)
os.makedirs('media', exist_ok=True) os.makedirs('media', exist_ok=True)
@ -86,6 +89,7 @@ with open('oloturiadump.json') as json_file:
# Genera i PDF # Genera i PDF
print("Genero i PDF")
os.makedirs('pdf', exist_ok=True) os.makedirs('pdf', exist_ok=True)
for vgo in all_vgos: for vgo in all_vgos:
vgo_num = html2text.html2text(vgo['content']).split(' ')[0] vgo_num = html2text.html2text(vgo['content']).split(' ')[0]
@ -151,6 +155,7 @@ with open('oloturiadump.json') as json_file:
# Genera i libretti # Genera i libretti
print("Genero i libretti")
os.makedirs('books', exist_ok=True) os.makedirs('books', exist_ok=True)
for book_num in range(1, int(len(vgo_dict) / 50) + 2): for book_num in range(1, int(len(vgo_dict) / 50) + 2):
pdfWriter = PyPDF2.PdfFileWriter() pdfWriter = PyPDF2.PdfFileWriter()