mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-02-24 23:07:36 +08:00
WIP
This commit is contained in:
parent
d4115cb65f
commit
7c6f47738f
6 changed files with 47 additions and 41 deletions
|
@ -41,12 +41,18 @@ class SqliteDictPathMapper:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def path_replace(self, values_dict):
|
def path_replace(self, values_dict):
|
||||||
|
if type(values_dict) is list:
|
||||||
for item in values_dict:
|
for item in values_dict:
|
||||||
item['path'] = path_replace(item['path'])
|
item['path'] = path_replace(item['path'])
|
||||||
|
elif type(values_dict) is dict:
|
||||||
|
values_dict['path'] = path_replace(values_dict['path'])
|
||||||
|
|
||||||
def path_replace_movie(self, values_dict):
|
def path_replace_movie(self, values_dict):
|
||||||
|
if type(values_dict) is list:
|
||||||
for item in values_dict:
|
for item in values_dict:
|
||||||
item['path'] = path_replace_movie(item['path'])
|
item['path'] = path_replace_movie(item['path'])
|
||||||
|
elif type(values_dict) is dict:
|
||||||
|
values_dict['path'] = path_replace_movie(values_dict['path'])
|
||||||
|
|
||||||
|
|
||||||
dict_mapper = SqliteDictPathMapper()
|
dict_mapper = SqliteDictPathMapper()
|
|
@ -560,7 +560,7 @@ def series_download_subtitles(no):
|
||||||
episodes_details_clause, (no,))
|
episodes_details_clause, (no,))
|
||||||
|
|
||||||
series_details = database.execute("SELECT hearing_impaired, title, forced FROM table_shows WHERE sonarrSeriesId=?",
|
series_details = database.execute("SELECT hearing_impaired, title, forced FROM table_shows WHERE sonarrSeriesId=?",
|
||||||
(no,))
|
(no,), only_one=True)
|
||||||
|
|
||||||
providers_list = get_providers()
|
providers_list = get_providers()
|
||||||
providers_auth = get_providers_auth()
|
providers_auth = get_providers_auth()
|
||||||
|
@ -657,7 +657,7 @@ def movies_download_subtitles(no):
|
||||||
movie_details_clause = ''
|
movie_details_clause = ''
|
||||||
|
|
||||||
movie = database.execute("SELECT path, missing_subtitles, radarrId, sceneName, hearing_impaired, title, forced "
|
movie = database.execute("SELECT path, missing_subtitles, radarrId, sceneName, hearing_impaired, title, forced "
|
||||||
"FROM table_movies WHERE radarrId=?" + movie_details_clause, (no,))
|
"FROM table_movies WHERE radarrId=?" + movie_details_clause, (no,), only_one=True)
|
||||||
|
|
||||||
providers_list = get_providers()
|
providers_list = get_providers()
|
||||||
providers_auth = get_providers_auth()
|
providers_auth = get_providers_auth()
|
||||||
|
@ -885,7 +885,7 @@ def refine_from_db(path, video):
|
||||||
"table_episodes.video_codec, table_episodes.audio_codec, table_episodes.path "
|
"table_episodes.video_codec, table_episodes.audio_codec, table_episodes.path "
|
||||||
"FROM table_episodes INNER JOIN table_shows on "
|
"FROM table_episodes INNER JOIN table_shows on "
|
||||||
"table_shows.sonarrSeriesId = table_episodes.sonarrSeriesId "
|
"table_shows.sonarrSeriesId = table_episodes.sonarrSeriesId "
|
||||||
"WHERE table_episodes.path = ?", (unicode(path_replace_reverse(path)),))[0]
|
"WHERE table_episodes.path = ?", (unicode(path_replace_reverse(path)),), only_one=True)
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
video.series, year, country = series_re.match(data['seriesTitle']).groups()
|
video.series, year, country = series_re.match(data['seriesTitle']).groups()
|
||||||
|
@ -906,7 +906,8 @@ def refine_from_db(path, video):
|
||||||
if data['audio_codec']: video.audio_codec = data['audio_codec']
|
if data['audio_codec']: video.audio_codec = data['audio_codec']
|
||||||
elif isinstance(video, Movie):
|
elif isinstance(video, Movie):
|
||||||
data = database.execute("SELECT title, year, alternativeTitles, format, resolution, video_codec, audio_codec, "
|
data = database.execute("SELECT title, year, alternativeTitles, format, resolution, video_codec, audio_codec, "
|
||||||
"imdbId FROM table_movies WHERE path = ?", (unicode(path_replace_reverse_movie(path)),))
|
"imdbId FROM table_movies WHERE path = ?",
|
||||||
|
(unicode(path_replace_reverse_movie(path)),), only_one=True)
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
video.title = re.sub(r'(\(\d\d\d\d\))', '', data['title'])
|
video.title = re.sub(r'(\(\d\d\d\d\))', '', data['title'])
|
||||||
|
|
|
@ -104,13 +104,14 @@ def store_subtitles(file):
|
||||||
actual_subtitles.append([str(detected_language), path_replace_reverse(
|
actual_subtitles.append([str(detected_language), path_replace_reverse(
|
||||||
os.path.join(os.path.dirname(file), subtitle))])
|
os.path.join(os.path.dirname(file), subtitle))])
|
||||||
|
|
||||||
database.execute("UPDATE table_episodes SET =? WHERE path=?",
|
database.execute("UPDATE table_episodes SET subtitles=? WHERE path=?",
|
||||||
(str(actual_subtitles), path_replace_reverse(file)))
|
(str(actual_subtitles), path_replace_reverse(file)))
|
||||||
episode = database.execute("SELECT sonarrSeriesId FROM table_episodes WHERE path=?", (path_replace_reverse(file),))
|
episode = database.execute("SELECT sonarrEpisodeId FROM table_episodes WHERE path=?",
|
||||||
|
(path_replace_reverse(file),), only_one=True)
|
||||||
|
|
||||||
if len(episode):
|
if len(episode):
|
||||||
logging.debug("BAZARR storing those languages to DB: " + str(actual_subtitles))
|
logging.debug("BAZARR storing those languages to DB: " + str(actual_subtitles))
|
||||||
list_missing_subtitles(epno=episode[0]['sonarrEpisodeId'])
|
list_missing_subtitles(epno=episode['sonarrEpisodeId'])
|
||||||
else:
|
else:
|
||||||
logging.debug("BAZARR haven't been able to update existing subtitles to DB : " + str(actual_subtitles))
|
logging.debug("BAZARR haven't been able to update existing subtitles to DB : " + str(actual_subtitles))
|
||||||
else:
|
else:
|
||||||
|
@ -356,14 +357,14 @@ def series_scan_subtitles(no):
|
||||||
episodes = database.execute("SELECT path FROM table_episodes WHERE sonarrSeriesId=?", (no,))
|
episodes = database.execute("SELECT path FROM table_episodes WHERE sonarrSeriesId=?", (no,))
|
||||||
|
|
||||||
for episode in episodes:
|
for episode in episodes:
|
||||||
store_subtitles(path_replace(episode.path))
|
store_subtitles(path_replace(episode['path']))
|
||||||
|
|
||||||
|
|
||||||
def movies_scan_subtitles(no):
|
def movies_scan_subtitles(no):
|
||||||
movies = database.execute("SELECT path FROM table_movies WHERE radarrId=?", (no,))
|
movies = database.execute("SELECT path FROM table_movies WHERE radarrId=?", (no,))
|
||||||
|
|
||||||
for movie in movies:
|
for movie in movies:
|
||||||
store_subtitles_movie(path_replace_movie(movie.path))
|
store_subtitles_movie(path_replace_movie(movie['path']))
|
||||||
|
|
||||||
|
|
||||||
def get_external_subtitles_path(file, subtitle):
|
def get_external_subtitles_path(file, subtitle):
|
||||||
|
|
|
@ -575,7 +575,7 @@ def serieseditor():
|
||||||
authorize()
|
authorize()
|
||||||
|
|
||||||
# Get missing count
|
# Get missing count
|
||||||
missing_count = database.execute("SELECT COUNT(*) FROM table_shows")
|
missing_count = len(database.execute("SELECT COUNT(*) FROM table_shows"))
|
||||||
|
|
||||||
# Get series list
|
# Get series list
|
||||||
data = database.execute("SELECT tvdbId, title, path, languages, hearing_impaired, sonarrSeriesId, poster, "
|
data = database.execute("SELECT tvdbId, title, path, languages, hearing_impaired, sonarrSeriesId, poster, "
|
||||||
|
@ -649,8 +649,8 @@ def edit_series(no):
|
||||||
else:
|
else:
|
||||||
hi = "False"
|
hi = "False"
|
||||||
|
|
||||||
result = database.execute("UPDATE table_shows SET languages=?, hearing_impaired=?, forced=?) WHERE "
|
result = database.execute("UPDATE table_shows SET languages=?, hearing_impaired=?, forced=? WHERE "
|
||||||
"sonarrSeriesId=?", (lang, hi, forced, no))
|
"sonarrSeriesId=?", (str(lang), hi, forced, no))
|
||||||
|
|
||||||
list_missing_subtitles(no=no)
|
list_missing_subtitles(no=no)
|
||||||
|
|
||||||
|
@ -694,14 +694,11 @@ def episodes(no):
|
||||||
|
|
||||||
series_details = database.execute("SELECT title, overview, poster, fanart, hearing_impaired, tvdbId, "
|
series_details = database.execute("SELECT title, overview, poster, fanart, hearing_impaired, tvdbId, "
|
||||||
"audio_language, languages, path, forced FROM table_shows WHERE "
|
"audio_language, languages, path, forced FROM table_shows WHERE "
|
||||||
"sonarrSeriesId=?", (no,))
|
"sonarrSeriesId=?", (no,), only_one=True)
|
||||||
# path_replace
|
# path_replace
|
||||||
dict_mapper.path_replace(series_details)
|
dict_mapper.path_replace(series_details)
|
||||||
|
|
||||||
for series in series_details:
|
tvdbid = series_details['tvdbId']
|
||||||
tvdbid = series['tvdbId']
|
|
||||||
series_details = series
|
|
||||||
break
|
|
||||||
|
|
||||||
episodes = database.execute("SELECT title, path, season, episode, subtitles, sonarrSeriesId, missing_subtitles, "
|
episodes = database.execute("SELECT title, path, season, episode, subtitles, sonarrSeriesId, missing_subtitles, "
|
||||||
"sonarrEpisodeId, scene_name, monitored, failedAttempts FROM table_episodes WHERE "
|
"sonarrEpisodeId, scene_name, monitored, failedAttempts FROM table_episodes WHERE "
|
||||||
|
@ -727,7 +724,7 @@ def episodes(no):
|
||||||
def movies():
|
def movies():
|
||||||
authorize()
|
authorize()
|
||||||
|
|
||||||
missing_count = database.execute("SELECT COUNT(*) FROM table_movies")
|
missing_count = len(database.execute("SELECT COUNT(*) FROM table_movies"))
|
||||||
page = request.GET.page
|
page = request.GET.page
|
||||||
if page == "":
|
if page == "":
|
||||||
page = "1"
|
page = "1"
|
||||||
|
@ -754,7 +751,7 @@ def movies():
|
||||||
def movieseditor():
|
def movieseditor():
|
||||||
authorize()
|
authorize()
|
||||||
|
|
||||||
missing_count = database.execute("SELECT COUNT(*) FORM table_movies")
|
missing_count = len(database.execute("SELECT COUNT(*) FROM table_movies"))
|
||||||
|
|
||||||
data = database.execute("SELECT tmdbId, title, path, languages, hearing_impaired, radarrId, poster, "
|
data = database.execute("SELECT tmdbId, title, path, languages, hearing_impaired, radarrId, poster, "
|
||||||
"audio_language, forced FROM table_movies ORDER BY sortTitle ASC")
|
"audio_language, forced FROM table_movies ORDER BY sortTitle ASC")
|
||||||
|
@ -844,7 +841,7 @@ def movie(no):
|
||||||
movies_details = database.execute("SELECT title, overview, poster, fanart, hearing_impaired, tmdbId, "
|
movies_details = database.execute("SELECT title, overview, poster, fanart, hearing_impaired, tmdbId, "
|
||||||
"audio_language, languages, path, subtitles, radarrId, missing_subtitles, "
|
"audio_language, languages, path, subtitles, radarrId, missing_subtitles, "
|
||||||
"scenename, monitored, failedAttempts, forced FROM table_movies "
|
"scenename, monitored, failedAttempts, forced FROM table_movies "
|
||||||
"WHERE radarrId=?", (no,))
|
"WHERE radarrId=?", (no,), only_one=True)
|
||||||
# path_replace
|
# path_replace
|
||||||
dict_mapper.path_replace(movies_details)
|
dict_mapper.path_replace(movies_details)
|
||||||
|
|
||||||
|
@ -917,9 +914,9 @@ def history():
|
||||||
def historyseries():
|
def historyseries():
|
||||||
authorize()
|
authorize()
|
||||||
|
|
||||||
row_count = database.execute("SELECT COUNT(*) FROM table_history LEFT JOIN table_shows on "
|
row_count = len(database.execute("SELECT COUNT(*) FROM table_history LEFT JOIN table_shows on "
|
||||||
"table_history.sonarrSeriesId = table_shows.sonarrSeriesId WHERE table_shows.title "
|
"table_history.sonarrSeriesId = table_shows.sonarrSeriesId WHERE "
|
||||||
"is not NULL")
|
"table_shows.title is not NULL"))
|
||||||
page = request.GET.page
|
page = request.GET.page
|
||||||
if page == "":
|
if page == "":
|
||||||
page = "1"
|
page = "1"
|
||||||
|
@ -995,9 +992,9 @@ def historyseries():
|
||||||
def historymovies():
|
def historymovies():
|
||||||
authorize()
|
authorize()
|
||||||
|
|
||||||
row_count = database.execute("SELECT COUNT(*) FROM table_history_movie LEFT JOIN table_movies ON "
|
row_count = len(database.execute("SELECT COUNT(*) FROM table_history_movie LEFT JOIN table_movies ON "
|
||||||
"table_history_movie.radarrId=table_movies.radarrId "
|
"table_history_movie.radarrId=table_movies.radarrId "
|
||||||
"WHERE table_movies.title is not NULL")
|
"WHERE table_movies.title is not NULL"))
|
||||||
page = request.GET.page
|
page = request.GET.page
|
||||||
if page == "":
|
if page == "":
|
||||||
page = "1"
|
page = "1"
|
||||||
|
@ -1084,8 +1081,8 @@ def wantedseries():
|
||||||
else:
|
else:
|
||||||
monitored_only_query_string = ''
|
monitored_only_query_string = ''
|
||||||
|
|
||||||
missing_count = database.execute("SELECT COUNT(*) FROM table_episodes WHERE missing_subtitles != '[]'" +
|
missing_count = len(database.execute("SELECT COUNT(*) FROM table_episodes WHERE missing_subtitles != '[]'" +
|
||||||
monitored_only_query_string)
|
monitored_only_query_string))
|
||||||
page = request.GET.page
|
page = request.GET.page
|
||||||
if page == "":
|
if page == "":
|
||||||
page = "1"
|
page = "1"
|
||||||
|
@ -1117,8 +1114,8 @@ def wantedmovies():
|
||||||
else:
|
else:
|
||||||
monitored_only_query_string = ''
|
monitored_only_query_string = ''
|
||||||
|
|
||||||
missing_count = database.execute("SELECT COUNT(*) FROM table_movies WHERE missing_subtitles != '[]'" +
|
missing_count = len(database.execute("SELECT COUNT(*) FROM table_movies WHERE missing_subtitles != '[]'" +
|
||||||
monitored_only_query_string)
|
monitored_only_query_string))
|
||||||
page = request.GET.page
|
page = request.GET.page
|
||||||
if page == "":
|
if page == "":
|
||||||
page = "1"
|
page = "1"
|
||||||
|
|
|
@ -47,19 +47,20 @@ def get_notifier_providers():
|
||||||
|
|
||||||
|
|
||||||
def get_series_name(sonarrSeriesId):
|
def get_series_name(sonarrSeriesId):
|
||||||
data = database.execute("SELECT title FROM table_shows WHERE sonarrSeriesId=?", (sonarrSeriesId,))
|
data = database.execute("SELECT title FROM table_shows WHERE sonarrSeriesId=?", (sonarrSeriesId,), only_one=True)
|
||||||
|
|
||||||
return data[0]['title'] or None
|
return data[0]['title'] or None
|
||||||
|
|
||||||
|
|
||||||
def get_episode_name(sonarrEpisodeId):
|
def get_episode_name(sonarrEpisodeId):
|
||||||
data = database.execute("SELECT title, season, episode FROM table_episodes WHERE sonarrEpisodeId=?", (sonarrEpisodeId,))
|
data = database.execute("SELECT title, season, episode FROM table_episodes WHERE sonarrEpisodeId=?",
|
||||||
|
(sonarrEpisodeId,), only_one=True)
|
||||||
|
|
||||||
return data['title'], data['season'], data['episode']
|
return data['title'], data['season'], data['episode']
|
||||||
|
|
||||||
|
|
||||||
def get_movies_name(radarrId):
|
def get_movies_name(radarrId):
|
||||||
data = database.execute("SELECT title FROM table_movies WHERE radarrId=?", (radarrId,))
|
data = database.execute("SELECT title FROM table_movies WHERE radarrId=?", (radarrId,), only_one=True)
|
||||||
return data['title']
|
return data['title']
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -258,8 +258,8 @@
|
||||||
if missing_languages is not None:
|
if missing_languages is not None:
|
||||||
from get_subtitle import search_active
|
from get_subtitle import search_active
|
||||||
for language in missing_languages:
|
for language in missing_languages:
|
||||||
if episode['failed_attempts'] is not None and settings.general.getboolean('adaptive_searching') and language in episode['failed_attempts']:
|
if episode['failedAttempts'] is not None and settings.general.getboolean('adaptive_searching') and language in episode['failedAttempts']:
|
||||||
for lang in ast.literal_eval(episode['failed_attempts']):
|
for lang in ast.literal_eval(episode['failedAttempts']):
|
||||||
if language in lang:
|
if language in lang:
|
||||||
if search_active(lang[1]):
|
if search_active(lang[1]):
|
||||||
%>
|
%>
|
||||||
|
|
Loading…
Reference in a new issue