This commit is contained in:
Louis Vézina 2019-10-27 20:45:15 -04:00
parent 277198685e
commit 4a911f43e5
18 changed files with 173 additions and 162 deletions

View File

@ -10,25 +10,22 @@ database = Sqlite3Worker(os.path.join(args.config_dir, 'db', 'bazarr.db'), max_q
class SqliteDictConverter:
def __init__(self):
pass
self.keys_insert = tuple()
self.keys_update = tuple()
self.values = tuple()
self.question_marks = tuple()
def convert(self, values_dict):
self.keys = str()
self.values = str()
self.items = str()
if type(values_dict) is dict:
for key, value in values_dict.items():
self.keys += key + ", "
if type(value) is not string_types:
value = str(value)
else:
value = "\"" + value + "\""
self.values += value + ", "
self.items += key + "=" + value + ", "
self.keys = self.keys.rstrip(", ")
self.values = self.values.rstrip(", ")
self.items = self.items.rstrip(", ")
temp_keys = list()
temp_values = list()
for item in values_dict.items():
temp_keys.append(item[0])
temp_values.append(item[1])
self.keys_insert = ','.join(temp_keys)
self.keys_update = ','.join([k + '=?' for k in temp_keys])
self.values = tuple(temp_values)
self.question_marks = ','.join(list('?'*len(values_dict)))
return self
else:
pass

View File

@ -26,7 +26,7 @@ def sync_episodes():
# Get current episodes id in DB
current_episodes_db = database.execute("SELECT sonarrEpisodeId, path, sonarrSeriesId FROM table_episodes")
current_episodes_db_list = [x.sonarr_episode_id for x in current_episodes_db]
current_episodes_db_list = [x['sonarrEpisodeId'] for x in current_episodes_db]
current_episodes_sonarr = []
episodes_to_update = []
@ -36,11 +36,11 @@ def sync_episodes():
# Get sonarrId for each series from database
seriesIdList = database.execute("SELECT sonarrSeriesId, title FROM table_shows")
seriesIdListLength = seriesIdList.count()
seriesIdListLength = len(seriesIdList)
for i, seriesId in enumerate(seriesIdList, 1):
notifications.write(msg='Getting episodes data from Sonarr...', queue='get_episodes', item=i, length=seriesIdListLength)
# Get episodes data for a series from Sonarr
url_sonarr_api_episode = url_sonarr + "/api/episode?seriesId=" + str(seriesId['sonarr_series_id']) + "&apikey=" + apikey_sonarr
url_sonarr_api_episode = url_sonarr + "/api/episode?seriesId=" + str(seriesId['sonarrSeriesId']) + "&apikey=" + apikey_sonarr
try:
r = requests.get(url_sonarr_api_episode, timeout=60, verify=False)
r.raise_for_status()
@ -136,18 +136,19 @@ def sync_episodes():
for updated_episode in episodes_to_update_list:
query = dict_converter.convert(updated_episode)
database.execute("UPDATE table_episodes SET ? WHERE sonarrEpisodeId=?",
(query.items, updated_episode['sonarr_episode_id']))
altered_episodes.append([updated_episode['sonarr_episode_id'],
database.execute('''UPDATE table_shows SET ''' + query.keys_update + ''' WHERE sonarrSeriesId = ?''',
query.values + (updated_episode['sonarrSeriesId'],))
altered_episodes.append([updated_episode['sonarrEpisodeId'],
updated_episode['path'],
updated_episode['sonarr_series_id']])
updated_episode['sonarrSeriesId']])
# Insert new episodes in DB
for added_episode in episodes_to_add:
query = dict_converter.convert(added_episode)
database.execute("INSERT OR IGNORE INTO table_episodes(?) VALUES(?)",
(query.keys, query.values))
altered_episodes.append([added_episode['sonarr_episode_id'],
database.execute(
'''INSERT OR IGNORE INTO table_episodes(''' + query.keys_insert + ''') VALUES(''' + query.question_marks +
''')''', query.values)
altered_episodes.append([added_episode['sonarrEpisodeId'],
added_episode['path']])
# Remove old episodes from DB

View File

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

View File

@ -133,13 +133,15 @@ def update_series():
for updated_series in series_to_update_list:
query = dict_converter.convert(updated_series)
database.execute("""UPDATE table_shows SET {0} WHERE sonarrSeriesId=?""".format(query.items),
(updated_series['sonarrSeriesId'],))
database.execute('''UPDATE table_shows SET ''' + query.keys_update + ''' WHERE sonarrSeriesId = ?''',
query.values + (updated_series['sonarrSeriesId'],))
# Insert new series in DB
for added_series in series_to_add:
query = dict_converter.convert(added_series)
database.execute("""INSERT OR IGNORE INTO table_shows({0}) VALUES({1})""".format(query.keys, query.values))
database.execute(
'''INSERT OR IGNORE INTO table_shows(''' + query.keys_insert + ''') VALUES(''' +
query.question_marks + ''')''', query.values)
list_missing_subtitles(no=added_series['sonarrSeriesId'])
# Remove old series from DB

View File

@ -574,7 +574,7 @@ def series_download_subtitles(no):
notifications.write(msg='Searching for Series Subtitles...', queue='get_subtitle', item=i,
length=count_episodes_details)
result = download_subtitle(path_replace(episode['path']),
str(alpha3_from_alpha2(language.split(':'))),
str(alpha3_from_alpha2(language.split(':')[0])),
series_details['hearing_impaired'],
"True" if len(language.split(':')) > 1 else "False",
providers_list,
@ -589,7 +589,7 @@ def series_download_subtitles(no):
language_code = result[2] + ":forced" if forced else result[2]
provider = result[3]
score = result[4]
store_subtitles(path_replace(episode.path))
store_subtitles(path_replace(episode['path']))
history_log(1, no, episode['sonarrEpisodeId'], message, path, language_code, provider, score)
send_notifications(no, episode['sonarrEpisodeId'], message)
else:
@ -661,8 +661,11 @@ def movies_download_subtitles(no):
providers_list = get_providers()
providers_auth = get_providers_auth()
count_movie = len(ast.literal_eval(movie['missing_subtitles']))
if ast.literal_eval(movie['missing_subtitles']):
count_movie = len(ast.literal_eval(movie['missing_subtitles']))
else:
count_movie = 0
for i, language in enumerate(ast.literal_eval(movie['missing_subtitles']), 1):
if providers_list:
@ -712,7 +715,7 @@ def wanted_download_subtitles(path, l, count_episodes):
providers_auth = get_providers_auth()
for episode in episodes_details:
attempt = episode['failed_attempts']
attempt = episode['failedAttempts']
if type(attempt) == unicode:
attempt = ast.literal_eval(attempt)
for language in ast.literal_eval(episode['missing_subtitles']):
@ -725,7 +728,7 @@ def wanted_download_subtitles(path, l, count_episodes):
attempt.append([language, time.time()])
database.execute("UPDATE table_episodes SET failedAttempts=? WHERE sonarrEpisodeId=?",
(unicode(attempt), episode['sonarrEpisdoeId']))
(unicode(attempt), episode['sonarrEpisodeId']))
for i in range(len(attempt)):
if attempt[i][0] == language:
@ -750,7 +753,7 @@ def wanted_download_subtitles(path, l, count_episodes):
score = result[4]
store_subtitles(path_replace(episode['path']))
history_log(1, episode['sonarrSeriesId'], episode['sonarrEpisodeId'], message, path, language_code, provider, score)
send_notifications(episode['sonarrSeriesId'], episode['sonarrSeriesId'], message)
send_notifications(episode['sonarrSeriesId'], episode['sonarrEpisodeId'], message)
else:
logging.debug(
'BAZARR Search is not active for episode ' + episode['path'] + ' Language: ' + attempt[i][0])
@ -765,7 +768,7 @@ def wanted_download_subtitles_movie(path, l, count_movies):
providers_auth = get_providers_auth()
for movie in movies_details:
attempt = movie['failed_attempts']
attempt = movie['failedAttempts']
if type(attempt) == unicode:
attempt = ast.literal_eval(attempt)
for language in ast.literal_eval(movie['missing_subtitles']):

View File

@ -575,7 +575,7 @@ def serieseditor():
authorize()
# Get missing count
missing_count = len(database.execute("SELECT COUNT(*) FROM table_shows"))
missing_count = database.execute("SELECT COUNT(*) as count FROM table_shows", only_one=True)['count']
# Get series list
data = database.execute("SELECT tvdbId, title, path, languages, hearing_impaired, sonarrSeriesId, poster, "
@ -751,7 +751,7 @@ def movies():
def movieseditor():
authorize()
missing_count = len(database.execute("SELECT COUNT(*) FROM table_movies"))
missing_count = database.execute("SELECT COUNT(*) as count FROM table_movies", only_one=True)['count']
data = database.execute("SELECT tmdbId, title, path, languages, hearing_impaired, radarrId, poster, "
"audio_language, forced FROM table_movies ORDER BY sortTitle ASC")
@ -935,13 +935,14 @@ def historyseries():
thisyear.append(datetime.fromtimestamp(stat['timestamp']).date())
stats = [len(today), len(thisweek), len(thisyear), total]
data = database.execute("SELECT table_history.action, table_shows.title, "
"table_episodes.season || 'x' || table_episodes.episode, table_episodes.title, "
data = database.execute("SELECT table_history.action, table_shows.title as seriesTitle, "
"table_episodes.season || 'x' || table_episodes.episode as episode_number, "
"table_episodes.title as episodeTitle, "
"table_history.timestamp, table_history.description, table_history.sonarrSeriesId, "
"table_episodes.path, table_shows.languages, table_history.language, table_history.score, "
"table_shows.forced FROM table_history LEFT JOIN table_shows on "
"table_shows.sonarrSeriesId = table_history.sonarrSeriesId LEFT JOIN table_episodes on "
"table_episodes.sonarrEpisodeId = table_history.sonarrEpisodeId WHERE table_history.title "
"table_episodes.sonarrEpisodeId = table_history.sonarrEpisodeId WHERE table_episodes.title "
"is not NULL ORDER BY timestamp DESC LIMIT ? OFFSET ?", (page_size, offset))
upgradable_episodes_not_perfect = []
@ -960,7 +961,7 @@ def historyseries():
else:
series_monitored_only_query_string = ''
upgradable_episodes = database.execute("SELECT video_path, MAX(timestamp), score FROM table_history "
upgradable_episodes = database.execute("SELECT video_path, MAX(timestamp) as timestamp, score FROM table_history "
"INNER JOIN table_episodes on table_episodes.sonarrEpisodeId = "
"table_history.sonarrEpisodeId WHERE action IN (" +
','.join(map(str, query_actions)) + ") AND timestamp > ? AND "
@ -1037,7 +1038,7 @@ def historymovies():
else:
query_actions = [1, 3]
upgradable_movies = database.execute("SELECT video_path, MAX(timestamp), score FROM table_history_movie "
upgradable_movies = database.execute("SELECT video_path, MAX(timestamp) as timestamp, score FROM table_history_movie "
"INNER JOIN table_movies on table_movies.radarrId="
"table_history_movie.radarrId WHERE action IN (" +
','.join(map(str, query_actions)) +
@ -1077,8 +1078,8 @@ def wantedseries():
else:
monitored_only_query_string = ''
missing_count = len(database.execute("SELECT COUNT(*) FROM table_episodes WHERE missing_subtitles != '[]'" +
monitored_only_query_string))
missing_count = database.execute("SELECT COUNT(*) as count FROM table_episodes WHERE missing_subtitles != '[]'" +
monitored_only_query_string, only_one=True)['count']
page = request.GET.page
if page == "":
page = "1"
@ -1086,8 +1087,9 @@ def wantedseries():
offset = (int(page) - 1) * page_size
max_page = int(math.ceil(missing_count / (page_size + 0.0)))
data = database.execute("SELECT table_shows.title, table_episodes.season || 'x' || table_episodes.episode, "
"table_episodes.title, table_episodes.missing_subtitles, table_episodes.sonarrSeriesId, "
data = database.execute("SELECT table_shows.title as seriesTitle, "
"table_episodes.season || 'x' || table_episodes.episode as episode_number, "
"table_episodes.title as episodeTitle, table_episodes.missing_subtitles, table_episodes.sonarrSeriesId, "
"table_episodes.path, table_shows.hearing_impaired, table_episodes.sonarrEpisodeId, "
"table_episodes.scene_name, table_episodes.failedAttempts FROM table_episodes "
"INNER JOIN table_shows on table_shows.sonarrSeriesId = table_episodes.sonarrSeriesId "
@ -1110,8 +1112,8 @@ def wantedmovies():
else:
monitored_only_query_string = ''
missing_count = len(database.execute("SELECT COUNT(*) FROM table_movies WHERE missing_subtitles != '[]'" +
monitored_only_query_string))
missing_count = database.execute("SELECT COUNT(*) as count FROM table_movies WHERE missing_subtitles != '[]'" +
monitored_only_query_string, only_one=True)['count']
page = request.GET.page
if page == "":
page = "1"

View File

@ -61,6 +61,7 @@ def get_episode_name(sonarrEpisodeId):
def get_movies_name(radarrId):
data = database.execute("SELECT title FROM table_movies WHERE radarrId=?", (radarrId,), only_one=True)
return data['title']

View File

@ -58,58 +58,58 @@
%for row in rows:
<tr class="selectable">
<td class="collapsing">
%if row.action == 0:
%if row['action'] == 0:
<div class="ui inverted basic compact icon" data-tooltip="Subtitle file has been erased." data-inverted="" data-position="top left">
<i class="ui trash icon"></i>
</div>
%elif row.action == 1:
%elif row['action'] == 1:
<div class="ui inverted basic compact icon" data-tooltip="Subtitle file has been downloaded." data-inverted="" data-position="top left">
<i class="ui download icon"></i>
</div>
%elif row.action == 2:
%elif row['action'] == 2:
<div class="ui inverted basic compact icon" data-tooltip="Subtitle file has been manually downloaded." data-inverted="" data-position="top left">
<i class="ui user icon"></i>
</div>
%elif row.action == 3:
%elif row['action'] == 3:
<div class="ui inverted basic compact icon" data-tooltip="Subtitle file has been upgraded." data-inverted="" data-position="top left">
<i class="ui recycle icon"></i>
</div>
%elif row[0] == 4:
%elif row['action'] == 4:
<div class="ui inverted basic compact icon" data-tooltip="Subtitle file has been manually uploaded." data-inverted="" data-position="top left">
<i class="ui cloud upload icon"></i>
</div>
%end
</td>
<td>
<a href="{{base_url}}movie/{{row.radarr_id.radarr_id}}">{{row.title}}</a>
<a href="{{base_url}}movie/{{row['radarrId']}}">{{row['title']}}</a>
</td>
<td class="collapsing">
<div class="ui inverted" data-tooltip="{{time.strftime('%Y/%m/%d %H:%M', time.localtime(row.timestamp))}}" data-inverted="" data-position="top left">
{{pretty.date(int(row.timestamp))}}
<div class="ui inverted" data-tooltip="{{time.strftime('%Y/%m/%d %H:%M', time.localtime(row['timestamp']))}}" data-inverted="" data-position="top left">
{{pretty.date(int(row['timestamp']))}}
</div>
</td>
<td>
% upgradable_criteria = (row.timestamp, row.video_path, row.score)
% upgradable_criteria = (row['timestamp'], row['video_path'], row['score'])
% if upgradable_criteria in upgradable_movies:
% if row.languages != "None":
% desired_languages = ast.literal_eval(str(row.languages))
% if row.forced == "True":
% if row['languages'] != "None":
% desired_languages = ast.literal_eval(str(row['languages']))
% if row['forced'] == "True":
% forced_languages = [l + ":forced" for l in desired_languages]
% elif row.forced == "Both":
% elif row['forced'] == "Both":
% forced_languages = [l + ":forced" for l in desired_languages] + desired_languages
% else:
% forced_languages = desired_languages
% end
% if row.languages and row.language and row.language in forced_languages:
% if row['languages'] and row['language'] and row['language'] in forced_languages:
<div class="ui inverted basic compact icon" data-tooltip="This Subtitle file is eligible for an upgrade." data-inverted="" data-position="top left">
<i class="ui green recycle icon upgrade"></i>{{row.description}}
<i class="ui green recycle icon upgrade"></i>{{row['description']}}
</div>
% else:
{{row.description}}
{{row['description']}}
% end
% end
% else:
{{row.description}}
{{row['description']}}
% end
</td>
</tr>

View File

@ -60,71 +60,71 @@
%for row in rows:
<tr class="selectable">
<td class="collapsing">
%if row.action == 0:
%if row['action'] == 0:
<div class="ui inverted basic compact icon" data-tooltip="Subtitle file has been erased." data-inverted="" data-position="top left">
<i class="ui trash icon"></i>
</div>
%elif row.action == 1:
%elif row['action'] == 1:
<div class="ui inverted basic compact icon" data-tooltip="Subtitle file has been downloaded." data-inverted="" data-position="top left">
<i class="ui download icon"></i>
</div>
%elif row.action == 2:
%elif row['action'] == 2:
<div class="ui inverted basic compact icon" data-tooltip="Subtitle file has been manually downloaded." data-inverted="" data-position="top left">
<i class="ui user icon"></i>
</div>
%elif row.action == 3:
%elif row['action'] == 3:
<div class="ui inverted basic compact icon" data-tooltip="Subtitle file has been upgraded." data-inverted="" data-position="top left">
<i class="ui recycle icon"></i>
</div>
%elif row.action == 4:
%elif row['action'] == 4:
<div class="ui inverted basic compact icon" data-tooltip="Subtitle file has been manually uploaded." data-inverted="" data-position="top left">
<i class="ui cloud upload icon"></i>
</div>
%end
</td>
<td>
<a href="{{base_url}}episodes/{{row.sonarr_series_id.sonarr_series_id}}">{{row.seriesTitle}}</a>
<a href="{{base_url}}episodes/{{row['sonarrSeriesId']}}">{{row['seriesTitle']}}</a>
</td>
<td class="collapsing">
%if row.episode_number is not None:
% episode = row.episode_number.split('x')
%if row['episode_number'] is not None:
% episode = row['episode_number'].split('x')
{{episode[0] + 'x' + episode[1].zfill(2)}}
%end
</td>
<td>
%if row.episodeTitle is not None:
{{row.episodeTitle}}
%if row['episodeTitle'] is not None:
{{row['episodeTitle']}}
%else:
<em>Deleted episode</em>
%end
</td>
<td class="collapsing">
<div class="ui inverted" data-tooltip="{{time.strftime('%Y/%m/%d %H:%M', time.localtime(row.timestamp))}}" data-inverted="" data-position="top left">
{{pretty.date(int(row.timestamp))}}
<div class="ui inverted" data-tooltip="{{time.strftime('%Y/%m/%d %H:%M', time.localtime(row['timestamp']))}}" data-inverted="" data-position="top left">
{{pretty.date(int(row['timestamp']))}}
</div>
</td>
<td>
% upgradable_criteria = (row.timestamp, row.path, row.score)
% upgradable_criteria = (row['timestamp'], row['path'], row['score'])
% if upgradable_criteria in upgradable_episodes:
% if row.languages != "None":
% desired_languages = ast.literal_eval(str(row.languages))
% if row.forced == "True":
% if row['languages'] != "None":
% desired_languages = ast.literal_eval(str(row['languages']))
% if row['forced'] == "True":
% forced_languages = [l + ":forced" for l in desired_languages]
% elif row.forced == "Both":
% elif row['forced'] == "Both":
% forced_languages = [l + ":forced" for l in desired_languages] + desired_languages
% else:
% forced_languages = desired_languages
% end
% if row.language in forced_languages:
% if row['language'] in forced_languages:
<div class="ui inverted basic compact icon" data-tooltip="This Subtitle file is eligible for an upgrade." data-inverted="" data-position="top left">
<i class="ui green recycle icon upgrade"></i>{{row.description}}
<i class="ui green recycle icon upgrade"></i>{{row['description']}}
</div>
% else:
{{row.description}}
{{row['description']}}
% end
% end
% else:
{{row.description}}
{{row['description']}}
% end
</td>
</tr>

View File

@ -74,8 +74,8 @@
% monitored_only_query_string_radarr = ""
%end
% wanted_series = len(database.execute("SELECT COUNT(*) FROM table_episodes WHERE missing_subtitles != '[]'" + monitored_only_query_string_sonarr))
% wanted_movies = len(database.execute("SELECT COUNT(*) FROM table_movies WHERE missing_subtitles != '[]'" + monitored_only_query_string_radarr))
% wanted_series = database.execute("SELECT COUNT(*) as count FROM table_episodes WHERE missing_subtitles != '[]'" + monitored_only_query_string_sonarr, only_one=True)['count']
% wanted_movies = database.execute("SELECT COUNT(*) as count FROM table_movies WHERE missing_subtitles != '[]'" + monitored_only_query_string_radarr, only_one=True)['count']
% from get_providers import list_throttled_providers
% throttled_providers_count = len(eval(str(settings.general.throtteled_providers)))
<div id="divmenu" class="ui container">

View File

@ -232,8 +232,8 @@
forced_bool = False
end
if details['failed_attempts'] is not None and settings.general.getboolean('adaptive_searching') and missing_subs_language in details['failed_attempts']:
for lang in ast.literal_eval(details['failed_attempts']):
if details['failedAttempts'] is not None and settings.general.getboolean('adaptive_searching') and missing_subs_language in details['failedAttempts']:
for lang in ast.literal_eval(details['failedAttempts']):
if missing_subs_language in lang:
if search_active(lang[1]):
%>

View File

@ -74,22 +74,22 @@
<tr class="selectable">
<td class="collapsing">
<div class="ui checkbox">
<input id='{{row.radarr_id}}' type="checkbox" class="selected">
<input id='{{row['radarrId']}}' type="checkbox" class="selected">
<label></label>
</div>
</td>
<td><a href="{{base_url}}movie/{{row.radarr_id}}">{{row.title}}</a></td>
<td>{{row.audio_language}}</td>
<td><a href="{{base_url}}movie/{{row['radarrId']}}">{{row['title']}}</a></td>
<td>{{row['audio_language']}}</td>
<td>
%subs_languages = ast.literal_eval(str(row.languages))
%subs_languages = ast.literal_eval(str(row['languages']))
%if subs_languages is not None:
%for subs_language in subs_languages:
<div class="ui tiny label">{{subs_language}}</div>
%end
%end
</td>
<td>{{!"" if row.hearing_impaired == None else row.hearing_impaired}}</td>
<td>{{!"" if row.forced is None else row.forced}}</td>
<td>{{!"" if row['hearing_impaired'] == None else row['hearing_impaired']}}</td>
<td>{{!"" if row['forced'] is None else row['forced']}}</td>
</tr>
%end
</tbody>
@ -105,7 +105,7 @@
<option value="">No Change</option>
<option value="None">None</option>
%for language in languages:
<option value="{{language.code2}}">{{language.name}}</option>
<option value="{{language['code2']}}">{{language['name']}}</option>
%end
</select>
</div>

View File

@ -74,22 +74,22 @@
<tr class="selectable">
<td class="collapsing">
<div class="ui checkbox">
<input id='{{row.sonarr_series_id}}' type="checkbox" class="selected">
<input id='{{row['sonarrSeriesId']}}' type="checkbox" class="selected">
<label></label>
</div>
</td>
<td><a href="{{base_url}}episodes/{{row.sonarr_series_id}}">{{row.title}}</a></td>
<td>{{row.audio_language}}</td>
<td><a href="{{base_url}}episodes/{{row['sonarrSeriesId']}}">{{row['title']}}</a></td>
<td>{{row['audio_language']}}</td>
<td>
%subs_languages = ast.literal_eval(str(row.languages))
%subs_languages = ast.literal_eval(str(row['languages']))
%if subs_languages is not None:
%for subs_language in subs_languages:
<div class="ui tiny label">{{subs_language}}</div>
%end
%end
</td>
<td>{{!"" if row.hearing_impaired is None else row.hearing_impaired}}</td>
<td>{{!"" if row.forced is None else row.forced}}</td>
<td>{{!"" if row['hearing_impaired'] is None else row['hearing_impaired']}}</td>
<td>{{!"" if row['forced'] is None else row['forced']}}</td>
</tr>
%end
</tbody>
@ -105,7 +105,7 @@
<option value="">No Change</option>
<option value="None">None</option>
%for language in languages:
<option value="{{language.code2}}">{{language.name}}</option>
<option value="{{language['code2']}}">{{language['name']}}</option>
%end
</select>
</div>

View File

@ -10,19 +10,19 @@
%for notifier in settings_notifier:
<div class="middle aligned row">
<div class="right aligned four wide column">
<label>{{notifier.name}}</label>
<label>{{notifier['name']}}</label>
</div>
<div class="one wide column">
<div id="settings_notifier_{{notifier.name}}_enabled" class="notifier_enabled ui toggle checkbox" data-notifier-url-div="settings_notifier_{{notifier.name}}_url_div" data-enabled={{notifier.enabled}}>
<input name="settings_notifier_{{notifier.name}}_enabled" type="checkbox">
<div id="settings_notifier_{{notifier['name']}}_enabled" class="notifier_enabled ui toggle checkbox" data-notifier-url-div="settings_notifier_{{notifier['name']}}_url_div" data-enabled={{notifier['enabled']}}>
<input name="settings_notifier_{{notifier['name']}}_enabled" type="checkbox">
<label></label>
</div>
</div>
<div class="eight wide column">
<div class='field'>
<div id="settings_notifier_{{notifier.name}}_url_div" class="ui fluid input">
<input name="settings_notifier_{{notifier.name}}_url" type="text" value="{{notifier.url if notifier.url != None else ''}}">
<div class="test_notification ui blue button" data-notification="{{notifier.url}}">Test Notification</div>
<div id="settings_notifier_{{notifier['name']}}_url_div" class="ui fluid input">
<input name="settings_notifier_{{notifier['name']}}_url" type="text" value="{{notifier['url'] if notifier['url'] != None else ''}}">
<div class="test_notification ui blue button" data-notification="{{notifier['url']}}">Test Notification</div>
</div>
</div>
</div>

View File

@ -414,9 +414,9 @@
<option value="">Languages</option>
%enabled_languages = []
%for language in settings_languages:
<option value="{{language.code2}}">{{language.name}}</option>
%if language.enabled == True:
% enabled_languages.append(str(language.code2))
<option value="{{language['code2']}}">{{language['name']}}</option>
%if language['enabled'] == True:
% enabled_languages.append(str(language['code2']))
%end
%end
</select>

View File

@ -60,8 +60,8 @@
% episodes_missing_subtitles_clause_movie = ""
%end
% wanted_series = len(database.execute("SELECT COUNT(*) FROM table_episodes WHERE missing_subtitles != '[]'" + episodes_missing_subtitles_clause))
% wanted_movies = len(database.execute("SELECT COUNT(*) FROM table_movies WHERE missing_subtitles != '[]'" + episodes_missing_subtitles_clause_movie))
% wanted_series = database.execute("SELECT COUNT(*) as count FROM table_episodes WHERE missing_subtitles != '[]'" + episodes_missing_subtitles_clause, only_one=True)['count']
% wanted_movies = database.execute("SELECT COUNT(*) as count FROM table_movies WHERE missing_subtitles != '[]'" + episodes_missing_subtitles_clause_movie, only_one=True)['count']
<div id='loader' class="ui page dimmer">
<div id="loader_text" class="ui indeterminate text loader">Loading...</div>

View File

@ -59,10 +59,10 @@
%end
%for row in rows:
<tr class="selectable">
<td><a href="{{base_url}}movie/{{row.radarr_id}}">{{row.title}}</a></td>
<td><a href="{{base_url}}movie/{{row['radarrId']}}">{{row['title']}}</a></td>
<td>
<%
missing_languages = ast.literal_eval(row.missing_subtitles)
missing_languages = ast.literal_eval(row['missing_subtitles'])
if missing_languages is not None:
from get_subtitle import search_active
from config import settings
@ -72,18 +72,18 @@
else:
forced = False
end
if row.failed_attempts is not None and settings.general.getboolean('adaptive_searching') and language in row.failed_attempts:
for lang in ast.literal_eval(row.failed_attempts):
if row['failedAttempts'] is not None and settings.general.getboolean('adaptive_searching') and language in row['failedAttempts']:
for lang in ast.literal_eval(row['failedAttempts']):
if language in lang:
active = search_active(lang[1])
if active:
%>
<a data-moviePath="{{row.path}}" data-sceneName="{{row.scene_name}}" data-language="{{alpha3_from_alpha2(str(language.split(':')[0]))}}" data-hi="{{row.hearing_impaired}}" data-forced="{{forced}}" data-radarrId={{row.radarr_id}} data-title="{{row.title.replace("'", "\'")}}" class="get_subtitle ui tiny label">
<a data-moviePath="{{row['path']}}" data-sceneName="{{row['sceneName']}}" data-language="{{alpha3_from_alpha2(str(language.split(':')[0]))}}" data-hi="{{row['hearing_impaired']}}" data-forced="{{forced}}" data-radarrId={{row['radarrId']}} data-title="{{row['title'].replace("'", "\'")}}" class="get_subtitle ui tiny label">
{{language}}
<i style="margin-left:3px; margin-right:0" class="search icon"></i>
</a>
%else:
<a data-tooltip="Automatic Searching Delayed (Adaptive Search)" data-position="top right" data-inverted="" data-moviePath="{{row.path}}" data-sceneName="{{row.scene_name}}" data-language="{{alpha3_from_alpha2(str(language.split(':')[0]))}}" data-hi="{{row.hearing_impaired}}" data-forced="{{forced}}" data-radarrId={{row.radarr_id}} data-title="{{row.title.replace("'", "\'")}}" class="get_subtitle ui tiny label">
<a data-tooltip="Automatic Searching Delayed (Adaptive Search)" data-position="top right" data-inverted="" data-moviePath="{{row['path']}}" data-sceneName="{{row['sceneName']}}" data-language="{{alpha3_from_alpha2(str(language.split(':')[0]))}}" data-hi="{{row['hearing_impaired']}}" data-forced="{{forced}}" data-radarrId={{row['radarrId']}} data-title="{{row['title'].replace("'", "\'")}}" class="get_subtitle ui tiny label">
{{language}}
<i style="margin-left:3px; margin-right:0" class="search red icon"></i>
</a>
@ -91,7 +91,7 @@
%end
%end
%else:
<a data-moviePath="{{row.path}}" data-sceneName="{{row.scene_name}}" data-language="{{alpha3_from_alpha2(str(language.split(':')[0]))}}" data-hi="{{row.hearing_impaired}}" data-forced="{{forced}}" data-radarrId="{{row.radarr_id}}" data-title="{{row.title.replace("'", "\'")}}" class="get_subtitle ui tiny label">
<a data-moviePath="{{row['path']}}" data-sceneName="{{row['sceneName']}}" data-language="{{alpha3_from_alpha2(str(language.split(':')[0]))}}" data-hi="{{row['hearing_impaired']}}" data-forced="{{forced}}" data-radarrId="{{row['radarrId']}}" data-title="{{row['title'].replace("'", "\'")}}" class="get_subtitle ui tiny label">
{{language}}
<i style="margin-left:3px; margin-right:0" class="search icon"></i>
</a>

View File

@ -54,22 +54,22 @@
<tbody>
%import time
%import pretty
%if rows.count() == 0:
%if len(rows) == 0:
<tr>
<td colspan="4">No Missing Subtitles.</td>
</tr>
%end
%for row in rows:
<tr class="selectable">
<td><a href="{{base_url}}episodes/{{row.sonarr_series_id.sonarr_series_id}}">{{row.seriesTitle}}</a></td>
<td><a href="{{base_url}}episodes/{{row['sonarrSeriesId']}}">{{row['seriesTitle']}}</a></td>
<td class="collapsing">
<%episode = str(row.episode_number).split('x')%>
<%episode = str(row['episode_number']).split('x')%>
{{episode[0] + 'x' + episode[1].zfill(2)}}
</td>
<td>{{row.episodeTitle}}</td>
<td>{{row['episodeTitle']}}</td>
<td>
<%
missing_languages = ast.literal_eval(row.missing_subtitles)
missing_languages = ast.literal_eval(row['missing_subtitles'])
if missing_languages is not None:
from get_subtitle import search_active
from config import settings
@ -79,18 +79,18 @@
else:
forced = False
end
if row.failed_attempts is not None and settings.general.getboolean('adaptive_searching') and language in row.failed_attempts:
for lang in ast.literal_eval(row.failed_attempts):
if row['failedAttempts'] is not None and settings.general.getboolean('adaptive_searching') and language in row['failedAttempts']:
for lang in ast.literal_eval(row['failedAttempts']):
if language in lang:
active = search_active(lang[1])
if active:
%>
<a data-episodePath="{{row.path}}" data-sceneName="{{row.scene_name}}" data-language="{{alpha3_from_alpha2(str(language.split(':')[0]))}}" data-hi="{{row.hearing_impaired}}" data-forced="{{forced}}" data-sonarrSeriesId={{row.sonarr_series_id.sonarr_series_id}} data-sonarrEpisodeId={{row.sonarr_episode_id}} data-title="{{row.seriesTitle.replace("'", "\'")}}" class="get_subtitle ui tiny label">
<a data-episodePath="{{row['path']}}" data-sceneName="{{row['scene_name']}}" data-language="{{alpha3_from_alpha2(str(language.split(':')[0]))}}" data-hi="{{row['hearing_impaired']}}" data-forced="{{forced}}" data-sonarrSeriesId={{row['sonarrSeriesId']}} data-sonarrEpisodeId={{row['sonarrEpisodeId']}} data-title="{{row['seriesTitle'].replace("'", "\'")}}" class="get_subtitle ui tiny label">
{{language}}
<i style="margin-left:3px; margin-right:0" class="search icon"></i>
</a>
%else:
<a data-tooltip="Automatic Searching Delayed (Adaptive Search)" data-position="top right" data-inverted="" data-episodePath="{{row.path}}" data-sceneName="{{row.scene_name}}" data-language="{{alpha3_from_alpha2(str(language.split(':')[0]))}}" data-hi="{{row.hearing_impaired}}" data-forced="{{forced}}" data-sonarrSeriesId={{row.sonarr_series_id.sonarr_series_id}} data-sonarrEpisodeId={{row.sonarr_episode_id}} data-title="{{row.seriesTitle.replace("'", "\'")}}" class="get_subtitle ui tiny label">
<a data-tooltip="Automatic Searching Delayed (Adaptive Search)" data-position="top right" data-inverted="" data-episodePath="{{row['path']}}" data-sceneName="{{row['scene_name']}}" data-language="{{alpha3_from_alpha2(str(language.split(':')[0]))}}" data-hi="{{row['hearing_impaired']}}" data-forced="{{forced}}" data-sonarrSeriesId={{row['sonarrSeriesId']}} data-sonarrEpisodeId={{row['sonarrEpisodeId']}} data-title="{{row['seriesTitle'].replace("'", "\'")}}" class="get_subtitle ui tiny label">
{{language}}
<i style="margin-left:3px; margin-right:0" class="search red icon"></i>
</a>
@ -98,7 +98,7 @@
%end
%end
%else:
<a data-episodePath="{{row.path}}" data-sceneName="{{row.scene_name}}" data-language="{{alpha3_from_alpha2(str(language.split(':')[0]))}}" data-hi="{{row.hearing_impaired}}" data-forced="{{forced}}" data-sonarrSeriesId={{row.sonarr_series_id.sonarr_series_id}} data-sonarrEpisodeId={{row.sonarr_episode_id}} data-title="{{row.seriesTitle.replace("'", "\'")}}" class="get_subtitle ui tiny label">
<a data-episodePath="{{row['path']}}" data-sceneName="{{row['scene_name']}}" data-language="{{alpha3_from_alpha2(str(language.split(':')[0]))}}" data-hi="{{row['hearing_impaired']}}" data-forced="{{forced}}" data-sonarrSeriesId={{row['sonarrSeriesId']}} data-sonarrEpisodeId={{row['sonarrEpisodeId']}} data-title="{{row['seriesTitle'].replace("'", "\'")}}" class="get_subtitle ui tiny label">
{{language}}
<i style="margin-left:3px; margin-right:0" class="search icon"></i>
</a>