diff --git a/pattrmm.py b/pattrmm.py index b3414d6..730c476 100644 --- a/pattrmm.py +++ b/pattrmm.py @@ -105,7 +105,7 @@ def tmdb_id(self, rating_key): year = self.year(rating_key) if year != None: print("") - print("No TMDB ID found locally: Searching themoviedb.org with " + show_name + " and year " + str(year)) + print("No TMDB ID found in Plex: Searching for " + show_name + " with year " + str(year)) search = self.search_tmdb_id(show_name, year) if search == None: year = int(year) @@ -856,7 +856,7 @@ def __init__(self, id, title, firstAir, lastAir, nextAir, status, pop): tmdb = json.loads(prettyJson(requests.get(tmdbUrl, headers=tmdbHeaders, params=tmdbParams).json())) - print("Refreshing data for " + tmdb['name'] + " ( " + str(tmdb['id']) + " )") + print("\033[KRefreshing data for " + tmdb['name'] + " ( " + str(tmdb['id']) + " )", end="\r", flush=True) if tmdb['last_air_date'] != None and tmdb['last_air_date'] != "" : lastAir = tmdb['last_air_date'] @@ -899,7 +899,7 @@ def __init__(self, id, title, firstAir, lastAir, nextAir, status, pop): writeTmdb = open(cache, "w") writeTmdb.write(listResults) writeTmdb.close() - print(library + " TMDB data updated...") + print("\033[K" + library + " TMDB data updated...") # write Template to Overlay file @@ -1162,24 +1162,32 @@ def __init__(self, id, title, firstAir, lastAir, nextAir, status, pop): traktMakeList = requests.post(traktListUrl, headers=traktHeaders, data=traktListData) time.sleep(1.25) + traktListShow = ''' +{ + "shows": [ + ''' for item in returningSorted: print("Adding " + item['title'] + " | TMDB ID: " + str(item['id']) + ", to Returning Soon " + library + ".") - traktListShow = f''' -{{ -"shows": [ + traktListShow += f''' {{ "ids": {{ "tmdb": "{str(item['id'])}" }} - }} + }},''' + + traktListShow = traktListShow.rstrip(",") + traktListShow += ''' ] -}} - ''' - postShow = requests.post(traktListUrlPostShow, headers=traktHeaders, data=traktListShow) - time.sleep(1.25) +} +''' - print("Added " + str(get_count(returningSorted)) + " entries to Trakt.") + postShow = requests.post(traktListUrlPostShow, headers=traktHeaders, data=traktListShow) + if postShow.status_code == 201: + print("Success") + print("Added " + str(get_count(returningSorted)) + " entries to Trakt.") + else: + print("Failure: " + str(postShow.status_code)) end_time = time.time() elapsed_time = end_time - start_time minutes, seconds = divmod(elapsed_time, 60)