Add function to update update table
This commit is contained in:
@@ -3,7 +3,7 @@ loglevel=info
|
||||
|
||||
[dbsettings]
|
||||
sqlserver_driver=ODBC Driver 13 for SQL Server
|
||||
hostname=192.168.128.7
|
||||
hostname=192.168.128.3
|
||||
mghostname=192.168.128.24
|
||||
dbname=media_dbsync
|
||||
mgdbname=tvdata
|
||||
|
||||
@@ -183,6 +183,8 @@ def main() -> int:
|
||||
try:
|
||||
os.makedirs(tempdir, exist_ok=True)
|
||||
out_file = 'tvmaze_updates.json'
|
||||
prev_file = 'post_tvmaze_updates.json'
|
||||
previous_updates_file = f"{tempdir}{prev_file}"
|
||||
# TVMAZE_URLS is a dict of urls; use the updatesurl if available
|
||||
updates_url = TVMAZE_URLS.get('updatesurl') if isinstance(TVMAZE_URLS, dict) else None
|
||||
if updates_url:
|
||||
@@ -250,6 +252,18 @@ def main() -> int:
|
||||
"select seriesid, timestamp from updates.tvupdates order by seriesid",
|
||||
lprint
|
||||
)
|
||||
print(f"Saving previous update to file.")
|
||||
with open(f"{previous_updates_file}", 'w') as pjf:
|
||||
for pl in previouslisting:
|
||||
pjf.write(f"{pl[0]}: {pl[1]}\n")
|
||||
pjf.close()
|
||||
print(f"Updating update table.")
|
||||
dbExec.update_tvupdates(
|
||||
dbengine["engine"],
|
||||
downloaded_updates_dict,
|
||||
"updates.tvupdates"
|
||||
)
|
||||
print("update complete.")
|
||||
# convert previouslisting (list of tuples) into a dict: row_id -> country_name
|
||||
try:
|
||||
_previouslisting_list = previouslisting
|
||||
@@ -279,6 +293,7 @@ def main() -> int:
|
||||
for seriesid, ts in downloaded_updates_dict.items():
|
||||
if seriesid in previous_listing_dict:
|
||||
prev_ts = previous_listing_dict[seriesid]
|
||||
# Check to see if all json files are present for seriesid
|
||||
try:
|
||||
if int(ts) == int(prev_ts):
|
||||
found_path = find_file_in_multiple_dirs(f"{seriesid}.json", directory_list)
|
||||
@@ -295,6 +310,7 @@ def main() -> int:
|
||||
for directory in directory_list:
|
||||
files_needed.append([f"{directory}", f"{seriesid}.json"])
|
||||
else:
|
||||
# Add needed json files to needed file list.
|
||||
for directory in directory_list:
|
||||
files_needed.append([f"{directory}", f"{seriesid}.json"])
|
||||
lprint.logprint("debug", f"Series {seriesid} present in downloaded updates but missing in previous listing")
|
||||
|
||||
Reference in New Issue
Block a user