From 27aae5a2835c4026bb02c0dc10617ab816aaf7a2 Mon Sep 17 00:00:00 2001 From: morpheus65535 <5130500+morpheus65535@users.noreply.github.com> Date: Wed, 10 Jan 2018 11:44:47 -0500 Subject: [PATCH 01/14] Implement single language option #36 --- bazarr.py | 18 +++++++++++++----- get_general_settings.py | 6 ++++-- get_subtitle.py | 6 +++++- list_subtitles.py | 24 ++++++++++++++++++++---- update_db.py | 15 ++++++++++++--- update_modules.py | 5 +++++ views/episodes.tpl | 3 ++- views/series.tpl | 2 +- views/serieseditor.tpl | 2 +- views/settings.tpl | 25 +++++++++++++++++++++++++ 10 files changed, 88 insertions(+), 18 deletions(-) diff --git a/bazarr.py b/bazarr.py index ea505ff4f..a19348bf7 100644 --- a/bazarr.py +++ b/bazarr.py @@ -1,4 +1,4 @@ -bazarr_version = '0.3.0' +bazarr_version = '0.3.1' from bottle import route, run, template, static_file, request, redirect, response import bottle @@ -128,6 +128,7 @@ def image_proxy(url): @route(base_url) def series(): import update_db + single_language = get_general_settings()[7] db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30) db.create_function("path_substitution", 1, path_replace) @@ -147,11 +148,13 @@ def series(): c.execute("SELECT code2, name FROM table_settings_languages WHERE enabled = 1") languages = c.fetchall() c.close() - 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) + 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, single_language=single_language) return output @route(base_url + 'serieseditor') def serieseditor(): + single_language = get_general_settings()[7] + 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() @@ -165,7 +168,7 @@ def serieseditor(): 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) + output = template('serieseditor', __file__=__file__, bazarr_version=bazarr_version, rows=data, languages=languages, missing_count=missing_count, base_url=base_url, single_language=single_language) return output @route(base_url + 'series_json/', method='GET') @@ -243,7 +246,7 @@ def edit_serieseditor(): @route(base_url + 'episodes/', method='GET') def episodes(no): - from get_sonarr_settings import get_sonarr_settings + single_language = get_general_settings()[7] url_sonarr_short = get_sonarr_settings()[1] conn = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30) @@ -380,10 +383,15 @@ def save_settings(): settings_general_automatic = 'False' else: settings_general_automatic = 'True' + settings_general_single_language = request.forms.get('settings_general_single_language') + if settings_general_single_language is None: + settings_general_single_language = 'False' + else: + settings_general_single_language = 'True' before = c.execute("SELECT ip, port, base_url FROM table_settings_general").fetchone() after = (unicode(settings_general_ip), int(settings_general_port), unicode(settings_general_baseurl)) - c.execute("UPDATE table_settings_general SET ip = ?, port = ?, base_url = ?, path_mapping = ?, log_level = ?, branch=?, auto_update=?", (unicode(settings_general_ip), int(settings_general_port), unicode(settings_general_baseurl), unicode(settings_general_pathmapping), unicode(settings_general_loglevel), unicode(settings_general_branch), unicode(settings_general_automatic))) + c.execute("UPDATE table_settings_general SET ip = ?, port = ?, base_url = ?, path_mapping = ?, log_level = ?, branch=?, auto_update=?, single_language=?", (unicode(settings_general_ip), int(settings_general_port), unicode(settings_general_baseurl), unicode(settings_general_pathmapping), unicode(settings_general_loglevel), unicode(settings_general_branch), unicode(settings_general_automatic), unicode(settings_general_single_language))) conn.commit() if after != before: configured() diff --git a/get_general_settings.py b/get_general_settings.py index 8ee78f18a..d5175f67d 100644 --- a/get_general_settings.py +++ b/get_general_settings.py @@ -26,8 +26,9 @@ def get_general_settings(): log_level = general_settings[4] branch = general_settings[5] automatic = general_settings[6] + single_language = general_settings[9] - return [ip, port, base_url, path_mappings, log_level, branch, automatic] + return [ip, port, base_url, path_mappings, log_level, branch, automatic, single_language] def path_replace(path): for path_mapping in path_mappings: @@ -58,4 +59,5 @@ base_url = result[2] path_mappings = result[3] log_level = result[4] branch = result[5] -automatic = result[6] \ No newline at end of file +automatic = result[6] +single_language = result[7] \ No newline at end of file diff --git a/get_subtitle.py b/get_subtitle.py index 09c337330..2616128d7 100644 --- a/get_subtitle.py +++ b/get_subtitle.py @@ -34,8 +34,12 @@ def download_subtitle(path, language, hi, providers, providers_auth): pass return None else: + single = get_general_settings()[7] try: - result = save_subtitles(video, [best_subtitle], encoding='utf-8') + if single == 'True': + result = save_subtitles(video, [best_subtitle], single=True, encoding='utf-8') + else: + result = save_subtitles(video, [best_subtitle], encoding='utf-8') except: logging.error('Error saving subtitles file to disk.') return None diff --git a/list_subtitles.py b/list_subtitles.py index e109d259a..3b6ce5bf6 100644 --- a/list_subtitles.py +++ b/list_subtitles.py @@ -5,6 +5,7 @@ from subliminal import * import pycountry import sqlite3 import ast +import langdetect from get_general_settings import * @@ -21,8 +22,7 @@ def list_subtitles(file): try: languages.append([str(pycountry.languages.lookup(subtitle_track.language).alpha_2),None]) except: - print subtitle_track.language - #pass + pass except: print file #pass @@ -30,7 +30,15 @@ def list_subtitles(file): subtitles = core.search_external_subtitles(file) for subtitle, language in subtitles.iteritems(): - actual_subtitles.append([str(language), path_replace_reverse(os.path.join(os.path.dirname(file), subtitle))]) + if str(language) != 'und': + actual_subtitles.append([str(language), path_replace_reverse(os.path.join(os.path.dirname(file), subtitle))]) + else: + with open(path_replace(os.path.join(os.path.dirname(file), subtitle)), 'r') as f: + text = [next(f) for x in xrange(5)] + text = ' '.join(text).decode('iso-8859-1') + detected_language = langdetect.detect(text) + if len(detected_language) > 0: + actual_subtitles.append([str(detected_language), path_replace_reverse(os.path.join(os.path.dirname(file), subtitle))]) return actual_subtitles @@ -55,7 +63,15 @@ def store_subtitles(file): subtitles = core.search_external_subtitles(file) for subtitle, language in subtitles.iteritems(): - actual_subtitles.append([str(language), path_replace_reverse(os.path.join(os.path.dirname(file), subtitle))]) + if str(language) != 'und': + actual_subtitles.append([str(language), path_replace_reverse(os.path.join(os.path.dirname(file), subtitle))]) + else: + with open(path_replace(os.path.join(os.path.dirname(file), subtitle)), 'r') as f: + text = [next(f) for x in xrange(5)] + text = ' '.join(text).decode('iso-8859-1') + detected_language = langdetect.detect(text) + if len(detected_language) > 0: + actual_subtitles.append([str(detected_language), unicode(path_replace_reverse(os.path.join(os.path.dirname(file), subtitle)))]) conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30) c_db = conn_db.cursor() diff --git a/update_db.py b/update_db.py index f5d0912ee..baff397fd 100644 --- a/update_db.py +++ b/update_db.py @@ -7,18 +7,20 @@ if os.path.exists(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db')) db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30) c = db.cursor() - # Execute table modification + # Execute tables modifications try: c.execute('alter table table_settings_providers add column "username" "text"') - c.execute('UPDATE table_settings_providers SET username=""') except: pass + else: + c.execute('UPDATE table_settings_providers SET username=""') try: c.execute('alter table table_settings_providers add column "password" "text"') - c.execute('UPDATE table_settings_providers SET password=""') except: pass + else: + c.execute('UPDATE table_settings_providers SET password=""') try: c.execute('alter table table_shows add column "audio_language" "text"') @@ -31,6 +33,13 @@ if os.path.exists(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db')) except: pass + try: + c.execute('alter table table_settings_general add column "single_language" "text"') + except: + pass + else: + c.execute('UPDATE table_settings_general SET single_language="False"') + # Commit change to db db.commit() diff --git a/update_modules.py b/update_modules.py index 1d507e179..ff820953d 100644 --- a/update_modules.py +++ b/update_modules.py @@ -2,5 +2,10 @@ import pip try: pip.main(['install', '--user', 'gitpython']) +except SystemExit as e: + pass + +try: + pip.main(['install', '--user', 'langdetect']) except SystemExit as e: pass \ No newline at end of file diff --git a/views/episodes.tpl b/views/episodes.tpl index 2d61b6acc..aa3654482 100644 --- a/views/episodes.tpl +++ b/views/episodes.tpl @@ -80,6 +80,7 @@ %import ast %import pycountry %from get_general_settings import * + %single_language = get_general_settings()[7]
Loading...
@@ -229,7 +230,7 @@
- %for language in languages: diff --git a/views/series.tpl b/views/series.tpl index bd9f88ae2..faa58f46e 100644 --- a/views/series.tpl +++ b/views/series.tpl @@ -156,7 +156,7 @@
- %for language in languages: diff --git a/views/serieseditor.tpl b/views/serieseditor.tpl index f486d7286..61113f954 100644 --- a/views/serieseditor.tpl +++ b/views/serieseditor.tpl @@ -102,7 +102,7 @@
- %for language in languages: diff --git a/views/settings.tpl b/views/settings.tpl index fdfa8d132..6dcb3a8b1 100644 --- a/views/settings.tpl +++ b/views/settings.tpl @@ -476,6 +476,25 @@
Subtitles languages
+
+
+ +
+
+
+ + +
+
+ +
+
@@ -526,6 +545,12 @@ $("#settings_automatic_div").checkbox('uncheck'); } + if ($('#settings_single_language').data("single-language") == "True") { + $("#settings_single_language").checkbox('check'); + } else { + $("#settings_single_language").checkbox('uncheck'); + } + $('#settings_loglevel').dropdown('clear'); $('#settings_loglevel').dropdown('set selected','{{!settings_general[4]}}'); $('#settings_providers').dropdown('clear'); From 916f1add598f65ac3feabbb48457551feaf981b6 Mon Sep 17 00:00:00 2001 From: morpheus65535 <5130500+morpheus65535@users.noreply.github.com> Date: Thu, 11 Jan 2018 19:42:35 -0500 Subject: [PATCH 02/14] Add compatibility with Sonarr v3 API #37 --- get_series.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/get_series.py b/get_series.py index c390e3931..3a7edff93 100644 --- a/get_series.py +++ b/get_series.py @@ -10,8 +10,6 @@ def update_series(): url_sonarr_short = get_sonarr_settings()[1] apikey_sonarr = get_sonarr_settings()[2] - get_profile_list() - # Open database connection db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30) c = db.cursor() @@ -19,6 +17,8 @@ def update_series(): if apikey_sonarr == None: pass else: + get_profile_list() + # Get shows data from Sonarr url_sonarr_api_series = url_sonarr + "/api/series?apikey=" + apikey_sonarr r = requests.get(url_sonarr_api_series) @@ -50,7 +50,7 @@ def update_series(): try: c.execute('''INSERT INTO table_shows(title, path, tvdbId, languages,`hearing_impaired`, sonarrSeriesId, overview, poster, fanart, `audio_language`) VALUES (?,?,?,(SELECT languages FROM table_shows WHERE tvdbId = ?),(SELECT `hearing_impaired` FROM table_shows WHERE tvdbId = ?), ?, ?, ?, ?, ?)''', (show["title"], show["path"], show["tvdbId"], show["tvdbId"], show["tvdbId"], show["id"], overview, poster, fanart, profile_id_to_language(show['qualityProfileId']))) except: - c.execute('''UPDATE table_shows SET title = ?, path = ?, tvdbId = ?, sonarrSeriesId = ?, overview = ?, poster = ?, fanart = ?, `audio_language` = ? WHERE tvdbid = ?''', (show["title"],show["path"],show["tvdbId"],show["id"],overview,poster,fanart,profile_id_to_language(show['qualityProfileId']),show["tvdbId"])) + c.execute('''UPDATE table_shows SET title = ?, path = ?, tvdbId = ?, sonarrSeriesId = ?, overview = ?, poster = ?, fanart = ?, `audio_language` = ? WHERE tvdbid = ?''', (show["title"],show["path"],show["tvdbId"],show["id"],overview,poster,fanart,profile_id_to_language((show['qualityProfileId'] if sonarr_version == 2 else show['languageProfileId'])),show["tvdbId"])) # Delete shows not in Sonarr anymore deleted_items = [] @@ -74,14 +74,25 @@ def get_profile_list(): # Get profiles data from Sonarr url_sonarr_api_series = url_sonarr + "/api/profile?apikey=" + apikey_sonarr profiles_json = requests.get(url_sonarr_api_series) + url_sonarr_api_series_v3 = url_sonarr + "/api/v3/languageprofile?apikey=" + apikey_sonarr + profiles_json_v3 = requests.get(url_sonarr_api_series_v3) global profiles_list profiles_list = [] # Parsing data returned from Sonarr - for profile in profiles_json.json(): - profiles_list.append([profile['id'], profile['language'].capitalize()]) + global sonarr_version + if type(profiles_json_v3.json()) != list: + sonarr_version = 2 + for profile in profiles_json.json(): + profiles_list.append([profile['id'], profile['language'].capitalize()]) + else: + sonarr_version = 3 + for profile in profiles_json_v3.json(): + profiles_list.append([profile['id'], profile['name'].capitalize()]) def profile_id_to_language(id): for profile in profiles_list: if id == profile[0]: - return profile[1] \ No newline at end of file + return profile[1] + +update_series() From d8aa94e632ceeb476261a9df1d5c1f08808152c1 Mon Sep 17 00:00:00 2001 From: morpheus65535 <5130500+morpheus65535@users.noreply.github.com> Date: Fri, 12 Jan 2018 20:47:48 -0500 Subject: [PATCH 03/14] Increased number of line to check for language detection and fixed conversion #36 --- list_subtitles.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/list_subtitles.py b/list_subtitles.py index 3b6ce5bf6..2ad8e5ec3 100644 --- a/list_subtitles.py +++ b/list_subtitles.py @@ -6,6 +6,7 @@ import pycountry import sqlite3 import ast import langdetect +import chardet from get_general_settings import * @@ -35,7 +36,9 @@ def list_subtitles(file): else: with open(path_replace(os.path.join(os.path.dirname(file), subtitle)), 'r') as f: text = [next(f) for x in xrange(5)] - text = ' '.join(text).decode('iso-8859-1') + text = ' '.join(text) + encoding = chardet.detect(text)['encoding'] + text = text.decode(encoding) detected_language = langdetect.detect(text) if len(detected_language) > 0: actual_subtitles.append([str(detected_language), path_replace_reverse(os.path.join(os.path.dirname(file), subtitle))]) @@ -67,7 +70,7 @@ def store_subtitles(file): actual_subtitles.append([str(language), path_replace_reverse(os.path.join(os.path.dirname(file), subtitle))]) else: with open(path_replace(os.path.join(os.path.dirname(file), subtitle)), 'r') as f: - text = [next(f) for x in xrange(5)] + text = [next(f) for x in xrange(20)] text = ' '.join(text).decode('iso-8859-1') detected_language = langdetect.detect(text) if len(detected_language) > 0: From b732538366e23ac6bc3ea4dd64007d62d1f005af Mon Sep 17 00:00:00 2001 From: morpheus65535 <5130500+morpheus65535@users.noreply.github.com> Date: Sat, 13 Jan 2018 09:21:12 -0500 Subject: [PATCH 04/14] Correction about #36 --- list_subtitles.py | 41 ++++------------------------------------- 1 file changed, 4 insertions(+), 37 deletions(-) diff --git a/list_subtitles.py b/list_subtitles.py index 2ad8e5ec3..87d17846c 100644 --- a/list_subtitles.py +++ b/list_subtitles.py @@ -10,41 +10,6 @@ import chardet from get_general_settings import * -def list_subtitles(file): - languages = [] - actual_subtitles = [] - if os.path.exists(file): - if os.path.splitext(file)[1] == '.mkv': - try: - with open(file, 'rb') as f: - mkv = enzyme.MKV(f) - - for subtitle_track in mkv.subtitle_tracks: - try: - languages.append([str(pycountry.languages.lookup(subtitle_track.language).alpha_2),None]) - except: - pass - except: - print file - #pass - - subtitles = core.search_external_subtitles(file) - - for subtitle, language in subtitles.iteritems(): - if str(language) != 'und': - actual_subtitles.append([str(language), path_replace_reverse(os.path.join(os.path.dirname(file), subtitle))]) - else: - with open(path_replace(os.path.join(os.path.dirname(file), subtitle)), 'r') as f: - text = [next(f) for x in xrange(5)] - text = ' '.join(text) - encoding = chardet.detect(text)['encoding'] - text = text.decode(encoding) - detected_language = langdetect.detect(text) - if len(detected_language) > 0: - actual_subtitles.append([str(detected_language), path_replace_reverse(os.path.join(os.path.dirname(file), subtitle))]) - - return actual_subtitles - def store_subtitles(file): languages = [] actual_subtitles = [] @@ -71,10 +36,12 @@ def store_subtitles(file): else: with open(path_replace(os.path.join(os.path.dirname(file), subtitle)), 'r') as f: text = [next(f) for x in xrange(20)] - text = ' '.join(text).decode('iso-8859-1') + text = ' '.join(text) + encoding = chardet.detect(text)['encoding'] + text = text.decode(encoding) detected_language = langdetect.detect(text) if len(detected_language) > 0: - actual_subtitles.append([str(detected_language), unicode(path_replace_reverse(os.path.join(os.path.dirname(file), subtitle)))]) + actual_subtitles.append([str(detected_language), path_replace_reverse(os.path.join(os.path.dirname(file), subtitle))]) conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30) c_db = conn_db.cursor() From d805576f839cff005b75bf160ffce7762203c262 Mon Sep 17 00:00:00 2001 From: morpheus65535 <5130500+morpheus65535@users.noreply.github.com> Date: Sat, 13 Jan 2018 12:39:54 -0500 Subject: [PATCH 05/14] Switch from next to itertools to avoid StopIteration error #37 --- list_subtitles.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/list_subtitles.py b/list_subtitles.py index 87d17846c..3158ba3b4 100644 --- a/list_subtitles.py +++ b/list_subtitles.py @@ -7,6 +7,7 @@ import sqlite3 import ast import langdetect import chardet +from itertools import islice from get_general_settings import * @@ -35,7 +36,7 @@ def store_subtitles(file): actual_subtitles.append([str(language), path_replace_reverse(os.path.join(os.path.dirname(file), subtitle))]) else: with open(path_replace(os.path.join(os.path.dirname(file), subtitle)), 'r') as f: - text = [next(f) for x in xrange(20)] + text = list(islice(f, 20)) text = ' '.join(text) encoding = chardet.detect(text)['encoding'] text = text.decode(encoding) From 47261c0c9132f8eb00730004cdb451caaf0ed3bb Mon Sep 17 00:00:00 2001 From: morpheus65535 <5130500+morpheus65535@users.noreply.github.com> Date: Sat, 13 Jan 2018 15:45:21 -0500 Subject: [PATCH 06/14] Adding exception logging for subtitles file encoding detection #37 --- list_subtitles.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/list_subtitles.py b/list_subtitles.py index 3158ba3b4..4d0010a53 100644 --- a/list_subtitles.py +++ b/list_subtitles.py @@ -39,10 +39,14 @@ def store_subtitles(file): text = list(islice(f, 20)) text = ' '.join(text) encoding = chardet.detect(text)['encoding'] - text = text.decode(encoding) - detected_language = langdetect.detect(text) - if len(detected_language) > 0: - actual_subtitles.append([str(detected_language), path_replace_reverse(os.path.join(os.path.dirname(file), subtitle))]) + try: + text = text.decode(encoding) + except Exception as e: + logging.exception('Error trying to detect character encoding for this subtitles file: ' + path_replace(os.path.join(os.path.dirname(file), subtitle))) + else: + detected_language = langdetect.detect(text) + if len(detected_language) > 0: + actual_subtitles.append([str(detected_language), path_replace_reverse(os.path.join(os.path.dirname(file), subtitle))]) conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30) c_db = conn_db.cursor() From 98de479389d367248b6376c74afc66093d7642a8 Mon Sep 17 00:00:00 2001 From: morpheus65535 <5130500+morpheus65535@users.noreply.github.com> Date: Sat, 13 Jan 2018 23:20:20 -0500 Subject: [PATCH 07/14] Switched to UnicodeDammit instead of chardet which give me better result #37 --- list_subtitles.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/list_subtitles.py b/list_subtitles.py index 4d0010a53..26dff271e 100644 --- a/list_subtitles.py +++ b/list_subtitles.py @@ -6,7 +6,7 @@ import pycountry import sqlite3 import ast import langdetect -import chardet +from bs4 import UnicodeDammit from itertools import islice from get_general_settings import * @@ -38,9 +38,9 @@ def store_subtitles(file): with open(path_replace(os.path.join(os.path.dirname(file), subtitle)), 'r') as f: text = list(islice(f, 20)) text = ' '.join(text) - encoding = chardet.detect(text)['encoding'] + encoding = UnicodeDammit(text) try: - text = text.decode(encoding) + text = text.decode(encoding.original_encoding) except Exception as e: logging.exception('Error trying to detect character encoding for this subtitles file: ' + path_replace(os.path.join(os.path.dirname(file), subtitle))) else: From 77c43550d8f16d34d26c819ff6bf72a20d3dc331 Mon Sep 17 00:00:00 2001 From: morpheus65535 <5130500+morpheus65535@users.noreply.github.com> Date: Sun, 14 Jan 2018 20:50:03 -0500 Subject: [PATCH 08/14] Added a suggestion do delete undecodable subtitles file --- list_subtitles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/list_subtitles.py b/list_subtitles.py index 26dff271e..04121af50 100644 --- a/list_subtitles.py +++ b/list_subtitles.py @@ -42,7 +42,7 @@ def store_subtitles(file): try: text = text.decode(encoding.original_encoding) except Exception as e: - logging.exception('Error trying to detect character encoding for this subtitles file: ' + path_replace(os.path.join(os.path.dirname(file), subtitle))) + logging.exception('Error trying to detect character encoding for this subtitles file: ' + path_replace(os.path.join(os.path.dirname(file), subtitle)) + ' You should try to delete this subtitles file manually and ask Bazarr to download it again.') else: detected_language = langdetect.detect(text) if len(detected_language) > 0: From be7c33f2c5ee476190dee369ac5d96809b687612 Mon Sep 17 00:00:00 2001 From: morpheus65535 <5130500+morpheus65535@users.noreply.github.com> Date: Mon, 15 Jan 2018 23:00:29 -0500 Subject: [PATCH 09/14] Included git name and email configuration if not already set to avoid update error. --- check_update.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/check_update.py b/check_update.py index e73502a45..fb8005478 100644 --- a/check_update.py +++ b/check_update.py @@ -8,7 +8,23 @@ import git current_working_directory = os.path.dirname(__file__) +def gitconfig(): + g = git.Repo.init(current_working_directory) + config_read = g.config_reader() + config_write = g.config_writer() + + try: + username = config_read.get_value("user", "name") + except: + config_write.set_value("user", "name", "Bazarr") + + try: + email = config_read.get_value("user", "email") + except: + config_write.set_value("user", "email", "bazarr@fake.email") + def check_and_apply_update(): + gitconfig() g = git.cmd.Git(current_working_directory) result = g.pull('origin', branch) if result.startswith('Already'): From 18a28973e7a241aab653e615ce4923843091cb66 Mon Sep 17 00:00:00 2001 From: morpheus65535 <5130500+morpheus65535@users.noreply.github.com> Date: Mon, 15 Jan 2018 23:28:40 -0500 Subject: [PATCH 10/14] Version bump --- bazarr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bazarr.py b/bazarr.py index a19348bf7..94ec46f8f 100644 --- a/bazarr.py +++ b/bazarr.py @@ -1,4 +1,4 @@ -bazarr_version = '0.3.1' +bazarr_version = '0.3.2' from bottle import route, run, template, static_file, request, redirect, response import bottle From 15a1d576ac009f52fbcf06ca9e414e93c31480b4 Mon Sep 17 00:00:00 2001 From: morpheus65535 <5130500+morpheus65535@users.noreply.github.com> Date: Mon, 15 Jan 2018 23:29:15 -0500 Subject: [PATCH 11/14] Updating process improvement --- check_update.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_update.py b/check_update.py index fb8005478..00e447960 100644 --- a/check_update.py +++ b/check_update.py @@ -29,7 +29,7 @@ def check_and_apply_update(): result = g.pull('origin', branch) if result.startswith('Already'): logging.info('No new version of Bazarr available.') - elif result.startswith('Updating'): + elif result.startswith('Updating') or result.startswith('Merge made'): logging.info('Bazarr updated to latest version and need to be restarted.') updated() else: From 1591529ff62fee1be93210a46a64efca7611d4c2 Mon Sep 17 00:00:00 2001 From: morpheus65535 <5130500+morpheus65535@users.noreply.github.com> Date: Mon, 15 Jan 2018 23:29:39 -0500 Subject: [PATCH 12/14] Switching to alpine linux for docker container --- Dockerfile | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index ffc2638b7..d38673405 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,18 @@ -FROM debian:buster +FROM python:2.7.14-alpine3.6 ENV LANG C.UTF-8 ENV LC_ALL C.UTF-8 -EXPOSE 6767 - VOLUME /tv -RUN apt-get update && \ - apt-get install -y python-dev python-pip python-setuptools libjpeg-dev zlib1g-dev git libffi-dev && \ - pip install -r /bazarr/requirements.txt +RUN apk add --update git py-pip jpeg-dev && \ + apk add --update --virtual build-dependencies build-base python-dev libffi-dev zlib-dev && \ + git clone -b master --single-branch https://github.com/morpheus65535/bazarr.git /bazarr && \ + pip install -r /bazarr/requirements.txt && \ + apk del --purge build-dependencies VOLUME /bazarr/data +EXPOSE 6767 + CMD ["python", "/bazarr/bazarr.py"] \ No newline at end of file From 10946b1c3806ac3fb5e3e43e70ab04ba6a33eb4d Mon Sep 17 00:00:00 2001 From: morpheus65535 <5130500+morpheus65535@users.noreply.github.com> Date: Mon, 15 Jan 2018 23:30:08 -0500 Subject: [PATCH 13/14] Removing docker old backup --- Dockerfile.alpine | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 Dockerfile.alpine diff --git a/Dockerfile.alpine b/Dockerfile.alpine deleted file mode 100644 index 0562757e9..000000000 --- a/Dockerfile.alpine +++ /dev/null @@ -1,15 +0,0 @@ -FROM lsiobase/alpine:3.6 - -VOLUME /tv - -RUN apk add --update git python2 py-pip py-pygit2 jpeg-dev && \ - apk add --update --virtual build-dependencies g++ python-dev libffi-dev zlib-dev && \ - git clone -b master --single-branch https://github.com/morpheus65535/bazarr.git /app && \ - pip install -r /app/requirements.txt && \ - apk del --purge build-dependencies - -VOLUME /app/data - -EXPOSE 6767 - -CMD ["python", "/app/bazarr.py"] \ No newline at end of file From 472980e3b34f105fb03983c61d6d713fb8ffd8be Mon Sep 17 00:00:00 2001 From: morpheus65535 <5130500+morpheus65535@users.noreply.github.com> Date: Mon, 15 Jan 2018 23:30:41 -0500 Subject: [PATCH 14/14] Switch to in memory cache on every OS --- get_subtitle.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/get_subtitle.py b/get_subtitle.py index 2616128d7..6363db819 100644 --- a/get_subtitle.py +++ b/get_subtitle.py @@ -10,10 +10,7 @@ from list_subtitles import * from utils import * # configure the cache -if os.name == 'nt': - region.configure('dogpile.cache.memory') -else: - region.configure('dogpile.cache.dbm', arguments={'filename': os.path.join(os.path.dirname(__file__), 'data/cache/cachefile.dbm')}) +region.configure('dogpile.cache.memory') def download_subtitle(path, language, hi, providers, providers_auth): try: