Added progress indicator

This commit is contained in:
Jonas_Jones 2023-12-15 04:17:11 +01:00
parent cec73a4e42
commit d74248ffb5

View file

@ -204,7 +204,7 @@ def convert_monthly_content_to_json(content, year, month):
print("[IGNORED] Error parsing line: '" + line + "'") print("[IGNORED] Error parsing line: '" + line + "'")
print(e) print(e)
print(f"Found {len(json_data)} entries in {year}-{month}.") print(f" ==>Found {len(json_data)} entries in {year}-{month}.")
return json_data return json_data
@ -272,7 +272,14 @@ if content:
for wiki_link in content[::-1]: for wiki_link in content[::-1]:
print("Fetching monthly page: " + wiki_link) progress = int(content[::-1].index(wiki_link)/len(content)*100)
if progress < 10:
progress = " " + str(progress)
elif progress < 100:
progress = " " + str(progress)
print(f"[{progress}%]Fetching monthly page: " + wiki_link)
try: try:
# fetch the monthly page and parse it # fetch the monthly page and parse it
@ -285,7 +292,7 @@ if content:
print(e) print(e)
exit(1) exit(1)
print("Parsed monthly page: " + wiki_link) print(f"[{progress}%]Parsed monthly page: " + wiki_link)
# sleep for 2 seconds to avoid getting rate limited # sleep for 2 seconds to avoid getting rate limited
# reddit api is awful # reddit api is awful