mirror of
https://github.com/JonasunderscoreJones/turbo-octo-potato.git
synced 2025-10-28 03:29:18 +01:00
Added progress indicator
This commit is contained in:
parent
cec73a4e42
commit
d74248ffb5
1 changed files with 10 additions and 3 deletions
13
rpopfetch.py
13
rpopfetch.py
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue