diff --git a/bazarr/api.py b/bazarr/api.py index a6011524d..8686c9c8c 100644 --- a/bazarr/api.py +++ b/bazarr/api.py @@ -45,7 +45,7 @@ class Series(Resource): row_count = database.execute("SELECT COUNT(*) as count FROM table_shows", only_one=True)['count'] if seriesId: result = database.execute("SELECT * FROM table_shows WHERE sonarrSeriesId=? ORDER BY sortTitle ASC LIMIT ? " - "OFFSET ?", (length, start), (seriesId,)) + "OFFSET ?", (seriesId, length, start)) else: result = database.execute("SELECT * FROM table_shows ORDER BY sortTitle ASC LIMIT ? OFFSET ?", (length, start)) for item in result: diff --git a/bazarr/main.py b/bazarr/main.py index 4398d1c6c..9b59f39ec 100644 --- a/bazarr/main.py +++ b/bazarr/main.py @@ -508,9 +508,9 @@ def download_log(): @login_required def image_proxy(url): apikey = settings.sonarr.apikey - url_image = (url_sonarr_short() + '/' + url + '?apikey=' + apikey).replace('poster-250', 'poster-500') + url_image = (url_sonarr() + '/' + url + '?apikey=' + apikey).replace('poster-250', 'poster-500') try: - req = requests.get(url_sonarr() + '/api' + url_image.split(url_sonarr())[1], stream=True, timeout=15, verify=False) + req = requests.get(url_image, stream=True, timeout=15, verify=False) except: return None else: @@ -547,56 +547,7 @@ def redirect_root(): @app.route('/series/') @login_required def series(): - series_count = database.execute("SELECT COUNT(*) as count FROM table_shows", only_one=True)['count'] - page = request.data - if not page: - page = "1" - page_size = int(settings.general.page_size) - offset = (int(page) - 1) * page_size - max_page = int(math.ceil(series_count / (page_size + 0.0))) - - # Get list of series - data = database.execute("SELECT tvdbId, title, path, languages, hearing_impaired, sonarrSeriesId, poster, " - "audio_language, forced FROM table_shows ORDER BY sortTitle ASC LIMIT ? OFFSET ?", - (page_size, offset)) - # path_replace - dict_mapper.path_replace(data) - - # Get languages list - languages = database.execute("SELECT code2, name FROM table_settings_languages WHERE enabled=1") - - # Build missing subtitles clause depending on only_monitored - if settings.sonarr.getboolean('only_monitored'): - missing_subtitles_clause = " AND table_episodes.monitored='True'" - else: - missing_subtitles_clause = '' - - # Get missing subtitles count by series - missing_subtitles_list = database.execute("SELECT table_shows.sonarrSeriesId, " - "COUNT(table_episodes.missing_subtitles) as missing_subtitles FROM table_shows LEFT JOIN " - "table_episodes ON table_shows.sonarrSeriesId=" - "table_episodes.sonarrSeriesId WHERE table_shows.languages IS NOT 'None' " - "AND table_episodes.missing_subtitles IS NOT '[]'" + - missing_subtitles_clause + " GROUP BY table_shows.sonarrSeriesId") - - # Build total subtitles clause depending on only_monitored - if settings.sonarr.getboolean('only_monitored'): - total_subtitles_clause = " AND table_episodes.monitored == 'True'" - else: - total_subtitles_clause = '' - - # Get total subtitles count by series - total_subtitles_list = database.execute("SELECT table_shows.sonarrSeriesId, " - "COUNT(table_episodes.missing_subtitles) as missing_subtitles FROM table_shows LEFT JOIN " - "table_episodes ON table_shows.sonarrSeriesId=" - "table_episodes.sonarrSeriesId WHERE table_shows.languages IS NOT 'None'" - + total_subtitles_clause + " GROUP BY table_shows.sonarrSeriesId") - - return render_template('series.html', bazarr_version=bazarr_version, rows=data, missing_subtitles_list=missing_subtitles_list, - total_subtitles_list=total_subtitles_list, languages=languages, missing_count=series_count, - page=page, max_page=max_page, base_url=base_url, - single_language=settings.general.getboolean('single_language'), page_size=page_size, - current_port=settings.general.port) + return render_template('series.html') @app.route('/serieseditor/') @@ -717,35 +668,10 @@ def edit_serieseditor(): @app.route('/episodes/', methods=['GET']) +@app.route('/episodes/') @login_required def episodes(no): - - - series_details = database.execute("SELECT title, overview, poster, fanart, hearing_impaired, tvdbId, " - "audio_language, languages, path, forced FROM table_shows WHERE " - "sonarrSeriesId=?", (no,), only_one=True) - # path_replace - dict_mapper.path_replace(series_details) - - tvdbid = series_details['tvdbId'] - - episodes = database.execute("SELECT title, path, season, episode, subtitles, sonarrSeriesId, missing_subtitles, " - "sonarrEpisodeId, scene_name, monitored, failedAttempts FROM table_episodes WHERE " - "sonarrSeriesId=? ORDER BY season DESC, episode DESC", (no,)) - # path_replace - dict_mapper.path_replace(episodes) - - number = len(episodes) - - languages = database.execute("SELECT code2, name FROM table_settings_languages WHERE enabled=1") - - seasons_list = [] - for key, season in itertools.groupby(episodes, lambda x: x['season']): - seasons_list.append(list(season)) - - return render_template('episodes.html', bazarr_version=bazarr_version, no=no, details=series_details, - languages=languages, seasons=seasons_list, url_sonarr_short=url_sonarr_short(), base_url=base_url, - tvdbid=tvdbid, number=number, current_port=settings.general.port) + return render_template('episodes.html', id=str(no)) @app.route('/movies') diff --git a/views/_main.html b/views/_main.html index 6a8965396..a99e843d4 100644 --- a/views/_main.html +++ b/views/_main.html @@ -278,7 +278,7 @@ BadgesAjax() $(function () { - $('[data-toggle="tooltip"]').tooltip() + $('[data-toggle="tooltip"]').tooltip({html: true}) }) {% endblock tail_js %} diff --git a/views/episodes.html b/views/episodes.html index 7a0c829d8..e2b3ff323 100644 --- a/views/episodes.html +++ b/views/episodes.html @@ -1,821 +1,146 @@ - - - - - - - - - - - - - - - - - - - - - - {{details['title']}} - Bazarr - + h1 { + color: white; + } - - - - %import ast - %from get_languages import * - %from config import settings - %from helper import path_replace - %single_language = settings.general.getboolean('single_language') -
-
-
Loading...
-
- % include('menu.tpl') - -
-
-
-
- + span { + margin-right: 0.5em; + } + +{% endblock head %} + +{% block body %} +
+
+
+ +
+
+
+
+

+
- -
-
-
-
-

{{details['title']}}

-
- -
-
- - - <% - subs_languages = ast.literal_eval(str(details['languages'])) - subs_languages_list = [] - if subs_languages is not None: - for subs_language in subs_languages: - subs_languages_list.append(subs_language) - end - end - %> - -
-
-
- -
-

{{details['overview']}}

-
- -
-
{{details['audio_language']}}
-
{{details['path']}}
-
{{number}} files
-
- -
- %for language in subs_languages_list: -
{{language}}
- %end -
- -
-
Hearing-impaired: {{details['hearing_impaired']}}
-
Forced: {{details['forced']}}
-
-
+
+
+
+
-
-
- - %if len(seasons) == 0: -
-

No episode files available for this Series or Bazarr is still synchronizing with Sonarr. Please come back later.

-
- %else: - %for season in seasons: -
- %missing_subs = len([i for i in season if i['missing_subtitles'] != "[]"]) - %total_subs = len(season) - %subs_label = '' - %if subs_languages is not None: - % subs_label = '
' + str(total_subs - missing_subs) + ' / ' + str(total_subs) + '
' - %end - % season_number = None - % for season_temp in season: - % season_number = season_temp['season'] - % break - % end -

Season {{season_number}}{{!subs_label}}

-
-
-
-
-

- Show/Hide Episodes

-
-
-
-
- - - - - - - - - - - - - - %for episode in season: - - - - - - - - - - %end - -
EpisodeTitleExisting
Subtitles
Missing
Subtitles
Manual
Search
Manual
Upload
- %if episode['monitored'] == 'True': - - %else: - - %end - {{episode['episode']}} - % if episode['scene_name'] is not None: - - % end - {{episode['title']}} - - %if episode['subtitles'] is not None: - % actual_languages = ast.literal_eval(episode['subtitles']) - % actual_languages.sort(key=lambda x: x[0]) - %else: - % actual_languages = '[]' - %end - %try: - %for language in actual_languages: - %if language[0].endswith(':forced'): - % forced = True - %else: - % forced = False - %end - %if language[1] is not None: - - {{!'' if forced else ''}}{{language[0].split(':')[0]}} - - - %else: -
- {{language[0]}} -
- %end - %end - %except: - %pass - %end -
- %try: - <% - if episode['missing_subtitles'] is not None: - missing_languages = ast.literal_eval(episode['missing_subtitles']) - missing_languages.sort() - end - if missing_languages is not None: - from get_subtitle import search_active - for language in missing_languages: - if episode['failedAttempts'] is not None and settings.general.getboolean('adaptive_searching') and language in episode['failedAttempts']: - for lang in ast.literal_eval(episode['failedAttempts']): - if language in lang: - if search_active(lang[1]): - %> - 1 else "False"}}" data-sonarrSeriesId="{{episode['sonarrSeriesId']}}" data-sonarrEpisodeId="{{episode['sonarrEpisodeId']}}" class="get_subtitle ui tiny label"> - {{language}} - - - %else: - 1 else "False"}}" data-sonarrSeriesId="{{episode['sonarrSeriesId']}}" data-sonarrEpisodeId="{{episode['sonarrEpisodeId']}}" class="get_subtitle ui tiny label"> - {{language}} - - - %end - %end - %end - %else: - 1 else "False"}}" data-sonarrSeriesId="{{episode['sonarrSeriesId']}}" data-sonarrEpisodeId="{{episode['sonarrEpisodeId']}}" class="get_subtitle ui tiny label"> - {{language}} - - - %end - %end - %end - %except: - %pass - %end - - %if subs_languages is not None: - - %end - - %if subs_languages is not None: - - %end -
-
+
+
-
- %end - %end -
- -