From 8c91494e647179252a04dc1f193a0d1549d555db Mon Sep 17 00:00:00 2001 From: morpheus65535 <5130500+morpheus65535@users.noreply.github.com> Date: Sun, 4 Nov 2018 22:17:21 -0500 Subject: [PATCH] Fix for missing path returned by Radarr #213 --- bazarr/get_movies.py | 65 +++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/bazarr/get_movies.py b/bazarr/get_movies.py index 24aa76497..fd3e3db13 100644 --- a/bazarr/get_movies.py +++ b/bazarr/get_movies.py @@ -50,41 +50,44 @@ def update_movies(): for movie in r.json(): if movie['hasFile'] is True: if 'movieFile' in movie: - try: - overview = unicode(movie['overview']) - except: - overview = "" - try: - poster_big = movie['images'][0]['url'] - poster = os.path.splitext(poster_big)[0] + '-500' + os.path.splitext(poster_big)[1] - except: - poster = "" - try: - fanart = movie['images'][1]['url'] - except: - fanart = "" - - if 'sceneName' in movie['movieFile']: - sceneName = movie['movieFile']['sceneName'] - else: - sceneName = None + if movie['movieFile']['relativePath'] is not None: + try: + overview = unicode(movie['overview']) + except: + overview = "" + try: + poster_big = movie['images'][0]['url'] + poster = os.path.splitext(poster_big)[0] + '-500' + os.path.splitext(poster_big)[1] + except: + poster = "" + try: + fanart = movie['images'][1]['url'] + except: + fanart = "" + + if 'sceneName' in movie['movieFile']: + sceneName = movie['movieFile']['sceneName'] + else: + sceneName = None - # Add movies in radarr to current movies list - current_movies_radarr.append(unicode(movie['tmdbId'])) + # Add movies in radarr to current movies list + current_movies_radarr.append(unicode(movie['tmdbId'])) - # Detect file separator - if movie['path'][0] == "/": - separator = "/" - else: - separator = "\\" + # Detect file separator + if movie['path'][0] == "/": + separator = "/" + else: + separator = "\\" - if unicode(movie['tmdbId']) in current_movies_db_list: - movies_to_update.append((movie["title"],movie["path"] + separator + movie['movieFile']['relativePath'],movie["tmdbId"],movie["id"],overview,poster,fanart,profile_id_to_language(movie['qualityProfileId']),sceneName,unicode(bool(movie['monitored'])),movie["tmdbId"])) - else: - if movie_default_enabled is True: - movies_to_add.append((movie["title"], movie["path"] + separator + movie['movieFile']['relativePath'], movie["tmdbId"], movie_default_language, '[]', movie_default_hi, movie["id"], overview, poster, fanart, profile_id_to_language(movie['qualityProfileId']), sceneName, unicode(bool(movie['monitored'])))) + if unicode(movie['tmdbId']) in current_movies_db_list: + movies_to_update.append((movie["title"],movie["path"] + separator + movie['movieFile']['relativePath'],movie["tmdbId"],movie["id"],overview,poster,fanart,profile_id_to_language(movie['qualityProfileId']),sceneName,unicode(bool(movie['monitored'])),movie["tmdbId"])) else: - movies_to_add.append((movie["title"], movie["path"] + separator + movie['movieFile']['relativePath'], movie["tmdbId"], movie["tmdbId"], movie["tmdbId"], movie["id"], overview, poster, fanart, profile_id_to_language(movie['qualityProfileId']), sceneName, unicode(bool(movie['monitored'])))) + if movie_default_enabled is True: + movies_to_add.append((movie["title"], movie["path"] + separator + movie['movieFile']['relativePath'], movie["tmdbId"], movie_default_language, '[]', movie_default_hi, movie["id"], overview, poster, fanart, profile_id_to_language(movie['qualityProfileId']), sceneName, unicode(bool(movie['monitored'])))) + else: + movies_to_add.append((movie["title"], movie["path"] + separator + movie['movieFile']['relativePath'], movie["tmdbId"], movie["tmdbId"], movie["tmdbId"], movie["id"], overview, poster, fanart, profile_id_to_language(movie['qualityProfileId']), sceneName, unicode(bool(movie['monitored'])))) + else: + logging.error('BAZARR Radarr returned a movie without a file path: ' + movie["path"] + separator + movie['movieFile']['relativePath']) # Update or insert movies in DB db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)