mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-01-12 17:57:43 +08:00
Continuing development
This commit is contained in:
parent
aa77ab68a9
commit
cfea295198
3 changed files with 12 additions and 7 deletions
|
@ -77,6 +77,9 @@ def update_movies():
|
|||
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:
|
||||
|
@ -111,7 +114,7 @@ def update_movies():
|
|||
profile_id_to_language(movie['qualityProfileId']), sceneName,
|
||||
unicode(bool(movie['monitored'])), movie['sortTitle'],
|
||||
movie['year'], alternativeTitles, format, resolution,
|
||||
videoCodec, audioCodec, movie["tmdbId"]))
|
||||
videoCodec, audioCodec, imdbId, movie["tmdbId"]))
|
||||
else:
|
||||
if movie_default_enabled is True:
|
||||
movies_to_add.append((movie["title"],
|
||||
|
@ -121,7 +124,7 @@ def update_movies():
|
|||
profile_id_to_language(movie['qualityProfileId']), sceneName,
|
||||
unicode(bool(movie['monitored'])), movie['sortTitle'],
|
||||
movie['year'], alternativeTitles, format, resolution,
|
||||
videoCodec, audioCodec))
|
||||
videoCodec, audioCodec, imdbId))
|
||||
else:
|
||||
movies_to_add.append((movie["title"],
|
||||
movie["path"] + separator + movie['movieFile'][
|
||||
|
@ -130,7 +133,7 @@ def update_movies():
|
|||
profile_id_to_language(movie['qualityProfileId']), sceneName,
|
||||
unicode(bool(movie['monitored'])), movie['sortTitle'],
|
||||
movie['year'], alternativeTitles, format, resolution,
|
||||
videoCodec, audioCodec))
|
||||
videoCodec, audioCodec, imdbId))
|
||||
else:
|
||||
logging.error(
|
||||
'BAZARR Radarr returned a movie without a file path: ' + movie["path"] + separator +
|
||||
|
@ -141,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 = ?, year = ?, alternativeTitles = ?, format = ?, resolution = ?, video_codec = ?, audio_codec = ? 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, year, alternativeTitles, format, resolution, video_codec, audio_codec) 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, year, alternativeTitles, format, resolution, video_codec, audio_codec) 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()
|
||||
|
||||
|
|
|
@ -708,11 +708,12 @@ def refine_from_db(path, video):
|
|||
elif isinstance(video, Movie):
|
||||
db = sqlite3.connect(os.path.join(args.config_dir, 'db', 'bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
data = c.execute("SELECT title, year, alternativeTitles, format, resolution, video_codec, audio_codec FROM table_movies WHERE path = ?", (path_replace_reverse_movie(path),)).fetchone()
|
||||
data = c.execute("SELECT title, year, alternativeTitles, format, resolution, video_codec, audio_codec, imdbId FROM table_movies WHERE path = ?", (path_replace_reverse_movie(path),)).fetchone()
|
||||
db.close()
|
||||
if data:
|
||||
video.title = re.sub(r'(\(\d\d\d\d\))' , '', data[0])
|
||||
if int(data[1]) > 0: video.year = int(data[1])
|
||||
if data[7]: video.imdb_id = data[7]
|
||||
video.alternative_titles = ast.literal_eval(data[2])
|
||||
if not video.format:
|
||||
if data[3]: video.format = data[3]
|
||||
|
|
|
@ -111,6 +111,7 @@ if os.path.exists(os.path.join(args.config_dir, 'db', 'bazarr.db')):
|
|||
c.execute('alter table table_movies add column "resolution" "text"')
|
||||
c.execute('alter table table_movies add column "video_codec" "text"')
|
||||
c.execute('alter table table_movies add column "audio_codec" "text"')
|
||||
c.execute('alter table table_movies add column "imdbId" "text"')
|
||||
db.commit()
|
||||
except:
|
||||
pass
|
||||
|
|
Loading…
Reference in a new issue