@ -54,7 +54,7 @@ def update_movies():
# Get current movies in DB
# Get current movies in DB
current_movies_db = database . execute ( " SELECT tmdbId, path, radarrId FROM table_movies " )
current_movies_db = database . execute ( " SELECT tmdbId, path, radarrId FROM table_movies " )
current_movies_db_list = [ x [ ' tmdb _i d' ] for x in current_movies_db ]
current_movies_db_list = [ x [ ' tmdb I d' ] for x in current_movies_db ]
current_movies_radarr = [ ]
current_movies_radarr = [ ]
movies_to_update = [ ]
movies_to_update = [ ]
@ -132,31 +132,31 @@ def update_movies():
current_movies_radarr . append ( unicode ( movie [ ' tmdbId ' ] ) )
current_movies_radarr . append ( unicode ( movie [ ' tmdbId ' ] ) )
if unicode ( movie [ ' tmdbId ' ] ) in current_movies_db_list :
if unicode ( movie [ ' tmdbId ' ] ) in current_movies_db_list :
movies_to_update . append ( { ' radarr _i d' : movie [ " id " ] ,
movies_to_update . append ( { ' radarr I d' : movie [ " id " ] ,
' title ' : unicode ( movie [ " title " ] ) ,
' title ' : unicode ( movie [ " title " ] ) ,
' path ' : unicode ( movie [ " path " ] + separator + movie [ ' movieFile ' ] [ ' relativePath ' ] ) ,
' path ' : unicode ( movie [ " path " ] + separator + movie [ ' movieFile ' ] [ ' relativePath ' ] ) ,
' tmdb _i d' : unicode ( movie [ " tmdbId " ] ) ,
' tmdb I d' : unicode ( movie [ " tmdbId " ] ) ,
' poster ' : unicode ( poster ) ,
' poster ' : unicode ( poster ) ,
' fanart ' : unicode ( fanart ) ,
' fanart ' : unicode ( fanart ) ,
' audio_language ' : unicode ( profile_id_to_language ( movie [ ' qualityProfileId ' ] , audio_profiles ) ) ,
' audio_language ' : unicode ( profile_id_to_language ( movie [ ' qualityProfileId ' ] , audio_profiles ) ) ,
' scene _n ame' : sceneName ,
' scene N ame' : sceneName ,
' monitored ' : unicode ( bool ( movie [ ' monitored ' ] ) ) ,
' monitored ' : unicode ( bool ( movie [ ' monitored ' ] ) ) ,
' year ' : unicode ( movie [ ' year ' ] ) ,
' year ' : unicode ( movie [ ' year ' ] ) ,
' sort _t itle' : unicode ( movie [ ' sortTitle ' ] ) ,
' sort T itle' : unicode ( movie [ ' sortTitle ' ] ) ,
' alternative _t itles' : unicode ( alternativeTitles ) ,
' alternative T itles' : unicode ( alternativeTitles ) ,
' format ' : unicode ( format ) ,
' format ' : unicode ( format ) ,
' resolution ' : unicode ( resolution ) ,
' resolution ' : unicode ( resolution ) ,
' video_codec ' : unicode ( videoCodec ) ,
' video_codec ' : unicode ( videoCodec ) ,
' audio_codec ' : unicode ( audioCodec ) ,
' audio_codec ' : unicode ( audioCodec ) ,
' overview ' : unicode ( overview ) ,
' overview ' : unicode ( overview ) ,
' imdb _i d' : unicode ( imdbId ) ,
' imdb I d' : unicode ( imdbId ) ,
' movie_file_id ' : movie [ ' movieFile ' ] [ ' id ' ] } )
' movie_file_id ' : movie [ ' movieFile ' ] [ ' id ' ] } )
else :
else :
if movie_default_enabled is True :
if movie_default_enabled is True :
movies_to_add . append ( { ' radarr _i d' : movie [ " id " ] ,
movies_to_add . append ( { ' radarr I d' : movie [ " id " ] ,
' title ' : movie [ " title " ] ,
' title ' : movie [ " title " ] ,
' path ' : movie [ " path " ] + separator + movie [ ' movieFile ' ] [ ' relativePath ' ] ,
' path ' : movie [ " path " ] + separator + movie [ ' movieFile ' ] [ ' relativePath ' ] ,
' tmdb _i d' : movie [ " tmdbId " ] ,
' tmdb I d' : movie [ " tmdbId " ] ,
' languages ' : movie_default_language ,
' languages ' : movie_default_language ,
' subtitles ' : ' [] ' ,
' subtitles ' : ' [] ' ,
' hearing_impaired ' : movie_default_hi ,
' hearing_impaired ' : movie_default_hi ,
@ -164,37 +164,41 @@ def update_movies():
' poster ' : poster ,
' poster ' : poster ,
' fanart ' : fanart ,
' fanart ' : fanart ,
' audio_language ' : profile_id_to_language ( movie [ ' qualityProfileId ' ] , audio_profiles ) ,
' audio_language ' : profile_id_to_language ( movie [ ' qualityProfileId ' ] , audio_profiles ) ,
' scene _n ame' : sceneName ,
' scene N ame' : sceneName ,
' monitored ' : unicode ( bool ( movie [ ' monitored ' ] ) ) ,
' monitored ' : unicode ( bool ( movie [ ' monitored ' ] ) ) ,
' sort _t itle' : movie [ ' sortTitle ' ] ,
' sort T itle' : movie [ ' sortTitle ' ] ,
' year ' : movie [ ' year ' ] ,
' year ' : movie [ ' year ' ] ,
' alternative _t itles' : alternativeTitles ,
' alternative T itles' : alternativeTitles ,
' format ' : format ,
' format ' : format ,
' resolution ' : resolution ,
' resolution ' : resolution ,
' video_codec ' : videoCodec ,
' video_codec ' : videoCodec ,
' audio_codec ' : audioCodec ,
' audio_codec ' : audioCodec ,
' imdb _i d' : imdbId ,
' imdb I d' : imdbId ,
' forced ' : movie_default_forced ,
' forced ' : movie_default_forced ,
' movie_file_id ' : movie [ ' movieFile ' ] [ ' id ' ] } )
' movie_file_id ' : movie [ ' movieFile ' ] [ ' id ' ] } )
else :
else :
movies_to_add . append ( { ' radarr _i d' : movie [ " id " ] ,
movies_to_add . append ( { ' radarr I d' : movie [ " id " ] ,
' title ' : movie [ " title " ] ,
' title ' : movie [ " title " ] ,
' path ' : movie [ " path " ] + separator + movie [ ' movieFile ' ] [ ' relativePath ' ] ,
' path ' : movie [ " path " ] + separator + movie [ ' movieFile ' ] [ ' relativePath ' ] ,
' tmdb_id ' : movie [ " tmdbId " ] ,
' tmdbId ' : movie [ " tmdbId " ] ,
' languages ' : None ,
' subtitles ' : ' [] ' ,
' hearing_impaired ' : None ,
' overview ' : overview ,
' overview ' : overview ,
' poster ' : poster ,
' poster ' : poster ,
' fanart ' : fanart ,
' fanart ' : fanart ,
' audio_language ' : profile_id_to_language ( movie [ ' qualityProfileId ' ] , audio_profiles ) ,
' audio_language ' : profile_id_to_language ( movie [ ' qualityProfileId ' ] , audio_profiles ) ,
' scene _n ame' : sceneName ,
' scene N ame' : sceneName ,
' monitored ' : unicode ( bool ( movie [ ' monitored ' ] ) ) ,
' monitored ' : unicode ( bool ( movie [ ' monitored ' ] ) ) ,
' sort _t itle' : movie [ ' sortTitle ' ] ,
' sort T itle' : movie [ ' sortTitle ' ] ,
' year ' : movie [ ' year ' ] ,
' year ' : movie [ ' year ' ] ,
' alternative _t itles' : alternativeTitles ,
' alternative T itles' : alternativeTitles ,
' format ' : format ,
' format ' : format ,
' resolution ' : resolution ,
' resolution ' : resolution ,
' video_codec ' : videoCodec ,
' video_codec ' : videoCodec ,
' audio_codec ' : audioCodec ,
' audio_codec ' : audioCodec ,
' imdb_id ' : imdbId ,
' imdbId ' : imdbId ,
' forced ' : None ,
' movie_file_id ' : movie [ ' movieFile ' ] [ ' id ' ] } )
' movie_file_id ' : movie [ ' movieFile ' ] [ ' id ' ] } )
else :
else :
logging . error (
logging . error (
@ -215,21 +219,22 @@ def update_movies():
for updated_movie in movies_to_update_list :
for updated_movie in movies_to_update_list :
query = dict_converter . convert ( updated_movie )
query = dict_converter . convert ( updated_movie )
database . execute ( " UPDATE table_movies SET ? WHERE radarrId=? " ,
database . execute ( ''' UPDATE table_movies SET ''' + query . keys_update + ''' WHERE radarrId = ? ''' ,
( query . items , updated_movie [ ' radarr_id ' ] ) )
query . values + ( updated_movie [ ' radarrId ' ] , ) )
altered_movies . append ( [ updated_movie [ ' tmdb _i d' ] ,
altered_movies . append ( [ updated_movie [ ' tmdb I d' ] ,
updated_movie [ ' path ' ] ,
updated_movie [ ' path ' ] ,
updated_movie [ ' radarr _i d' ] ,
updated_movie [ ' radarr I d' ] ,
updated_movie [ ' monitored ' ] ] )
updated_movie [ ' monitored ' ] ] )
# Insert new movies in DB
# Insert new movies in DB
for added_movie in movies_to_add :
for added_movie in movies_to_add :
query = dict_converter . convert ( updated_movie )
query = dict_converter . convert ( added_movie )
database . execute ( " INSERT OR IGNORE INTO table_movies(?) VALUES(?) " ,
database . execute (
( query . keys , query . values ) )
''' INSERT OR IGNORE INTO table_movies( ''' + query . keys_insert + ''' ) VALUES( ''' +
altered_movies . append ( [ added_movie [ ' tmdb_id ' ] ,
query . question_marks + ''' ) ''' , query . values )
altered_movies . append ( [ added_movie [ ' tmdbId ' ] ,
added_movie [ ' path ' ] ,
added_movie [ ' path ' ] ,
added_movie [ ' radarr _i d' ] ,
added_movie [ ' radarr I d' ] ,
added_movie [ ' monitored ' ] ] )
added_movie [ ' monitored ' ] ] )
# Remove old movies from DB
# Remove old movies from DB