Add logging support to JSON download function in update_mongo.py
This commit is contained in:
+2
-2
@@ -5,7 +5,7 @@ import json
|
|||||||
import requests
|
import requests
|
||||||
import time
|
import time
|
||||||
|
|
||||||
def download_json_to_file(api_url, outputdir, output_file):
|
def download_json_to_file(api_url, outputdir, output_file, lprint):
|
||||||
"""
|
"""
|
||||||
Downloads JSON data from the given API URL and saves it to the specified file.
|
Downloads JSON data from the given API URL and saves it to the specified file.
|
||||||
"""
|
"""
|
||||||
@@ -18,5 +18,5 @@ def download_json_to_file(api_url, outputdir, output_file):
|
|||||||
#print(f"JSON data saved to {outputdir}{output_file}")
|
#print(f"JSON data saved to {outputdir}{output_file}")
|
||||||
time.sleep(.5) # Sleep for 0.5 second to avoid overwhelming the server
|
time.sleep(.5) # Sleep for 0.5 second to avoid overwhelming the server
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Failed to download or save JSON: {e}")
|
lprint.logprint("info", f"Downloadinng {outputdir}{output_file} for series ID: {output_file.replace('.json', '')} failed: {e}")
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -327,7 +327,7 @@ def main() -> int:
|
|||||||
else:
|
else:
|
||||||
url_template = TVMAZE_URLS["showurl"]
|
url_template = TVMAZE_URLS["showurl"]
|
||||||
seriesid = file.replace('.json', '')
|
seriesid = file.replace('.json', '')
|
||||||
json_downloader.download_json_to_file(url_template.replace("<seriesid>", str(seriesid)), directory, f'{seriesid}.json')
|
json_downloader.download_json_to_file(url_template.replace("<seriesid>", str(seriesid)), directory, f'{seriesid}.json', lprint)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user