@ -73,7 +73,31 @@ def update_movies():
sceneName = movie [ ' movieFile ' ] [ ' sceneName ' ]
else :
sceneName = None
if movie [ ' alternativeTitles ' ] != None :
alternativeTitles = str ( [ item [ ' title ' ] for item in movie [ ' alternativeTitles ' ] ] )
if ' imdbId ' in movie : imdbId = movie [ ' imdbId ' ]
else : imdbId = None
try :
format , resolution = movie [ ' movieFile ' ] [ ' quality ' ] [ ' quality ' ] [ ' name ' ] . split ( ' - ' )
except :
format = movie [ ' movieFile ' ] [ ' quality ' ] [ ' quality ' ] [ ' name ' ]
resolution = movie [ ' movieFile ' ] [ ' quality ' ] [ ' quality ' ] [ ' resolution ' ] . lstrip ( ' r ' ) . lower ( )
videoFormat = movie [ ' movieFile ' ] [ ' mediaInfo ' ] [ ' videoFormat ' ]
videoCodecID = movie [ ' movieFile ' ] [ ' mediaInfo ' ] [ ' videoCodecID ' ]
videoProfile = movie [ ' movieFile ' ] [ ' mediaInfo ' ] [ ' videoProfile ' ]
videoCodecLibrary = movie [ ' movieFile ' ] [ ' mediaInfo ' ] [ ' videoCodecLibrary ' ]
videoCodec = RadarrFormatVideoCodec ( videoFormat , videoCodecID , videoProfile , videoCodecLibrary )
audioFormat = movie [ ' movieFile ' ] [ ' mediaInfo ' ] [ ' audioFormat ' ]
audioCodecID = movie [ ' movieFile ' ] [ ' mediaInfo ' ] [ ' audioCodecID ' ]
audioProfile = movie [ ' movieFile ' ] [ ' mediaInfo ' ] [ ' audioProfile ' ]
audioAdditionalFeatures = movie [ ' movieFile ' ] [ ' mediaInfo ' ] [ ' audioAdditionalFeatures ' ]
audioCodec = RadarrFormatAudioCodec ( audioFormat , audioCodecID , audioProfile , audioAdditionalFeatures )
# Add movies in radarr to current movies list
current_movies_radarr . append ( unicode ( movie [ ' tmdbId ' ] ) )
@ -89,22 +113,27 @@ def update_movies():
movie [ " tmdbId " ] , movie [ " id " ] , overview , poster , fanart ,
profile_id_to_language ( movie [ ' qualityProfileId ' ] ) , sceneName ,
unicode ( bool ( movie [ ' monitored ' ] ) ) , movie [ ' sortTitle ' ] ,
movie [ " tmdbId " ] ) )
movie [ ' year ' ] , alternativeTitles , format , resolution ,
videoCodec , audioCodec , imdbId , 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 ,
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 ' ] ) ) , movie [ ' sortTitle ' ] ) )
unicode ( bool ( movie [ ' monitored ' ] ) ) , movie [ ' sortTitle ' ] ,
movie [ ' year ' ] , alternativeTitles , format , resolution ,
videoCodec , audioCodec , imdbId ) )
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 ' ] ) ) , movie [ ' sortTitle ' ] ) )
unicode ( bool ( movie [ ' monitored ' ] ) ) , movie [ ' sortTitle ' ] ,
movie [ ' year ' ] , alternativeTitles , format , resolution ,
videoCodec , audioCodec , imdbId ) )
else :
logging . error (
' BAZARR Radarr returned a movie without a file path: ' + movie [ " path " ] + separator +
@ -115,18 +144,18 @@ def update_movies():
c = db . cursor ( )
updated_result = c . executemany (
''' UPDATE table_movies SET title = ?, path = ?, tmdbId = ?, radarrId = ?, overview = ?, poster = ?, fanart = ?, `audio_language` = ?, sceneName = ?, monitored = ?, sortTitle = ? WHERE tmdbid = ?''' ,
''' UPDATE table_movies SET title = ?, path = ?, tmdbId = ?, radarrId = ?, overview = ?, poster = ?, fanart = ?, `audio_language` = ?, sceneName = ?, monitored = ?, sortTitle = ?, year = ?, alternativeTitles = ?, format = ?, resolution = ?, video_codec = ?, audio_codec = ?, imdbId = ? WHERE tmdbid = ?''' ,
movies_to_update )
db . commit ( )
if movie_default_enabled is True :
added_result = c . executemany (
''' INSERT OR IGNORE INTO table_movies(title, path, tmdbId, languages, subtitles,`hearing_impaired`, radarrId, overview, poster, fanart, `audio_language`, sceneName, monitored, sortTitle ) VALUES (?,?,?,?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''' ,
''' INSERT OR IGNORE INTO table_movies(title, path, tmdbId, languages, subtitles,`hearing_impaired`, radarrId, overview, poster, fanart, `audio_language`, sceneName, monitored, sortTitle , year, alternativeTitles, format, resolution, video_codec, audio_codec, imdbId ) VALUES (?,?,?,?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''' ,
movies_to_add )
db . commit ( )
else :
added_result = c . executemany (
''' INSERT OR IGNORE INTO table_movies(title, path, tmdbId, languages, subtitles,`hearing_impaired`, radarrId, overview, poster, fanart, `audio_language`, sceneName, monitored, sortTitle ) VALUES (?,?,?,(SELECT languages FROM table_movies WHERE tmdbId = ?), ' [] ' ,(SELECT `hearing_impaired` FROM table_movies WHERE tmdbId = ?) , ?, ?, ?, ?, ?, ?, ?, ?)''' ,
''' INSERT OR IGNORE INTO table_movies(title, path, tmdbId, languages, subtitles,`hearing_impaired`, radarrId, overview, poster, fanart, `audio_language`, sceneName, monitored, sortTitle , year, alternativeTitles, format, resolution, video_codec, audio_codec, imdbId ) VALUES (?,?,?,(SELECT languages FROM table_movies WHERE tmdbId = ?), ' [] ' ,(SELECT `hearing_impaired` FROM table_movies WHERE tmdbId = ?) , ?, ?, ?, ?, ?, ?, ? , ?, ?, ?, ?, ?, ?, ?, ?)''' ,
movies_to_add )
db . commit ( )
@ -183,5 +212,51 @@ def profile_id_to_language(id):
return profile [ 1 ]
def RadarrFormatAudioCodec ( audioFormat , audioCodecID , audioProfile , audioAdditionalFeatures ) :
if audioFormat == " AC-3 " : return " AC3 "
if audioFormat == " E-AC-3 " : return " EAC3 "
if audioFormat == " AAC " :
if audioCodecID == " A_AAC/MPEG4/LC/SBR " :
return " HE-AAC "
else :
return " AAC "
if audioFormat . strip ( ) == " mp3 " : return " MP3 "
if audioFormat == " MPEG Audio " :
if audioCodecID == " 55 " or audioCodecID == " A_MPEG/L3 " or audioProfile == " Layer 3 " : return " MP3 "
if audioCodecID == " A_MPEG/L2 " or audioProfile == " Layer 2 " : return " MP2 "
if audioFormat == " MLP FBA " :
if audioAdditionalFeatures == " 16-ch " :
return " TrueHD Atmos "
else :
return " TrueHD "
return audioFormat
def RadarrFormatVideoCodec ( videoFormat , videoCodecID , videoProfile , videoCodecLibrary ) :
if videoFormat == " x264 " : return " h264 "
if videoFormat == " AVC " or videoFormat == " V.MPEG4/ISO/AVC " : return " h264 "
if videoFormat == " HEVC " or videoFormat == " V_MPEGH/ISO/HEVC " :
if videoCodecLibrary . startswith ( " x265 " ) : return " h265 "
if videoFormat == " MPEG Video " :
if videoCodecID == " 2 " or videoCodecID == " V_MPEG2 " :
return " Mpeg2 "
else :
return " Mpeg "
if videoFormat == " MPEG-1 Video " : return " Mpeg "
if videoFormat == " MPEG-2 Video " : return " Mpeg2 "
if videoFormat == " MPEG-4 Visual " :
if videoCodecID . endswith ( " XVID " ) or videoCodecLibrary . startswith ( " XviD " ) : return " XviD "
if videoCodecID . endswith ( " DIV3 " ) or videoCodecID . endswith ( " DIVX " ) or videoCodecID . endswith (
" DX50 " ) or videoCodecLibrary . startswith ( " DivX " ) : return " DivX "
if videoFormat == " VC-1 " : return " VC1 "
if videoFormat == " WMV2 " :
return " WMV "
if videoFormat == " DivX " or videoFormat == " div3 " :
return " DivX "
return videoFormat
if __name__ == ' __main__ ' :
update_movies ( )