diff --git a/bazarr.py b/bazarr.py index afd7d4936..2a308b0c2 100644 --- a/bazarr.py +++ b/bazarr.py @@ -21,6 +21,7 @@ from io import BytesIO from fdsend import send_file import urllib import math +import ast from init_db import * from update_db import * @@ -149,6 +150,24 @@ def series(): output = template('series', __file__=__file__, bazarr_version=bazarr_version, rows=data, languages=languages, missing_count=missing_count, page=page, max_page=max_page, base_url=base_url) return output +@route(base_url + 'serieseditor') +def serieseditor(): + db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30) + db.create_function("path_substitution", 1, path_replace) + c = db.cursor() + + c.execute("SELECT COUNT(*) FROM table_shows") + missing_count = c.fetchone() + missing_count = missing_count[0] + + c.execute("SELECT tvdbId, title, path_substitution(path), languages, hearing_impaired, sonarrSeriesId, poster, audio_language FROM table_shows ORDER BY title ASC") + data = c.fetchall() + c.execute("SELECT code2, name FROM table_settings_languages WHERE enabled = 1") + languages = c.fetchall() + c.close() + output = template('serieseditor', __file__=__file__, bazarr_version=bazarr_version, rows=data, languages=languages, missing_count=missing_count, base_url=base_url) + return output + @route(base_url + 'series_json/', method='GET') def series_json(query): db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30) @@ -171,12 +190,10 @@ def edit_series(no): lang = request.forms.getall('languages') if len(lang) > 0: - if lang[0] == '': - lang = None - else: - pass + pass else: - lang = None + lang = 'None' + hi = request.forms.get('hearing_impaired') if hi == "on": @@ -186,7 +203,7 @@ def edit_series(no): conn = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30) c = conn.cursor() - c.execute("UPDATE table_shows SET languages = ?, hearing_impaired = ? WHERE tvdbId LIKE ?", (str(lang), hi, no)) + c.execute("UPDATE table_shows SET languages = ?, hearing_impaired = ? WHERE sonarrSeriesId LIKE ?", (str(lang), hi, no)) conn.commit() c.close() @@ -194,6 +211,36 @@ def edit_series(no): redirect(ref) +@route(base_url + 'edit_serieseditor', method='POST') +def edit_serieseditor(): + ref = request.environ['HTTP_REFERER'] + + series = request.forms.get('series') + series = ast.literal_eval(str('[' + series + ']')) + lang = request.forms.getall('languages') + hi = request.forms.get('hearing_impaired') + + conn = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30) + c = conn.cursor() + + for serie in series: + if len(lang) > 0: + if str(lang) == "['None']": + lang = 'None' + else: + lang = str(lang) + c.execute("UPDATE table_shows SET languages = ? WHERE sonarrSeriesId LIKE ?", (lang, serie)) + if hi != '': + c.execute("UPDATE table_shows SET hearing_impaired = ? WHERE sonarrSeriesId LIKE ?", (hi, serie)) + + conn.commit() + c.close() + + for serie in series: + list_missing_subtitles(serie) + + redirect(ref) + @route(base_url + 'episodes/', method='GET') def episodes(no): from get_sonarr_settings import get_sonarr_settings diff --git a/views/series.tpl b/views/series.tpl index 2122ca8b2..bd9f88ae2 100644 --- a/views/series.tpl +++ b/views/series.tpl @@ -49,6 +49,9 @@ % include('menu.tpl')
+
+ +
@@ -213,6 +216,10 @@ location.href="?page={{int(max_page)}}"; }) + $('#serieseditor').click(function(){ + window.location = '{{base_url}}serieseditor'; + }) + $('.modal') .modal({ autofocus: false diff --git a/views/serieseditor.tpl b/views/serieseditor.tpl new file mode 100644 index 000000000..0091dc418 --- /dev/null +++ b/views/serieseditor.tpl @@ -0,0 +1,176 @@ + + + + + + + + + + + + + + + + + + Series Editor - Bazarr + + + + +
+
Loading...
+
+ % include('menu.tpl') + +
+
+ + + + + + + + + + + %import ast + %import os + %for row in rows: + + + + + + + + %end + +
+
+ + +
+
NameAudio languageSubtitles languagesHearing-impaired
+
+ + +
+
{{row[1]}}{{row[7]}} + %subs_languages = ast.literal_eval(str(row[3])) + %if subs_languages is not None: + %for subs_language in subs_languages: +
{{subs_language}}
+ %end + %end +
{{!"" if row[4] == None else row[4]}}
+
+ + + % include('footer.tpl') +



+ + + + + \ No newline at end of file