diff --git a/bazarr.db b/bazarr.db index 97f40554a..c29826065 100644 Binary files a/bazarr.db and b/bazarr.db differ diff --git a/bazarr.py b/bazarr.py index f440da735..9511fbbae 100644 --- a/bazarr.py +++ b/bazarr.py @@ -15,6 +15,8 @@ import urllib from init_db import * from get_languages import * +from get_providers import * + from get_general_settings import * from get_sonarr_settings import * from list_subtitles import * @@ -108,16 +110,39 @@ def settings(): c = db.cursor() c.execute("SELECT * FROM table_settings_general") settings_general = c.fetchone() - c.execute("SELECT * FROM table_settings_languages") + c.execute("SELECT * FROM table_settings_languages ORDER BY name") settings_languages = c.fetchall() - c.execute("SELECT * FROM table_settings_providers") + c.execute("SELECT * FROM table_settings_providers ORDER BY name") settings_providers = c.fetchall() c.execute("SELECT * FROM table_settings_sonarr") settings_sonarr = c.fetchone() - c.execute("SELECT * FROM table_settings_subliminal") - settings_subliminal = c.fetchone() c.close() - return template('settings', settings_general=settings_general, settings_languages=settings_languages, settings_providers=settings_providers, settings_sonarr=settings_sonarr, settings_subliminal=settings_subliminal) + return template('settings', settings_general=settings_general, settings_languages=settings_languages, settings_providers=settings_providers, settings_sonarr=settings_sonarr) + +@route('/save_settings', method='POST') +def save_settings(): + lang = request.forms.getall('languages') + if len(lang) > 0: + if lang[0] == '': + lang = None + else: + pass + else: + lang = None + hi = request.forms.get('hearing_impaired') + + if hi == "on": + hi = "True" + else: + hi = "False" + + conn = sqlite3.connect('bazarr.db') + c = conn.cursor() + c.execute("UPDATE table_shows SET languages = ?, hearing_impaired = ? WHERE tvdbId LIKE ?", (str(lang), hi, no)) + conn.commit() + c.close() + + redirect('/settings') @route('/system') def system(): diff --git a/get_providers.py b/get_providers.py new file mode 100644 index 000000000..f20f750e3 --- /dev/null +++ b/get_providers.py @@ -0,0 +1,19 @@ +import sqlite3 +from subliminal import * + +# Get providers list from subliminal +providers_list = sorted(provider_manager.names()) + +# Open database connection +db = sqlite3.connect('bazarr.db') +c = db.cursor() + +# Insert providers in database table +for provider_name in providers_list: + c.execute('''INSERT OR IGNORE INTO table_settings_providers(name) VALUES(?)''', (provider_name, )) + +# Commit changes to database table +db.commit() + +# Close database connection +db.close() diff --git a/list_subtitles.py b/list_subtitles.py index dda83d9a8..87b236079 100644 --- a/list_subtitles.py +++ b/list_subtitles.py @@ -1,6 +1,7 @@ import os import enzyme import babelfish +from subliminal import * import pycountry import sqlite3 import ast @@ -25,20 +26,19 @@ def store_subtitles(file): conn_db = sqlite3.connect('bazarr.db') c_db = conn_db.cursor() - enabled_languages = c_db.execute("SELECT code2 FROM table_settings_languages WHERE enabled = 1").fetchall() - for language in enabled_languages: - subtitle_path = os.path.splitext(file)[0] + "." + str(language[0]) + ".srt" - if os.path.isfile(subtitle_path): - languages.append([str(language[0]),str(path_replace_reverse(subtitle_path))]) + subtitles = core.search_external_subtitles(file) + actual_subtitles = [] + for subtitle, language in subtitles.iteritems(): + actual_subtitles.append([str(language), path_replace_reverse(os.path.join(os.path.dirname(file), subtitle))]) try: - c_db.execute("UPDATE table_episodes SET subtitles = ? WHERE path = ?", (str(languages), path_replace_reverse(file))) + c_db.execute("UPDATE table_episodes SET subtitles = ? WHERE path = ?", (str(actual_subtitles), path_replace_reverse(file))) conn_db.commit() except: pass c_db.close() - return languages + return actual_subtitles def list_missing_subtitles(file): conn_db = sqlite3.connect('bazarr.db') @@ -69,5 +69,4 @@ def full_scan_subtitles(): for path in all_path: print store_subtitles(path_replace(path[0])) -#print list_missing_subtitles('/tv/Fear the Walking Dead/Season 3/Fear.The.Walking.Dead.S03E01.CONVERT.720p.WEB.h264-TBS[rarbg].mkv') #full_scan_subtitles() diff --git a/list_subtitles.pyc b/list_subtitles.pyc index b82a1a6ff..e62ea6020 100644 Binary files a/list_subtitles.pyc and b/list_subtitles.pyc differ diff --git a/utils.pyc b/utils.pyc index 0b4f5995d..76ce77909 100644 Binary files a/utils.pyc and b/utils.pyc differ diff --git a/views/settings.tpl b/views/settings.tpl index 1fc715b39..3d608f811 100644 --- a/views/settings.tpl +++ b/views/settings.tpl @@ -71,23 +71,182 @@ General Sonarr Subliminal - Providers - Languages
- General +
+
+
Bazarr settings
+
+
+
+
+ +
+
+
+ +
+
+
+ +
+
+ +
+
+
+ +
+
+
+ +
+
+ +
+
+
+ +
+
+
+ +
+
+ +
+
+
+ + +
+
+
+ +
+
+ +
+
+
+ +
+
+
+
+
- Sonarr +
+
+
sonarr settings
+
+
+
+
+ +
+
+
+ +
+
+
+ +
+
+ +
+
+
+ +
+
+
+ +
+
+ +
+
+
+ +
+
+
+ +
+
+ +
+
+
+ + +
+
+
+ +
+
+ +
+
+
+ +
+
+
+
+
- Subliminal -
-
- Providers -
-
- Languages +
+
+
Providers
+
+
+
+
+ +
+
+ +
+
+
+
+
Subtitles languages
+
+
+
+
+ +
+
+ +
+
+
+
@@ -102,4 +261,18 @@ $('a.menu').click(function(){ $('#loader').addClass('active'); }) + + if ($('#sonarr_ssl_div').data("ssl") == "True") { + $("#sonarr_ssl_div").checkbox('check'); + } else { + $("#sonarr_ssl_div").checkbox('uncheck'); + } + + $('#settings_providers').dropdown('clear'); + $('#settings_providers').dropdown('set selected',{{!enabled_providers}}); + $('#settings_languages').dropdown('clear'); + $('#settings_languages').dropdown('set selected',{{!enabled_languages}}); + + $('#settings_providers').dropdown(); + $('#settings_languages').dropdown(); \ No newline at end of file