From 31a14eea7ca910ad7167e467a3be086fb00bfae4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Mon, 13 Nov 2017 23:23:07 -0500 Subject: [PATCH 01/55] Error 500 in episode list --- Dockerfile | 2 +- get_episodes.py | 5 ++++- views/episodes.tpl | 53 ++++++++++++++++++++++++++-------------------- 3 files changed, 35 insertions(+), 25 deletions(-) diff --git a/Dockerfile b/Dockerfile index 221fe2fc9..1af1d4314 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM lsiobase/alpine.python +FROM python:2 EXPOSE 6767 diff --git a/get_episodes.py b/get_episodes.py index bcdcbb006..880679d97 100644 --- a/get_episodes.py +++ b/get_episodes.py @@ -120,4 +120,7 @@ def add_new_episodes(): # Store substitles from episodes we've just added new_scan_subtitles() - list_missing_subtitles() + try: + list_missing_subtitles() + except: + pass diff --git a/views/episodes.tpl b/views/episodes.tpl index 4b391f3e4..c2a56aeb4 100644 --- a/views/episodes.tpl +++ b/views/episodes.tpl @@ -155,36 +155,43 @@ %if episode[4] is not None: % actual_languages = ast.literal_eval(episode[4]) %else: - actual_languages = '[]' + % actual_languages = '[]' %end - %if actual_languages is not None: + + %try: %for language in actual_languages: - %if language[1] is not None: - - {{language[0]}} - - - %else: -
- {{language[0]}} -
- %end + %if language[1] is not None: + + {{language[0]}} + + + %else: +
+ {{language[0]}} +
+ %end %end + %except: + %pass %end - %if episode[6] is not None: - % missing_languages = ast.literal_eval(episode[6]) - %else: - % missing_languages = None - %end - %if missing_languages is not None: - %for language in missing_languages: - - {{language}} - - + %try: + %if episode[6] is not None: + % missing_languages = ast.literal_eval(episode[6]) + %else: + % missing_languages = None + %end + %if missing_languages is not None: + %for language in missing_languages: + + {{language}} + + + %end %end + %except: + %pass %end From 2edd829849a1a17cfd00128a8b0666cd3692dd68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Mon, 13 Nov 2017 23:31:05 -0500 Subject: [PATCH 02/55] Switching to Debian base --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 1af1d4314..4f5b96c32 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ EXPOSE 6767 VOLUME /tv # Update -RUN apk add --update build-base python-dev py2-pip py-setuptools jpeg-dev zlib-dev git libgit2-dev +RUN apt-get install build-base python-dev py2-pip py-setuptools jpeg-dev zlib-dev git libgit2-dev # Get application source from Github RUN git clone -b master --single-branch https://github.com/morpheus65535/bazarr.git /bazarr From 32988225c47209b87f4abc650f18adb71bd1da2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Mon, 13 Nov 2017 23:51:58 -0500 Subject: [PATCH 03/55] Revert to alpine --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4f5b96c32..221fe2fc9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ -FROM python:2 +FROM lsiobase/alpine.python EXPOSE 6767 VOLUME /tv # Update -RUN apt-get install build-base python-dev py2-pip py-setuptools jpeg-dev zlib-dev git libgit2-dev +RUN apk add --update build-base python-dev py2-pip py-setuptools jpeg-dev zlib-dev git libgit2-dev # Get application source from Github RUN git clone -b master --single-branch https://github.com/morpheus65535/bazarr.git /bazarr From d99355654196b4b59826bd1bc7f940d8ebf67ca0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Mon, 13 Nov 2017 23:58:10 -0500 Subject: [PATCH 04/55] Commented pygit2 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 4147c9e29..555ce3e28 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,7 @@ enzyme Pillow py-pretty pycountry -pygit2 +#pygit2 requests subliminal urllib3 From c9e39ad9a2d7c0748909bef1e71b328c1dbde189 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Tue, 14 Nov 2017 08:53:40 -0500 Subject: [PATCH 05/55] Trying Debian base for Docker --- Dockerfile | 4 ++-- requirements.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 221fe2fc9..98b103940 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ -FROM lsiobase/alpine.python +FROM debian EXPOSE 6767 VOLUME /tv # Update -RUN apk add --update build-base python-dev py2-pip py-setuptools jpeg-dev zlib-dev git libgit2-dev +RUN apt-get install build-base python-dev py2-pip py-setuptools jpeg-dev zlib-dev git libgit2-dev # Get application source from Github RUN git clone -b master --single-branch https://github.com/morpheus65535/bazarr.git /bazarr diff --git a/requirements.txt b/requirements.txt index 555ce3e28..4147c9e29 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,7 @@ enzyme Pillow py-pretty pycountry -#pygit2 +pygit2 requests subliminal urllib3 From 2efc13f848654cbb2ea5b00f6b3a3ea8b089abd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Tue, 14 Nov 2017 09:38:34 -0500 Subject: [PATCH 06/55] Test --- Dockerfile | 5 +++-- check_update.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 98b103940..1f21c71aa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,12 @@ -FROM debian +FROM debian:buster EXPOSE 6767 VOLUME /tv # Update -RUN apt-get install build-base python-dev py2-pip py-setuptools jpeg-dev zlib-dev git libgit2-dev +RUN apt-get update +RUN apt-get install -y build-essential python-dev python-pip python-setuptools libjpeg-dev zlib1g-dev git libgit2-dev libffi-dev # Get application source from Github RUN git clone -b master --single-branch https://github.com/morpheus65535/bazarr.git /bazarr diff --git a/check_update.py b/check_update.py index 1b39ec551..079110077 100644 --- a/check_update.py +++ b/check_update.py @@ -3,7 +3,7 @@ from get_general_settings import * import os import pygit2 -current_working_directory = os.getcwd() +current_working_directory = os.path.dirname(__file__) repository_path = pygit2.discover_repository(current_working_directory) local_repo = pygit2.Repository(repository_path) From 5026af8203d23c6bf5e972b5daef729ccf138302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Tue, 14 Nov 2017 10:03:53 -0500 Subject: [PATCH 07/55] Test --- Dockerfile | 2 +- list_subtitles.py | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1f21c71aa..9672a55b6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ RUN apt-get update RUN apt-get install -y build-essential python-dev python-pip python-setuptools libjpeg-dev zlib1g-dev git libgit2-dev libffi-dev # Get application source from Github -RUN git clone -b master --single-branch https://github.com/morpheus65535/bazarr.git /bazarr +RUN git clone -b development --single-branch https://github.com/morpheus65535/bazarr.git /bazarr VOLUME /bazarr/data diff --git a/list_subtitles.py b/list_subtitles.py index 9c24b5353..d0e5c458b 100644 --- a/list_subtitles.py +++ b/list_subtitles.py @@ -11,7 +11,7 @@ from get_general_settings import * def list_subtitles(file): languages = [] actual_subtitles = [] - if os.path.exists(file): + if os.path.exists(file.encode('utf-8')): if os.path.splitext(file)[1] == '.mkv': try: with open(file, 'rb') as f: @@ -35,7 +35,7 @@ def list_subtitles(file): def store_subtitles(file): languages = [] actual_subtitles = [] - if os.path.exists(file): + if os.path.exists(file.encode('utf-8')): if os.path.splitext(file)[1] == '.mkv': try: with open(file, 'rb') as f: @@ -125,8 +125,4 @@ def new_scan_subtitles(): c_db.close() for episode in episodes: - store_subtitles(path_replace(episode[0])) - -#full_scan_subtitles() -#new_scan_subtitles() -#list_missing_subtitles() + store_subtitles(path_replace(episode[0])) \ No newline at end of file From 789eed03d1b0dfac6aea4a6f3049c5b18575e952 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Tue, 14 Nov 2017 10:12:55 -0500 Subject: [PATCH 08/55] Test --- list_subtitles.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/list_subtitles.py b/list_subtitles.py index d0e5c458b..8b22bace0 100644 --- a/list_subtitles.py +++ b/list_subtitles.py @@ -36,6 +36,8 @@ def store_subtitles(file): languages = [] actual_subtitles = [] if os.path.exists(file.encode('utf-8')): + print file + print file.encode('utf-8') if os.path.splitext(file)[1] == '.mkv': try: with open(file, 'rb') as f: From a76a3c699651ea23cca832984d2bc3ad914b696c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Tue, 14 Nov 2017 10:14:22 -0500 Subject: [PATCH 09/55] Test --- list_subtitles.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/list_subtitles.py b/list_subtitles.py index 8b22bace0..dd7344d46 100644 --- a/list_subtitles.py +++ b/list_subtitles.py @@ -35,9 +35,9 @@ def list_subtitles(file): def store_subtitles(file): languages = [] actual_subtitles = [] + print file + print file.encode('utf-8') if os.path.exists(file.encode('utf-8')): - print file - print file.encode('utf-8') if os.path.splitext(file)[1] == '.mkv': try: with open(file, 'rb') as f: From b8663f7b63c81d9c6f65e6bc289572301fff7dc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Tue, 14 Nov 2017 10:16:51 -0500 Subject: [PATCH 10/55] Test --- list_subtitles.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/list_subtitles.py b/list_subtitles.py index dd7344d46..fa995376d 100644 --- a/list_subtitles.py +++ b/list_subtitles.py @@ -11,7 +11,7 @@ from get_general_settings import * def list_subtitles(file): languages = [] actual_subtitles = [] - if os.path.exists(file.encode('utf-8')): + if os.path.exists(file): if os.path.splitext(file)[1] == '.mkv': try: with open(file, 'rb') as f: @@ -35,9 +35,7 @@ def list_subtitles(file): def store_subtitles(file): languages = [] actual_subtitles = [] - print file - print file.encode('utf-8') - if os.path.exists(file.encode('utf-8')): + if os.path.exists(file): if os.path.splitext(file)[1] == '.mkv': try: with open(file, 'rb') as f: @@ -116,7 +114,7 @@ def series_scan_subtitles(no): c_db.close() for episode in episodes: - store_subtitles(path_replace(episode[0])) + store_subtitles(path_replace(episode[0]).encode('utf-8')) list_missing_subtitles(no) @@ -127,4 +125,4 @@ def new_scan_subtitles(): c_db.close() for episode in episodes: - store_subtitles(path_replace(episode[0])) \ No newline at end of file + store_subtitles(path_replace(episode[0]).encode('utf-8')) \ No newline at end of file From 1effedcbf6419fbdb9c10b2ca1616f8034e59a25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Tue, 14 Nov 2017 10:23:20 -0500 Subject: [PATCH 11/55] Test --- list_subtitles.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/list_subtitles.py b/list_subtitles.py index fa995376d..33078f7fc 100644 --- a/list_subtitles.py +++ b/list_subtitles.py @@ -35,6 +35,8 @@ def list_subtitles(file): def store_subtitles(file): languages = [] actual_subtitles = [] + print file + print print.encode('utf-8') if os.path.exists(file): if os.path.splitext(file)[1] == '.mkv': try: From ff11e1d6919b8b26b1af7f6e26de1a61bfd55609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Tue, 14 Nov 2017 10:24:04 -0500 Subject: [PATCH 12/55] Test --- list_subtitles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/list_subtitles.py b/list_subtitles.py index 33078f7fc..4226b5880 100644 --- a/list_subtitles.py +++ b/list_subtitles.py @@ -36,7 +36,7 @@ def store_subtitles(file): languages = [] actual_subtitles = [] print file - print print.encode('utf-8') + print file.encode('utf-8') if os.path.exists(file): if os.path.splitext(file)[1] == '.mkv': try: From 97e923e76440d992dee33e1eacca48e6a16c9032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Tue, 14 Nov 2017 10:25:53 -0500 Subject: [PATCH 13/55] Test --- list_subtitles.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/list_subtitles.py b/list_subtitles.py index 4226b5880..04e22a172 100644 --- a/list_subtitles.py +++ b/list_subtitles.py @@ -36,7 +36,6 @@ def store_subtitles(file): languages = [] actual_subtitles = [] print file - print file.encode('utf-8') if os.path.exists(file): if os.path.splitext(file)[1] == '.mkv': try: @@ -116,7 +115,7 @@ def series_scan_subtitles(no): c_db.close() for episode in episodes: - store_subtitles(path_replace(episode[0]).encode('utf-8')) + store_subtitles(path_replace(episode[0].encode('utf-8'))) list_missing_subtitles(no) @@ -127,4 +126,4 @@ def new_scan_subtitles(): c_db.close() for episode in episodes: - store_subtitles(path_replace(episode[0]).encode('utf-8')) \ No newline at end of file + store_subtitles(path_replace(episode[0].encode('utf-8'))) \ No newline at end of file From 754b05863528b19249e6e8b7b558405259b5f1cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Tue, 14 Nov 2017 10:44:07 -0500 Subject: [PATCH 14/55] Test --- list_subtitles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/list_subtitles.py b/list_subtitles.py index 04e22a172..f2e13d4ee 100644 --- a/list_subtitles.py +++ b/list_subtitles.py @@ -106,7 +106,7 @@ def full_scan_subtitles(): c_db.close() for episode in episodes: - store_subtitles(path_replace(episode[0])) + store_subtitles(path_replace(episode[0].encode('utf-8'))) def series_scan_subtitles(no): conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db')) From 5d11f61024e23b8493f89b8cbae49cbb042e96e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Tue, 14 Nov 2017 10:46:51 -0500 Subject: [PATCH 15/55] Test --- list_subtitles.py | 1 + 1 file changed, 1 insertion(+) diff --git a/list_subtitles.py b/list_subtitles.py index f2e13d4ee..290b2b293 100644 --- a/list_subtitles.py +++ b/list_subtitles.py @@ -37,6 +37,7 @@ def store_subtitles(file): actual_subtitles = [] print file if os.path.exists(file): + print "exist" if os.path.splitext(file)[1] == '.mkv': try: with open(file, 'rb') as f: From b88fba51ff4a5e167f769caca6f97b8a6198824e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Tue, 14 Nov 2017 11:06:01 -0500 Subject: [PATCH 16/55] Test --- list_subtitles.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/list_subtitles.py b/list_subtitles.py index 290b2b293..6e4d05c73 100644 --- a/list_subtitles.py +++ b/list_subtitles.py @@ -35,10 +35,8 @@ def list_subtitles(file): def store_subtitles(file): languages = [] actual_subtitles = [] - print file if os.path.exists(file): - print "exist" - if os.path.splitext(file)[1] == '.mkv': + if os.path.splitext(file)[1] == '.mkv': try: with open(file, 'rb') as f: mkv = enzyme.MKV(f) From 175095a45bd4247bc295aa8ba6ccad8862414302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Tue, 14 Nov 2017 13:37:54 -0500 Subject: [PATCH 17/55] Test --- bazarr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bazarr.py b/bazarr.py index 8a4e4fce9..457abf556 100644 --- a/bazarr.py +++ b/bazarr.py @@ -320,7 +320,7 @@ def system(): task_list = [] for job in scheduler.get_jobs(): - task_list.append([job.name, job.trigger.interval.__str__(), pretty.date(job.next_run_time.replace(tzinfo=None))]) + task_list.append([job.name, job.trigger.interval.__str__(), pretty.date(job.next_run_time)]) return template('system', tasks=tasks, logs=logs, base_url=base_url, task_list=task_list) From 1d19db607d86d446c5b3962d78b94a213c86a98b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Tue, 14 Nov 2017 14:44:39 -0500 Subject: [PATCH 18/55] Revert "Test" This reverts commit 175095a45bd4247bc295aa8ba6ccad8862414302. --- bazarr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bazarr.py b/bazarr.py index 457abf556..8a4e4fce9 100644 --- a/bazarr.py +++ b/bazarr.py @@ -320,7 +320,7 @@ def system(): task_list = [] for job in scheduler.get_jobs(): - task_list.append([job.name, job.trigger.interval.__str__(), pretty.date(job.next_run_time)]) + task_list.append([job.name, job.trigger.interval.__str__(), pretty.date(job.next_run_time.replace(tzinfo=None))]) return template('system', tasks=tasks, logs=logs, base_url=base_url, task_list=task_list) From d97f6d39312437c8a66b2aa4a3a310fde29adbf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Tue, 14 Nov 2017 14:58:27 -0500 Subject: [PATCH 19/55] Test --- bazarr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bazarr.py b/bazarr.py index 8a4e4fce9..92eb1d763 100644 --- a/bazarr.py +++ b/bazarr.py @@ -320,7 +320,7 @@ def system(): task_list = [] for job in scheduler.get_jobs(): - task_list.append([job.name, job.trigger.interval.__str__(), pretty.date(job.next_run_time.replace(tzinfo=None))]) + task_list.append([job.name, job.trigger.interval.__str__(), pretty.date(job.next_run_time.replace(tzinfo=tz))]) return template('system', tasks=tasks, logs=logs, base_url=base_url, task_list=task_list) From 200b6e0a7691720c9f2e8cb6197765d4dd89e90c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Tue, 14 Nov 2017 19:14:16 -0500 Subject: [PATCH 20/55] Revert "Test" This reverts commit d97f6d39312437c8a66b2aa4a3a310fde29adbf4. --- bazarr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bazarr.py b/bazarr.py index 92eb1d763..8a4e4fce9 100644 --- a/bazarr.py +++ b/bazarr.py @@ -320,7 +320,7 @@ def system(): task_list = [] for job in scheduler.get_jobs(): - task_list.append([job.name, job.trigger.interval.__str__(), pretty.date(job.next_run_time.replace(tzinfo=tz))]) + task_list.append([job.name, job.trigger.interval.__str__(), pretty.date(job.next_run_time.replace(tzinfo=None))]) return template('system', tasks=tasks, logs=logs, base_url=base_url, task_list=task_list) From ee9ef5e790253c29ae761aac2e2f39c449113be7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Tue, 14 Nov 2017 20:20:44 -0500 Subject: [PATCH 21/55] Updating improvement --- bazarr.py | 3 ++- check_update.py | 8 ++++++-- scheduler.py | 4 +++- views/settings.tpl | 4 ++-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/bazarr.py b/bazarr.py index 8a4e4fce9..bacf10410 100644 --- a/bazarr.py +++ b/bazarr.py @@ -302,7 +302,8 @@ def save_settings(): def check_update(): ref = request.environ['HTTP_REFERER'] - check_and_apply_update() + result = check_and_apply_update() + logging.info(result) redirect(ref) diff --git a/check_update.py b/check_update.py index 079110077..cbbe97ba3 100644 --- a/check_update.py +++ b/check_update.py @@ -15,13 +15,17 @@ def check_and_apply_update(repo=local_repo, remote_name='origin'): merge_result, _ = repo.merge_analysis(remote_id) # Up to date, do nothing if merge_result & pygit2.GIT_MERGE_ANALYSIS_UP_TO_DATE: - print 'Up to date' - return + result = 'No new version of Bazarr available.' + pass # We can just fastforward elif merge_result & pygit2.GIT_MERGE_ANALYSIS_FASTFORWARD: repo.checkout_tree(repo.get(remote_id)) master_ref = repo.lookup_reference('refs/heads/master') master_ref.set_target(remote_id) repo.head.set_target(remote_id) + result = 'Bazarr updated to latest version.' + os.execlp('python', 'python', os.path.join(os.path.dirname(__file__), 'bazarr.py')) else: raise AssertionError('Unknown merge analysis result') + + return result diff --git a/scheduler.py b/scheduler.py index 8028fd7c3..7235838a2 100644 --- a/scheduler.py +++ b/scheduler.py @@ -1,3 +1,4 @@ +from get_general_settings import * from get_series import * from get_episodes import * from get_subtitle import * @@ -6,7 +7,8 @@ from check_update import * from apscheduler.schedulers.background import BackgroundScheduler scheduler = BackgroundScheduler() -scheduler.add_job(check_and_apply_update, 'interval', hours=6, max_instances=1, coalesce=True, id='update_bazarr', name='Update bazarr from source on Github') +if automatic == 'True': + scheduler.add_job(check_and_apply_update, 'interval', hours=6, max_instances=1, coalesce=True, id='update_bazarr', name='Update bazarr from source on Github') scheduler.add_job(update_series, 'interval', minutes=1, max_instances=1, coalesce=True, id='update_series', name='Update series list from Sonarr') scheduler.add_job(add_new_episodes, 'interval', minutes=1, max_instances=1, coalesce=True, id='add_new_episodes', name='Add new episodes from Sonarr') scheduler.add_job(wanted_search_missing_subtitles, 'interval', minutes=15, max_instances=1, coalesce=True, id='wanted_search_missing_subtitles', name='Search for wanted subtitles') diff --git a/views/settings.tpl b/views/settings.tpl index 0aaa1f1d5..46a69d3ad 100644 --- a/views/settings.tpl +++ b/views/settings.tpl @@ -236,7 +236,7 @@
- + Check now and update
@@ -372,7 +372,7 @@ ; $('#settings_general_check_update').click(function(){ - window.location.href = '{{base_url}}check_update'; + window.location = '{{base_url}}check_update'; }) $('a:not(.tabs), button:not(.cancel)').click(function(){ From 6c92df08613ec1128ee1b7df00fffd8aadb30afc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Wed, 15 Nov 2017 21:07:21 -0500 Subject: [PATCH 22/55] Better error management and improvemet to tasks schduler --- Dockerfile | 2 +- README.md | 18 ++++++---- bazarr.py | 39 +++++++------------- check_update.py | 2 +- create_db.sql | 2 +- get_episodes.py | 88 ++++++++++++++++++++++++--------------------- get_series.py | 89 ++++++++++++++++++++++++---------------------- list_subtitles.py | 21 +++++------ scheduler.py | 7 ++++ views/episodes.tpl | 2 +- views/series.tpl | 20 +---------- views/system.tpl | 10 ++++++ 12 files changed, 151 insertions(+), 149 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9672a55b6..1f21c71aa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ RUN apt-get update RUN apt-get install -y build-essential python-dev python-pip python-setuptools libjpeg-dev zlib1g-dev git libgit2-dev libffi-dev # Get application source from Github -RUN git clone -b development --single-branch https://github.com/morpheus65535/bazarr.git /bazarr +RUN git clone -b master --single-branch https://github.com/morpheus65535/bazarr.git /bazarr VOLUME /bazarr/data diff --git a/README.md b/README.md index 074bc507d..105f83d24 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,9 @@ Linux: * Open your browser and go to `http://localhost:6767/` ## Docker: -* You can use [this image](https://hub.docker.com/r/morpheus65535/bazarr) to quickly build your own isolated app container. Thanks to [Linux Server](https://github.com/linuxserver) for the base image. It's based on the Linux instructions above. For more info about Docker check out the [official website](https://www.docker.com). +* You can use [this image](https://hub.docker.com/r/morpheus65535/bazarr) to quickly build your own isolated app container. It's based on the Linux instructions above. For more info about Docker check out the [official website](https://www.docker.com). + +docker create --name=bazarr -v /etc/localtime:/etc/localtime:ro -v /etc/timezone:/etc/timezone:ro -v /path/to/series/directory:/tv -v /path/to/config/directory/on/host:/bazarr/data -p 6767:6767 --restart=always morpheus65535/bazarr:latest ## First run (important to read!!!): @@ -77,12 +79,16 @@ Linux: * Configure Sonarr ip, port, base url, SSL and API key. ### 4 - In "Subliminal" tab: * Configure enabled providers and enabled languages. Enabled languages are those that you are going to be able to assign to a series later. -### 5 - Save those settings and restart Bazarr. +### 5 - Save those settings and restart (important!!!) Bazarr. + +### 6 - Wait 2 minutes + +### 7 - On the "Series" page, you should now see all your series listed with a wrench icon on yellow background. Those are the series that need to be configured. Click on those one you want to get subtitles for and select desired languages. You don't have to do this for every series but it will looks cleaner without all this yellow ;-). If you don't want any substitles for a series, just click on the wrench icon and then on "Save" without selecting anything. + +### 8 - On each series page, you should see episode files available on disk, existing subtitles and missing subtitles (in case you requested some and they aren't already existing). +* If you don't see your episodes right now, wait some more time. It take time to do the initial synchronization between Sonarr and Bazarr. -### 6 - On the "Series" page, click on "Update Series" -* You should now see all your series listed with a wrench icon on yellow background. Those are the series that need to be configured. Click on each one and select desired languages. You have to do this even if you don't want subtitles for a series. Just click on the wrench icon and then on "Save". -* When you've finished going trough all those series to configure desired languages, you have to "Update All Episodes" from the "Series" page. Don't be impatient, it will take about 1 minute by 1000 episodes Bazarr need to scan for existing internal and external subtitles. If Bazarr is accessing those episodes trough a network share, it's going to take much more longer than that. Keep in mind that Bazarr have to open each and every episode files to analyze the content. -* Once the scan is finished, you should be able to access episodes list for each series and see those missing subtitles on the wanted page. +### 9 - On "Wanted" page, you should see all the episodes who have missing subtitles. ### 10 - Have fun and keep in mind that providers may temporary refuse connection due to connection limit exceeded or problem on the provider web service. diff --git a/bazarr.py b/bazarr.py index bacf10410..e2f0a407f 100644 --- a/bazarr.py +++ b/bazarr.py @@ -41,7 +41,7 @@ c.execute("SELECT log_level FROM table_settings_general") log_level = c.fetchone() log_level = log_level[0] if log_level is None: - log_level = "WARNING" + log_level = "INFO" log_level = getattr(logging, log_level) c.close() @@ -129,30 +129,6 @@ def edit_series(no): redirect(ref) -@route(base_url + 'update_series') -def update_series_list(): - ref = request.environ['HTTP_REFERER'] - - update_series() - - redirect(ref) - -@route(base_url + 'update_all_episodes') -def update_all_episodes_list(): - ref = request.environ['HTTP_REFERER'] - - update_all_episodes() - - redirect(ref) - -@route(base_url + 'add_new_episodes') -def add_new_episodes_list(): - ref = request.environ['HTTP_REFERER'] - - add_new_episodes() - - redirect(ref) - @route(base_url + 'episodes/', method='GET') def episodes(no): conn = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db')) @@ -321,10 +297,21 @@ def system(): task_list = [] for job in scheduler.get_jobs(): - task_list.append([job.name, job.trigger.interval.__str__(), pretty.date(job.next_run_time.replace(tzinfo=None))]) + if job.trigger.__str__().startswith('interval'): + task_list.append([job.name, job.trigger.interval.__str__(), pretty.date(job.next_run_time.replace(tzinfo=None)), job.id]) + elif job.trigger.__str__().startswith('cron'): + task_list.append([job.name, job.trigger.__str__(), pretty.date(job.next_run_time.replace(tzinfo=None)), job.id]) return template('system', tasks=tasks, logs=logs, base_url=base_url, task_list=task_list) +@route(base_url + 'execute/') +def execute_task(taskid): + ref = request.environ['HTTP_REFERER'] + + execute_now(taskid) + + redirect(ref) + @route(base_url + 'remove_subtitles', method='POST') def remove_subtitles(): episodePath = request.forms.get('episodePath') diff --git a/check_update.py b/check_update.py index cbbe97ba3..9d7c84c0c 100644 --- a/check_update.py +++ b/check_update.py @@ -23,7 +23,7 @@ def check_and_apply_update(repo=local_repo, remote_name='origin'): master_ref = repo.lookup_reference('refs/heads/master') master_ref.set_target(remote_id) repo.head.set_target(remote_id) - result = 'Bazarr updated to latest version.' + result = 'Bazarr updated to latest version and restarting.' os.execlp('python', 'python', os.path.join(os.path.dirname(__file__), 'bazarr.py')) else: raise AssertionError('Unknown merge analysis result') diff --git a/create_db.sql b/create_db.sql index 57ece98ea..a29b2fdf1 100644 --- a/create_db.sql +++ b/create_db.sql @@ -40,7 +40,7 @@ CREATE TABLE "table_settings_general" ( `branch` TEXT, `auto_update` INTEGER ); -INSERT INTO `table_settings_general` (ip,port,base_url,path_mapping,log_level, branch, auto_update) VALUES ('0.0.0.0',6767,'/',Null,'WARNING','master','True'); +INSERT INTO `table_settings_general` (ip,port,base_url,path_mapping,log_level, branch, auto_update) VALUES ('0.0.0.0',6767,'/',Null,'INFO','master','True'); CREATE TABLE `table_scheduler` ( `id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE, `name` TEXT NOT NULL, diff --git a/get_episodes.py b/get_episodes.py index 880679d97..3f90747f9 100644 --- a/get_episodes.py +++ b/get_episodes.py @@ -21,6 +21,7 @@ def update_all_episodes(): base_url_sonarr = "" else: base_url_sonarr = "/" + config_sonarr[2].strip("/") + apikey_sonarr = config_sonarr[4] # Get current episodes id in DB current_episodes_db = c.execute('SELECT sonarrEpisodeId FROM table_episodes').fetchall() @@ -32,7 +33,7 @@ def update_all_episodes(): seriesIdList = c.fetchall() for seriesId in seriesIdList: # Get episodes data for a series from Sonarr - url_sonarr_api_episode = protocol_sonarr + "://" + config_sonarr[0] + ":" + str(config_sonarr[1]) + base_url_sonarr + "/api/episode?seriesId=" + str(seriesId[0]) + "&apikey=" + config_sonarr[4] + url_sonarr_api_episode = protocol_sonarr + "://" + config_sonarr[0] + ":" + str(config_sonarr[1]) + base_url_sonarr + "/api/episode?seriesId=" + str(seriesId[0]) + "&apikey=" + apikey_sonarr r = requests.get(url_sonarr_api_episode) for episode in r.json(): if episode['hasFile']: @@ -80,47 +81,52 @@ def add_new_episodes(): base_url_sonarr = "" else: base_url_sonarr = "/" + config_sonarr[2].strip("/") + apikey_sonarr = config_sonarr[4] - # Get current episodes in DB - current_episodes_db = c.execute('SELECT sonarrEpisodeId FROM table_episodes').fetchall() - current_episodes_db_list = [x[0] for x in current_episodes_db] - current_episodes_sonarr = [] - - # Get sonarrId for each series from database - c.execute("SELECT sonarrSeriesId FROM table_shows") - seriesIdList = c.fetchall() - for seriesId in seriesIdList: - # Get episodes data for a series from Sonarr - url_sonarr_api_episode = protocol_sonarr + "://" + config_sonarr[0] + ":" + str(config_sonarr[1]) + base_url_sonarr + "/api/episode?seriesId=" + str(seriesId[0]) + "&apikey=" + config_sonarr[4] - r = requests.get(url_sonarr_api_episode) - - for episode in r.json(): - if episode['hasFile']: - # Add shows in Sonarr to current shows list - current_episodes_sonarr.append(episode['id']) - - try: - c.execute('''INSERT INTO table_episodes(sonarrSeriesId, sonarrEpisodeId, title, path, season, episode) VALUES (?, ?, ?, ?, ?, ?)''', (episode['seriesId'], episode['id'], episode['title'], episode['episodeFile']['path'], episode['seasonNumber'], episode['episodeNumber'])) - except: - pass + if apikey_sonarr == None: + # Close database connection + c.close() + pass + else: + # Get current episodes in DB + current_episodes_db = c.execute('SELECT sonarrEpisodeId FROM table_episodes').fetchall() + current_episodes_db_list = [x[0] for x in current_episodes_db] + current_episodes_sonarr = [] + + # Get sonarrId for each series from database + c.execute("SELECT sonarrSeriesId FROM table_shows") + seriesIdList = c.fetchall() + for seriesId in seriesIdList: + # Get episodes data for a series from Sonarr + url_sonarr_api_episode = protocol_sonarr + "://" + config_sonarr[0] + ":" + str(config_sonarr[1]) + base_url_sonarr + "/api/episode?seriesId=" + str(seriesId[0]) + "&apikey=" + apikey_sonarr + r = requests.get(url_sonarr_api_episode) + for episode in r.json(): + if episode['hasFile']: + # Add shows in Sonarr to current shows list + current_episodes_sonarr.append(episode['id']) + + try: + c.execute('''INSERT INTO table_episodes(sonarrSeriesId, sonarrEpisodeId, title, path, season, episode) VALUES (?, ?, ?, ?, ?, ?)''', (episode['seriesId'], episode['id'], episode['title'], episode['episodeFile']['path'], episode['seasonNumber'], episode['episodeNumber'])) + except: + pass + db.commit() + + # Delete episodes not in Sonarr anymore + deleted_items = [] + for item in current_episodes_db_list: + if item not in current_episodes_sonarr: + deleted_items.append(tuple([item])) + c.executemany('DELETE FROM table_episodes WHERE sonarrEpisodeId = ?',deleted_items) + + # Commit changes to database table db.commit() - # Delete episodes not in Sonarr anymore - deleted_items = [] - for item in current_episodes_db_list: - if item not in current_episodes_sonarr: - deleted_items.append(tuple([item])) - c.executemany('DELETE FROM table_episodes WHERE sonarrEpisodeId = ?',deleted_items) - - # Commit changes to database table - db.commit() - - # Close database connection - c.close() + # Close database connection + c.close() - # Store substitles from episodes we've just added - new_scan_subtitles() - try: - list_missing_subtitles() - except: - pass + # Store substitles from episodes we've just added + new_scan_subtitles() + try: + list_missing_subtitles() + except: + pass diff --git a/get_series.py b/get_series.py index dd8875f03..07c52f924 100644 --- a/get_series.py +++ b/get_series.py @@ -9,49 +9,52 @@ def update_series(): db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db')) c = db.cursor() - # Get shows data from Sonarr - url_sonarr_api_series = url_sonarr + "/api/series?apikey=" + apikey_sonarr - r = requests.get(url_sonarr_api_series) - shows_list = [] - - # Get current shows in DB - current_shows_db = c.execute('SELECT tvdbId FROM table_shows').fetchall() - current_shows_db_list = [x[0] for x in current_shows_db] - current_shows_sonarr = [] - - # Parsing data returned from Sonarr - for show in r.json(): - try: - overview = unicode(show['overview']) - except: - overview = "" - try: - poster_big = show['images'][2]['url'].split('?')[0] - poster = os.path.splitext(poster_big)[0] + '-250' + os.path.splitext(poster_big)[1] - except: - poster = "" - try: - fanart = show['images'][0]['url'].split('?')[0] - except: - fanart = "" - - # Add shows in Sonarr to current shows list - current_shows_sonarr.append(show['tvdbId']) - - # Update or insert shows list in database table - result = c.execute('''UPDATE table_shows SET title = ?, path = ?, tvdbId = ?, sonarrSeriesId = ?, overview = ?, poster = ?, fanart = ? WHERE tvdbid = ?''', (show["title"],show["path"],show["tvdbId"],show["id"],overview,poster,fanart,show["tvdbId"])) - if result.rowcount == 0: - c.execute('''INSERT INTO table_shows(title, path, tvdbId, languages,`hearing_impaired`, sonarrSeriesId, overview, poster, fanart) 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)) - - # Delete shows not in Sonarr anymore - deleted_items = [] - for item in current_shows_db_list: - if item not in current_shows_sonarr: - deleted_items.append(tuple([item])) - c.executemany('DELETE FROM table_shows WHERE tvdbId = ?',deleted_items) - - # Commit changes to database table - db.commit() + if apikey_sonarr == None: + pass + else: + # Get shows data from Sonarr + url_sonarr_api_series = url_sonarr + "/api/series?apikey=" + apikey_sonarr + r = requests.get(url_sonarr_api_series) + shows_list = [] + + # Get current shows in DB + current_shows_db = c.execute('SELECT tvdbId FROM table_shows').fetchall() + current_shows_db_list = [x[0] for x in current_shows_db] + current_shows_sonarr = [] + + # Parsing data returned from Sonarr + for show in r.json(): + try: + overview = unicode(show['overview']) + except: + overview = "" + try: + poster_big = show['images'][2]['url'].split('?')[0] + poster = os.path.splitext(poster_big)[0] + '-250' + os.path.splitext(poster_big)[1] + except: + poster = "" + try: + fanart = show['images'][0]['url'].split('?')[0] + except: + fanart = "" + + # Add shows in Sonarr to current shows list + current_shows_sonarr.append(show['tvdbId']) + + # Update or insert shows list in database table + result = c.execute('''UPDATE table_shows SET title = ?, path = ?, tvdbId = ?, sonarrSeriesId = ?, overview = ?, poster = ?, fanart = ? WHERE tvdbid = ?''', (show["title"],show["path"],show["tvdbId"],show["id"],overview,poster,fanart,show["tvdbId"])) + if result.rowcount == 0: + c.execute('''INSERT INTO table_shows(title, path, tvdbId, languages,`hearing_impaired`, sonarrSeriesId, overview, poster, fanart) 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)) + + # Delete shows not in Sonarr anymore + deleted_items = [] + for item in current_shows_db_list: + if item not in current_shows_sonarr: + deleted_items.append(tuple([item])) + c.executemany('DELETE FROM table_shows WHERE tvdbId = ?',deleted_items) + + # Commit changes to database table + db.commit() # Close database connection db.close() diff --git a/list_subtitles.py b/list_subtitles.py index 6e4d05c73..dcda27734 100644 --- a/list_subtitles.py +++ b/list_subtitles.py @@ -68,32 +68,33 @@ def store_subtitles(file): def list_missing_subtitles(*no): query_string = '' try: - query_string = " WHERE table_episodes.sonarrSeriesId = " + str(no[0]) + query_string = " WHERE table_shows.tvdbId = " + str(no[0]) except: pass conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db')) c_db = conn_db.cursor() episodes_subtitles = c_db.execute("SELECT table_episodes.sonarrEpisodeId, table_episodes.subtitles, table_shows.languages FROM table_episodes INNER JOIN table_shows on table_episodes.sonarrSeriesId = table_shows.sonarrSeriesId" + query_string).fetchall() - - missing_subtitles_global = [] + missing_subtitles_global = [] + for episode_subtitles in episodes_subtitles: actual_subtitles = [] + actual_subtitles_list = [] desired_subtitles = [] missing_subtitles = [] if episode_subtitles[1] != None: actual_subtitles = ast.literal_eval(episode_subtitles[1]) + if episode_subtitles[2] != None: desired_subtitles = ast.literal_eval(episode_subtitles[2]) - actual_subtitles_list = [] - if desired_subtitles == None: - missing_subtitles_global.append(tuple(['[]', episode_subtitles[0]])) - else: for item in actual_subtitles: actual_subtitles_list.append(item[0]) missing_subtitles = list(set(desired_subtitles) - set(actual_subtitles_list)) - missing_subtitles_global.append(tuple([str(missing_subtitles), episode_subtitles[0]])) - + missing_subtitles_global.append(tuple([str(missing_subtitles), episode_subtitles[0]])) + else: + missing_subtitles_global.append(tuple(['[]', episode_subtitles[0]])) + c_db.executemany("UPDATE table_episodes SET missing_subtitles = ? WHERE sonarrEpisodeId = ?", (missing_subtitles_global)) + conn_db.commit() c_db.close() @@ -125,4 +126,4 @@ def new_scan_subtitles(): c_db.close() for episode in episodes: - store_subtitles(path_replace(episode[0].encode('utf-8'))) \ No newline at end of file + store_subtitles(path_replace(episode[0].encode('utf-8'))) diff --git a/scheduler.py b/scheduler.py index 7235838a2..a77e9efac 100644 --- a/scheduler.py +++ b/scheduler.py @@ -1,15 +1,22 @@ from get_general_settings import * from get_series import * from get_episodes import * +from list_subtitles import * from get_subtitle import * from check_update import * from apscheduler.schedulers.background import BackgroundScheduler +from datetime import datetime scheduler = BackgroundScheduler() if automatic == 'True': scheduler.add_job(check_and_apply_update, 'interval', hours=6, max_instances=1, coalesce=True, id='update_bazarr', name='Update bazarr from source on Github') scheduler.add_job(update_series, 'interval', minutes=1, max_instances=1, coalesce=True, id='update_series', name='Update series list from Sonarr') scheduler.add_job(add_new_episodes, 'interval', minutes=1, max_instances=1, coalesce=True, id='add_new_episodes', name='Add new episodes from Sonarr') +scheduler.add_job(update_all_episodes, 'cron', hour=4, max_instances=1, coalesce=True, id='update_all_episodes', name='Update all episodes from Sonarr') +scheduler.add_job(list_missing_subtitles, 'interval', minutes=5, max_instances=1, coalesce=True, id='list_missing_subtitles', name='Process missing subtitles for all series') scheduler.add_job(wanted_search_missing_subtitles, 'interval', minutes=15, max_instances=1, coalesce=True, id='wanted_search_missing_subtitles', name='Search for wanted subtitles') scheduler.start() + +def execute_now(taskid): + scheduler.modify_job(taskid, jobstore=None, next_run_time=datetime.now()) diff --git a/views/episodes.tpl b/views/episodes.tpl index c2a56aeb4..756d0ecd1 100644 --- a/views/episodes.tpl +++ b/views/episodes.tpl @@ -121,7 +121,7 @@ %if len(seasons) == 0:
-

No episode file available for this series.

+

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

%else: %for season in seasons: diff --git a/views/series.tpl b/views/series.tpl index 8dbe41ea8..2b3d6fe7d 100644 --- a/views/series.tpl +++ b/views/series.tpl @@ -78,12 +78,6 @@
-
- - - -
- @@ -111,7 +105,7 @@ %end %end - + + @@ -93,6 +94,11 @@ + %end @@ -173,6 +179,10 @@ icon"> .tab() ; + $('.execute').click(function(){ + window.location = '{{base_url}}execute/' + $(this).data("taskid"); + }) + $('.log').click(function(){ $("#message").html($(this).data("message")); $("#exception").html($(this).data("exception")); From 3eb17ee1ad927d6f9b7b29a8f28f6ebb493b2f20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Wed, 15 Nov 2017 21:17:51 -0500 Subject: [PATCH 23/55] Optimizing logging --- bazarr.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bazarr.py b/bazarr.py index e2f0a407f..d67613c87 100644 --- a/bazarr.py +++ b/bazarr.py @@ -34,6 +34,7 @@ from scheduler import * import logging from logging.handlers import TimedRotatingFileHandler + logger = logging.getLogger('waitress') db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db')) c = db.cursor() @@ -64,6 +65,9 @@ def configure_logging(): f = OneLineExceptionFormatter('%(asctime)s|%(levelname)s|%(message)s|', '%d/%m/%Y %H:%M:%S') fh.setFormatter(f) + logging.getLogger("enzyme").setLevel(logging.WARNING) + logging.getLogger("apscheduler").setLevel(logging.WARNING) + logging.getLogger("subliminal").setLevel(logging.WARNING) root = logging.getLogger() root.setLevel(log_level) root.addHandler(fh) From 71983f0d1ebbf0deb54937415b9a9fb94b35b119 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Wed, 15 Nov 2017 21:25:14 -0500 Subject: [PATCH 24/55] Integrating version number --- bazarr.py | 4 +++- check_update.py | 2 +- views/system.tpl | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/bazarr.py b/bazarr.py index d67613c87..b5f5e103f 100644 --- a/bazarr.py +++ b/bazarr.py @@ -1,3 +1,5 @@ +bazarr_version = '0.1.1' + from bottle import route, run, template, static_file, request, redirect import bottle bottle.debug(True) @@ -306,7 +308,7 @@ def system(): elif job.trigger.__str__().startswith('cron'): task_list.append([job.name, job.trigger.__str__(), pretty.date(job.next_run_time.replace(tzinfo=None)), job.id]) - return template('system', tasks=tasks, logs=logs, base_url=base_url, task_list=task_list) + return template('system', tasks=tasks, logs=logs, base_url=base_url, task_list=task_list, bazarr_version=bazarr_version) @route(base_url + 'execute/') def execute_task(taskid): diff --git a/check_update.py b/check_update.py index 9d7c84c0c..f4ecc2e33 100644 --- a/check_update.py +++ b/check_update.py @@ -20,7 +20,7 @@ def check_and_apply_update(repo=local_repo, remote_name='origin'): # We can just fastforward elif merge_result & pygit2.GIT_MERGE_ANALYSIS_FASTFORWARD: repo.checkout_tree(repo.get(remote_id)) - master_ref = repo.lookup_reference('refs/heads/master') + master_ref = repo.lookup_reference('refs/heads/' + branch) master_ref.set_target(remote_id) repo.head.set_target(remote_id) result = 'Bazarr updated to latest version and restarting.' diff --git a/views/system.tpl b/views/system.tpl index 2523898d5..3f9b43ffb 100644 --- a/views/system.tpl +++ b/views/system.tpl @@ -141,7 +141,7 @@ icon">
- About + Bazarr version: {{bazarr_version}}
From d5dd9098ae7c0a19f8c2d0c023949074c1b68567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Wed, 15 Nov 2017 21:37:27 -0500 Subject: [PATCH 25/55] Test --- list_subtitles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/list_subtitles.py b/list_subtitles.py index dcda27734..d4e7e063e 100644 --- a/list_subtitles.py +++ b/list_subtitles.py @@ -89,9 +89,9 @@ def list_missing_subtitles(*no): for item in actual_subtitles: actual_subtitles_list.append(item[0]) missing_subtitles = list(set(desired_subtitles) - set(actual_subtitles_list)) - missing_subtitles_global.append(tuple([str(missing_subtitles), episode_subtitles[0]])) else: missing_subtitles_global.append(tuple(['[]', episode_subtitles[0]])) + missing_subtitles_global.append(tuple([str(missing_subtitles), episode_subtitles[0]])) c_db.executemany("UPDATE table_episodes SET missing_subtitles = ? WHERE sonarrEpisodeId = ?", (missing_subtitles_global)) From aad06f946191050b04c66b72ce22acb29efaf522 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Wed, 15 Nov 2017 22:14:24 -0500 Subject: [PATCH 26/55] Bug correction --- list_subtitles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/list_subtitles.py b/list_subtitles.py index d4e7e063e..33e6a51cc 100644 --- a/list_subtitles.py +++ b/list_subtitles.py @@ -79,13 +79,13 @@ def list_missing_subtitles(*no): for episode_subtitles in episodes_subtitles: actual_subtitles = [] - actual_subtitles_list = [] desired_subtitles = [] missing_subtitles = [] if episode_subtitles[1] != None: actual_subtitles = ast.literal_eval(episode_subtitles[1]) if episode_subtitles[2] != None: desired_subtitles = ast.literal_eval(episode_subtitles[2]) + actual_subtitles_list = [] for item in actual_subtitles: actual_subtitles_list.append(item[0]) missing_subtitles = list(set(desired_subtitles) - set(actual_subtitles_list)) From 77d2a0d5d024ba3d78f26a503531f520f82d6118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Wed, 15 Nov 2017 22:31:20 -0500 Subject: [PATCH 27/55] Bug correction --- list_subtitles.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/list_subtitles.py b/list_subtitles.py index 33e6a51cc..52b9675f2 100644 --- a/list_subtitles.py +++ b/list_subtitles.py @@ -81,17 +81,17 @@ def list_missing_subtitles(*no): actual_subtitles = [] desired_subtitles = [] missing_subtitles = [] + actual_subtitles_list = [] if episode_subtitles[1] != None: actual_subtitles = ast.literal_eval(episode_subtitles[1]) - if episode_subtitles[2] != None: - desired_subtitles = ast.literal_eval(episode_subtitles[2]) - actual_subtitles_list = [] - for item in actual_subtitles: - actual_subtitles_list.append(item[0]) - missing_subtitles = list(set(desired_subtitles) - set(actual_subtitles_list)) - else: - missing_subtitles_global.append(tuple(['[]', episode_subtitles[0]])) - missing_subtitles_global.append(tuple([str(missing_subtitles), episode_subtitles[0]])) + if episode_subtitles[2] != None: + desired_subtitles = ast.literal_eval(episode_subtitles[2]) + for item in actual_subtitles: + actual_subtitles_list.append(item[0]) + missing_subtitles = list(set(desired_subtitles) - set(actual_subtitles_list)) + else: + missing_subtitles_global.append(tuple(['[]', episode_subtitles[0]])) + missing_subtitles_global.append(tuple([str(missing_subtitles), episode_subtitles[0]])) c_db.executemany("UPDATE table_episodes SET missing_subtitles = ? WHERE sonarrEpisodeId = ?", (missing_subtitles_global)) From adc525120088550efc77daceed8b16c070e6c050 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Wed, 15 Nov 2017 22:51:28 -0500 Subject: [PATCH 28/55] Test --- list_subtitles.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/list_subtitles.py b/list_subtitles.py index 52b9675f2..b222ecbc8 100644 --- a/list_subtitles.py +++ b/list_subtitles.py @@ -81,17 +81,17 @@ def list_missing_subtitles(*no): actual_subtitles = [] desired_subtitles = [] missing_subtitles = [] - actual_subtitles_list = [] if episode_subtitles[1] != None: actual_subtitles = ast.literal_eval(episode_subtitles[1]) - if episode_subtitles[2] != None: - desired_subtitles = ast.literal_eval(episode_subtitles[2]) - for item in actual_subtitles: - actual_subtitles_list.append(item[0]) - missing_subtitles = list(set(desired_subtitles) - set(actual_subtitles_list)) - else: - missing_subtitles_global.append(tuple(['[]', episode_subtitles[0]])) - missing_subtitles_global.append(tuple([str(missing_subtitles), episode_subtitles[0]])) + desired_subtitles = ast.literal_eval(episode_subtitles[2]) + actual_subtitles_list = [] + if desired_subtitles == None: + missing_subtitles_global.append(tuple(['[]', episode_subtitles[0]])) + else: + for item in actual_subtitles: + actual_subtitles_list.append(item[0]) + missing_subtitles = list(set(desired_subtitles) - set(actual_subtitles_list)) + missing_subtitles_global.append(tuple([str(missing_subtitles), episode_subtitles[0]])) c_db.executemany("UPDATE table_episodes SET missing_subtitles = ? WHERE sonarrEpisodeId = ?", (missing_subtitles_global)) From 198fd368256d53d17b0fa47a870d21c474ac7b07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Wed, 15 Nov 2017 23:27:30 -0500 Subject: [PATCH 29/55] Try to fix memory leak --- get_episodes.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/get_episodes.py b/get_episodes.py index 3f90747f9..f586d2e18 100644 --- a/get_episodes.py +++ b/get_episodes.py @@ -60,7 +60,16 @@ def update_all_episodes(): # Close database connection c.close() - + + #Cleanup variables to free memory + del current_episodes_db + del current_episodes_db_list + del seriesIdList + del r + del current_episodes_sonarr + del deleted_items + del c + # Store substitles for all episodes full_scan_subtitles() list_missing_subtitles() @@ -124,6 +133,15 @@ def add_new_episodes(): # Close database connection c.close() + #Cleanup variables to free memory + del current_episodes_db + del current_episodes_db_list + del seriesIdList + del r + del current_episodes_sonarr + del deleted_items + del c + # Store substitles from episodes we've just added new_scan_subtitles() try: From fbc136a2f177bf5a9643e767d7eb1c5353a0c61a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Wed, 15 Nov 2017 23:33:22 -0500 Subject: [PATCH 30/55] test --- get_episodes.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/get_episodes.py b/get_episodes.py index f586d2e18..cac821c0f 100644 --- a/get_episodes.py +++ b/get_episodes.py @@ -143,8 +143,8 @@ def add_new_episodes(): del c # Store substitles from episodes we've just added - new_scan_subtitles() - try: - list_missing_subtitles() - except: - pass + #new_scan_subtitles() + #try: + # list_missing_subtitles() + #except: + # pass From a7defd4e6baa3ec556ba21a554402ecb470bf917 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Wed, 15 Nov 2017 23:37:18 -0500 Subject: [PATCH 31/55] Revert "test" This reverts commit fbc136a2f177bf5a9643e767d7eb1c5353a0c61a. --- get_episodes.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/get_episodes.py b/get_episodes.py index cac821c0f..f586d2e18 100644 --- a/get_episodes.py +++ b/get_episodes.py @@ -143,8 +143,8 @@ def add_new_episodes(): del c # Store substitles from episodes we've just added - #new_scan_subtitles() - #try: - # list_missing_subtitles() - #except: - # pass + new_scan_subtitles() + try: + list_missing_subtitles() + except: + pass From e57e03da32389c1084f3cfea30403b5fde3e50ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Thu, 16 Nov 2017 05:50:52 -0500 Subject: [PATCH 32/55] Finding memory link under docker --- get_episodes.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/get_episodes.py b/get_episodes.py index f586d2e18..2387b39d0 100644 --- a/get_episodes.py +++ b/get_episodes.py @@ -2,6 +2,9 @@ import os import sqlite3 import requests +from pympler.tracker import SummaryTracker +tracker = SummaryTracker() + from get_general_settings import * from list_subtitles import * @@ -148,3 +151,4 @@ def add_new_episodes(): list_missing_subtitles() except: pass + tracker.print_diff() From d9bff60884f998dae0a0d67351b3ed09b8d3de08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Thu, 16 Nov 2017 09:22:55 -0500 Subject: [PATCH 33/55] Bug correction --- bazarr.py | 8 ++++---- get_episodes.py | 4 ---- list_subtitles.py | 5 +++-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/bazarr.py b/bazarr.py index b5f5e103f..4e54a8568 100644 --- a/bazarr.py +++ b/bazarr.py @@ -2,8 +2,8 @@ bazarr_version = '0.1.1' from bottle import route, run, template, static_file, request, redirect import bottle -bottle.debug(True) -bottle.TEMPLATES.clear() +#bottle.debug(True) +#bottle.TEMPLATES.clear() import os bottle.TEMPLATE_PATH.insert(0,os.path.join(os.path.dirname(__file__), 'views/')) @@ -67,9 +67,9 @@ def configure_logging(): f = OneLineExceptionFormatter('%(asctime)s|%(levelname)s|%(message)s|', '%d/%m/%Y %H:%M:%S') fh.setFormatter(f) - logging.getLogger("enzyme").setLevel(logging.WARNING) + logging.getLogger("enzyme").setLevel(logging.ERROR) logging.getLogger("apscheduler").setLevel(logging.WARNING) - logging.getLogger("subliminal").setLevel(logging.WARNING) + logging.getLogger("subliminal").setLevel(logging.ERROR) root = logging.getLogger() root.setLevel(log_level) root.addHandler(fh) diff --git a/get_episodes.py b/get_episodes.py index 2387b39d0..f586d2e18 100644 --- a/get_episodes.py +++ b/get_episodes.py @@ -2,9 +2,6 @@ import os import sqlite3 import requests -from pympler.tracker import SummaryTracker -tracker = SummaryTracker() - from get_general_settings import * from list_subtitles import * @@ -151,4 +148,3 @@ def add_new_episodes(): list_missing_subtitles() except: pass - tracker.print_diff() diff --git a/list_subtitles.py b/list_subtitles.py index b222ecbc8..e5c47aa03 100644 --- a/list_subtitles.py +++ b/list_subtitles.py @@ -83,6 +83,7 @@ def list_missing_subtitles(*no): missing_subtitles = [] if episode_subtitles[1] != None: actual_subtitles = ast.literal_eval(episode_subtitles[1]) + if episode_subtitles[2] != None: desired_subtitles = ast.literal_eval(episode_subtitles[2]) actual_subtitles_list = [] if desired_subtitles == None: @@ -91,7 +92,7 @@ def list_missing_subtitles(*no): for item in actual_subtitles: actual_subtitles_list.append(item[0]) missing_subtitles = list(set(desired_subtitles) - set(actual_subtitles_list)) - missing_subtitles_global.append(tuple([str(missing_subtitles), episode_subtitles[0]])) + missing_subtitles_global.append(tuple([str(missing_subtitles), episode_subtitles[0]])) c_db.executemany("UPDATE table_episodes SET missing_subtitles = ? WHERE sonarrEpisodeId = ?", (missing_subtitles_global)) @@ -118,7 +119,7 @@ def series_scan_subtitles(no): store_subtitles(path_replace(episode[0].encode('utf-8'))) list_missing_subtitles(no) - + def new_scan_subtitles(): conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db')) c_db = conn_db.cursor() From cd3f2b0721497df08540bc031818e76e498b3fc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Thu, 16 Nov 2017 09:53:12 -0500 Subject: [PATCH 34/55] Bug correction --- bazarr.py | 13 ++++++++----- views/episodes.tpl | 6 ++++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/bazarr.py b/bazarr.py index 4e54a8568..ce1d72ea4 100644 --- a/bazarr.py +++ b/bazarr.py @@ -142,7 +142,8 @@ def episodes(no): c = conn.cursor() series_details = [] - series_details = c.execute("SELECT title, overview, poster, fanart, hearing_impaired FROM table_shows WHERE sonarrSeriesId LIKE ?", (str(no),)).fetchone() + series_details = c.execute("SELECT title, overview, poster, fanart, hearing_impaired, tvdbid FROM table_shows WHERE sonarrSeriesId LIKE ?", (str(no),)).fetchone() + tvdbid = series_details[5] episodes = c.execute("SELECT title, path_substitution(path), season, episode, subtitles, sonarrSeriesId, missing_subtitles, sonarrEpisodeId FROM table_episodes WHERE sonarrSeriesId LIKE ? ORDER BY episode ASC", (str(no),)).fetchall() episodes = reversed(sorted(episodes, key=operator.itemgetter(2))) @@ -151,7 +152,7 @@ def episodes(no): seasons_list.append(list(season)) c.close() - return template('episodes', no=no, details=series_details, seasons=seasons_list, url_sonarr_short=url_sonarr_short, base_url=base_url) + return template('episodes', no=no, details=series_details, seasons=seasons_list, url_sonarr_short=url_sonarr_short, base_url=base_url, tvdbid=tvdbid) @route(base_url + 'scan_disk/', method='GET') def scan_disk(no): @@ -325,6 +326,7 @@ def remove_subtitles(): subtitlesPath = request.forms.get('subtitlesPath') sonarrSeriesId = request.forms.get('sonarrSeriesId') sonarrEpisodeId = request.forms.get('sonarrEpisodeId') + tvdbid = request.forms.get('tvdbid') try: os.remove(subtitlesPath) @@ -333,7 +335,7 @@ def remove_subtitles(): except OSError: pass store_subtitles(episodePath) - list_missing_subtitles(sonarrSeriesId) + list_missing_subtitles(tvdbid) @route(base_url + 'get_subtitle', method='POST') def get_subtitle(): @@ -344,6 +346,7 @@ def get_subtitle(): hi = request.forms.get('hi') sonarrSeriesId = request.forms.get('sonarrSeriesId') sonarrEpisodeId = request.forms.get('sonarrEpisodeId') + tvdbid = request.forms.get('tvdbid') db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db')) c = db.cursor() @@ -360,9 +363,9 @@ def get_subtitle(): if result is not None: history_log(1, sonarrSeriesId, sonarrEpisodeId, result) store_subtitles(episodePath) - list_missing_subtitles(sonarrSeriesId) + list_missing_subtitles(tvdbid) redirect(ref) except OSError: - redirect(ref + '?error=2') + pass run(host=ip, port=port, server='waitress') diff --git a/views/episodes.tpl b/views/episodes.tpl index 756d0ecd1..fcc318a77 100644 --- a/views/episodes.tpl +++ b/views/episodes.tpl @@ -221,7 +221,8 @@ language: $(this).attr("data-language"), subtitlesPath: $(this).attr("data-subtitlesPath"), sonarrSeriesId: $(this).attr("data-sonarrSeriesId"), - sonarrEpisodeId: $(this).attr("data-sonarrEpisodeId") + sonarrEpisodeId: $(this).attr("data-sonarrEpisodeId"), + tvdbid: {{tvdbid}} }; $.ajax({ url: "{{base_url}}remove_subtitles", @@ -238,7 +239,8 @@ language: $(this).attr("data-language"), hi: $(this).attr("data-hi"), sonarrSeriesId: $(this).attr("data-sonarrSeriesId"), - sonarrEpisodeId: $(this).attr("data-sonarrEpisodeId") + sonarrEpisodeId: $(this).attr("data-sonarrEpisodeId"), + tvdbid: {{tvdbid}} }; $.ajax({ url: "{{base_url}}get_subtitle", From 43abd5c3fbeafc8887447b51e6d2892f09786f5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Thu, 16 Nov 2017 11:41:49 -0500 Subject: [PATCH 35/55] Memory leak investigation --- get_subtitle.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/get_subtitle.py b/get_subtitle.py index 18e2c7baf..eb944391b 100644 --- a/get_subtitle.py +++ b/get_subtitle.py @@ -8,6 +8,8 @@ from get_general_settings import * from list_subtitles import * from utils import * +from memory_profiler import profile + # configure the cache region.configure('dogpile.cache.dbm', arguments={'filename': os.path.join(os.path.dirname(__file__), 'data/cache/cachefile.dbm')}) @@ -64,7 +66,7 @@ def wanted_download_subtitles(path): store_subtitles(path_replace(episode[0])) list_missing_subtitles(episode[3]) history_log(1, episode[3], episode[2], message) - +@profile def wanted_search_missing_subtitles(): db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db')) db.create_function("path_substitution", 1, path_replace) From e049c1902fc49a3d19fa5e2fb0f6d9a6732dd919 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Thu, 16 Nov 2017 12:03:57 -0500 Subject: [PATCH 36/55] Test --- get_subtitle.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/get_subtitle.py b/get_subtitle.py index eb944391b..5bbb76fcd 100644 --- a/get_subtitle.py +++ b/get_subtitle.py @@ -8,7 +8,8 @@ from get_general_settings import * from list_subtitles import * from utils import * -from memory_profiler import profile +from pympler.tracker import SummaryTracker +tracker = SummaryTracker() # configure the cache region.configure('dogpile.cache.dbm', arguments={'filename': os.path.join(os.path.dirname(__file__), 'data/cache/cachefile.dbm')}) @@ -78,3 +79,4 @@ def wanted_search_missing_subtitles(): for episode in data: wanted_download_subtitles(episode[0]) + tracker.print_diff() From 00aec30e15da7eedcda5941d41350f4cc98e2570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Thu, 16 Nov 2017 12:04:20 -0500 Subject: [PATCH 37/55] Test --- get_subtitle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/get_subtitle.py b/get_subtitle.py index 5bbb76fcd..44451c0c5 100644 --- a/get_subtitle.py +++ b/get_subtitle.py @@ -67,7 +67,7 @@ def wanted_download_subtitles(path): store_subtitles(path_replace(episode[0])) list_missing_subtitles(episode[3]) history_log(1, episode[3], episode[2], message) -@profile + def wanted_search_missing_subtitles(): db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db')) db.create_function("path_substitution", 1, path_replace) From 2fcfa65a310c9e56f2a75873058e484fa42c7d07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Thu, 16 Nov 2017 12:09:55 -0500 Subject: [PATCH 38/55] Test --- bazarr.py | 4 ++++ get_subtitle.py | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bazarr.py b/bazarr.py index ce1d72ea4..36c32f6e9 100644 --- a/bazarr.py +++ b/bazarr.py @@ -20,6 +20,9 @@ from io import BytesIO from fdsend import send_file import urllib +from pympler.tracker import SummaryTracker +tracker = SummaryTracker() + from init_db import * from get_languages import * from get_providers import * @@ -215,6 +218,7 @@ def wanted_search_missing_subtitles_list(): ref = request.environ['HTTP_REFERER'] wanted_search_missing_subtitles() + tracker.print_diff() redirect(ref) diff --git a/get_subtitle.py b/get_subtitle.py index 44451c0c5..18e2c7baf 100644 --- a/get_subtitle.py +++ b/get_subtitle.py @@ -8,9 +8,6 @@ from get_general_settings import * from list_subtitles import * from utils import * -from pympler.tracker import SummaryTracker -tracker = SummaryTracker() - # configure the cache region.configure('dogpile.cache.dbm', arguments={'filename': os.path.join(os.path.dirname(__file__), 'data/cache/cachefile.dbm')}) @@ -79,4 +76,3 @@ def wanted_search_missing_subtitles(): for episode in data: wanted_download_subtitles(episode[0]) - tracker.print_diff() From 185bc2a80d23684c0faa36c9249491f7e421842c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Thu, 16 Nov 2017 12:23:37 -0500 Subject: [PATCH 39/55] Test --- get_subtitle.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/get_subtitle.py b/get_subtitle.py index 18e2c7baf..c04bf20f8 100644 --- a/get_subtitle.py +++ b/get_subtitle.py @@ -76,3 +76,7 @@ def wanted_search_missing_subtitles(): for episode in data: wanted_download_subtitles(episode[0]) + + del db + del c + del data From 4ac881693728722e01097f5b15424e41b7e7fd41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Thu, 16 Nov 2017 12:46:59 -0500 Subject: [PATCH 40/55] Test --- get_subtitle.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/get_subtitle.py b/get_subtitle.py index c04bf20f8..918683c18 100644 --- a/get_subtitle.py +++ b/get_subtitle.py @@ -65,6 +65,13 @@ def wanted_download_subtitles(path): list_missing_subtitles(episode[3]) history_log(1, episode[3], episode[2], message) + del conn_db + del c_db + del episodes_details + del enabled_providers + del providers_list + del message + def wanted_search_missing_subtitles(): db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db')) db.create_function("path_substitution", 1, path_replace) From 5380e079759b88bd90247d87266e8016939090cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Thu, 16 Nov 2017 13:26:09 -0500 Subject: [PATCH 41/55] Test --- bazarr.py | 4 ---- get_subtitle.py | 7 +++++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/bazarr.py b/bazarr.py index 36c32f6e9..ce1d72ea4 100644 --- a/bazarr.py +++ b/bazarr.py @@ -20,9 +20,6 @@ from io import BytesIO from fdsend import send_file import urllib -from pympler.tracker import SummaryTracker -tracker = SummaryTracker() - from init_db import * from get_languages import * from get_providers import * @@ -218,7 +215,6 @@ def wanted_search_missing_subtitles_list(): ref = request.environ['HTTP_REFERER'] wanted_search_missing_subtitles() - tracker.print_diff() redirect(ref) diff --git a/get_subtitle.py b/get_subtitle.py index 918683c18..04fd74c97 100644 --- a/get_subtitle.py +++ b/get_subtitle.py @@ -26,6 +26,13 @@ def download_subtitle(path, language, hi, providers): except: return None + del video + del best_subtitles + del result + del downloaded_provider + del downloaded_language + del message + def series_download_subtitles(no): conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db')) c_db = conn_db.cursor() From 77162c1d48f04593d43e1c8bfb9b8085ac2c0831 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Thu, 16 Nov 2017 13:30:48 -0500 Subject: [PATCH 42/55] Test --- get_subtitle.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/get_subtitle.py b/get_subtitle.py index 04fd74c97..d16101b84 100644 --- a/get_subtitle.py +++ b/get_subtitle.py @@ -13,18 +13,18 @@ region.configure('dogpile.cache.dbm', arguments={'filename': os.path.join(os.pat def download_subtitle(path, language, hi, providers): video = scan_video(path) - best_subtitles = download_best_subtitles([video], {Language(language)}, providers=providers, hearing_impaired=hi) - try: - best_subtitle = best_subtitles[video][0] - - result = save_subtitles(video, [best_subtitle]) - downloaded_provider = str(result[0]).strip('<>').split(' ')[0][:-8] - downloaded_language = pycountry.languages.lookup(str(str(result[0]).strip('<>').split(' ')[2].strip('[]'))).name - message = downloaded_language + " subtitles downloaded from " + downloaded_provider + "." - - return message - except: - return None + #best_subtitles = download_best_subtitles([video], {Language(language)}, providers=providers, hearing_impaired=hi) + #try: + # best_subtitle = best_subtitles[video][0] + # + # result = save_subtitles(video, [best_subtitle]) + # downloaded_provider = str(result[0]).strip('<>').split(' ')[0][:-8] + # downloaded_language = pycountry.languages.lookup(str(str(result[0]).strip('<>').split(' ')[2].strip('[]'))).name + # message = downloaded_language + " subtitles downloaded from " + downloaded_provider + "." + # + # return message + #except: + # return None del video del best_subtitles From 18603ee29d4c4f59958e4c9423a8ab5cec15f851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Thu, 16 Nov 2017 13:33:37 -0500 Subject: [PATCH 43/55] Test --- get_subtitle.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/get_subtitle.py b/get_subtitle.py index d16101b84..a93902234 100644 --- a/get_subtitle.py +++ b/get_subtitle.py @@ -12,7 +12,7 @@ from utils import * region.configure('dogpile.cache.dbm', arguments={'filename': os.path.join(os.path.dirname(__file__), 'data/cache/cachefile.dbm')}) def download_subtitle(path, language, hi, providers): - video = scan_video(path) + #video = scan_video(path) #best_subtitles = download_best_subtitles([video], {Language(language)}, providers=providers, hearing_impaired=hi) #try: # best_subtitle = best_subtitles[video][0] @@ -26,12 +26,12 @@ def download_subtitle(path, language, hi, providers): #except: # return None - del video - del best_subtitles - del result - del downloaded_provider - del downloaded_language - del message + #del video + #del best_subtitles + #del result + #del downloaded_provider + #del downloaded_language + #del message def series_download_subtitles(no): conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db')) From 7d8ad0d585f0039e13ddfd981bbec8cb65990b7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Thu, 16 Nov 2017 13:35:05 -0500 Subject: [PATCH 44/55] Test --- get_subtitle.py | 1 + 1 file changed, 1 insertion(+) diff --git a/get_subtitle.py b/get_subtitle.py index a93902234..5fc977739 100644 --- a/get_subtitle.py +++ b/get_subtitle.py @@ -12,6 +12,7 @@ from utils import * region.configure('dogpile.cache.dbm', arguments={'filename': os.path.join(os.path.dirname(__file__), 'data/cache/cachefile.dbm')}) def download_subtitle(path, language, hi, providers): + pass #video = scan_video(path) #best_subtitles = download_best_subtitles([video], {Language(language)}, providers=providers, hearing_impaired=hi) #try: From 2eef8c29e77c55980803cece14bc5d8afd86174c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Thu, 16 Nov 2017 13:39:47 -0500 Subject: [PATCH 45/55] Test --- get_subtitle.py | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/get_subtitle.py b/get_subtitle.py index 5fc977739..523f080c2 100644 --- a/get_subtitle.py +++ b/get_subtitle.py @@ -12,27 +12,26 @@ from utils import * region.configure('dogpile.cache.dbm', arguments={'filename': os.path.join(os.path.dirname(__file__), 'data/cache/cachefile.dbm')}) def download_subtitle(path, language, hi, providers): - pass - #video = scan_video(path) - #best_subtitles = download_best_subtitles([video], {Language(language)}, providers=providers, hearing_impaired=hi) - #try: - # best_subtitle = best_subtitles[video][0] - # - # result = save_subtitles(video, [best_subtitle]) - # downloaded_provider = str(result[0]).strip('<>').split(' ')[0][:-8] - # downloaded_language = pycountry.languages.lookup(str(str(result[0]).strip('<>').split(' ')[2].strip('[]'))).name - # message = downloaded_language + " subtitles downloaded from " + downloaded_provider + "." - # - # return message - #except: - # return None + video = scan_video(path) + best_subtitles = download_best_subtitles([video], {Language(language)}, providers=providers, hearing_impaired=hi) + try: + best_subtitle = best_subtitles[video][0] + + result = save_subtitles(video, [best_subtitle]) + downloaded_provider = str(result[0]).strip('<>').split(' ')[0][:-8] + downloaded_language = pycountry.languages.lookup(str(str(result[0]).strip('<>').split(' ')[2].strip('[]'))).name + message = downloaded_language + " subtitles downloaded from " + downloaded_provider + "." + + return message + except: + return None - #del video - #del best_subtitles - #del result - #del downloaded_provider - #del downloaded_language - #del message + del video + del best_subtitles + del result + del downloaded_provider + del downloaded_language + del message def series_download_subtitles(no): conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db')) @@ -52,7 +51,7 @@ def series_download_subtitles(no): if message is not None: store_subtitles(path_replace(episode[0])) history_log(1, no, episode[2], message) - list_missing_subtitles(no) + #list_missing_subtitles(no) def wanted_download_subtitles(path): conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db')) From e1b972c56135548ab6e332200b2e2cb35a7dede1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Thu, 16 Nov 2017 13:42:23 -0500 Subject: [PATCH 46/55] Test --- get_subtitle.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/get_subtitle.py b/get_subtitle.py index 523f080c2..a32942540 100644 --- a/get_subtitle.py +++ b/get_subtitle.py @@ -51,26 +51,26 @@ def series_download_subtitles(no): if message is not None: store_subtitles(path_replace(episode[0])) history_log(1, no, episode[2], message) - #list_missing_subtitles(no) + list_missing_subtitles(no) def wanted_download_subtitles(path): - conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db')) - c_db = conn_db.cursor() - episodes_details = c_db.execute("SELECT table_episodes.path, table_episodes.missing_subtitles, table_episodes.sonarrEpisodeId, table_episodes.sonarrSeriesId, table_shows.hearing_impaired FROM table_episodes INNER JOIN table_shows on table_shows.sonarrSeriesId = table_episodes.sonarrSeriesId WHERE table_episodes.path = ? AND missing_subtitles != '[]'", (path_replace_reverse(path),)).fetchall() - enabled_providers = c_db.execute("SELECT name FROM table_settings_providers WHERE enabled = 1").fetchall() - c_db.close() + #conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db')) + #c_db = conn_db.cursor() + #episodes_details = c_db.execute("SELECT table_episodes.path, table_episodes.missing_subtitles, table_episodes.sonarrEpisodeId, table_episodes.sonarrSeriesId, table_shows.hearing_impaired FROM table_episodes INNER JOIN table_shows on table_shows.sonarrSeriesId = table_episodes.sonarrSeriesId WHERE table_episodes.path = ? AND missing_subtitles != '[]'", (path_replace_reverse(path),)).fetchall() + #enabled_providers = c_db.execute("SELECT name FROM table_settings_providers WHERE enabled = 1").fetchall() + #c_db.close() - providers_list = [] - for provider in enabled_providers: - providers_list.append(provider[0]) + #providers_list = [] + #for provider in enabled_providers: + # providers_list.append(provider[0]) - for episode in episodes_details: - for language in ast.literal_eval(episode[1]): - message = download_subtitle(path_replace(episode[0]), str(pycountry.languages.lookup(language).alpha_3), episode[4], providers_list) - if message is not None: - store_subtitles(path_replace(episode[0])) - list_missing_subtitles(episode[3]) - history_log(1, episode[3], episode[2], message) + #for episode in episodes_details: + # for language in ast.literal_eval(episode[1]): + # message = download_subtitle(path_replace(episode[0]), str(pycountry.languages.lookup(language).alpha_3), episode[4], providers_list) + # if message is not None: + # store_subtitles(path_replace(episode[0])) + # list_missing_subtitles(episode[3]) + # history_log(1, episode[3], episode[2], message) del conn_db del c_db From 917526340dabaeeb7c8fceb828242f3d3f0b55ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Thu, 16 Nov 2017 13:46:30 -0500 Subject: [PATCH 47/55] Test --- get_subtitle.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/get_subtitle.py b/get_subtitle.py index a32942540..74f3fcd37 100644 --- a/get_subtitle.py +++ b/get_subtitle.py @@ -54,8 +54,8 @@ def series_download_subtitles(no): list_missing_subtitles(no) def wanted_download_subtitles(path): - #conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db')) - #c_db = conn_db.cursor() + conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db')) + c_db = conn_db.cursor() #episodes_details = c_db.execute("SELECT table_episodes.path, table_episodes.missing_subtitles, table_episodes.sonarrEpisodeId, table_episodes.sonarrSeriesId, table_shows.hearing_impaired FROM table_episodes INNER JOIN table_shows on table_shows.sonarrSeriesId = table_episodes.sonarrSeriesId WHERE table_episodes.path = ? AND missing_subtitles != '[]'", (path_replace_reverse(path),)).fetchall() #enabled_providers = c_db.execute("SELECT name FROM table_settings_providers WHERE enabled = 1").fetchall() #c_db.close() From 6856cd6dd7e8c15fccbc793f1879b28e7acd14be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Thu, 16 Nov 2017 13:48:47 -0500 Subject: [PATCH 48/55] Test --- get_subtitle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/get_subtitle.py b/get_subtitle.py index 74f3fcd37..8a1c69e5f 100644 --- a/get_subtitle.py +++ b/get_subtitle.py @@ -55,7 +55,7 @@ def series_download_subtitles(no): def wanted_download_subtitles(path): conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db')) - c_db = conn_db.cursor() + #c_db = conn_db.cursor() #episodes_details = c_db.execute("SELECT table_episodes.path, table_episodes.missing_subtitles, table_episodes.sonarrEpisodeId, table_episodes.sonarrSeriesId, table_shows.hearing_impaired FROM table_episodes INNER JOIN table_shows on table_shows.sonarrSeriesId = table_episodes.sonarrSeriesId WHERE table_episodes.path = ? AND missing_subtitles != '[]'", (path_replace_reverse(path),)).fetchall() #enabled_providers = c_db.execute("SELECT name FROM table_settings_providers WHERE enabled = 1").fetchall() #c_db.close() From a39284d005fa8d2a5dd55e258a2ea50b62877c8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Thu, 16 Nov 2017 13:53:39 -0500 Subject: [PATCH 49/55] Test --- get_subtitle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/get_subtitle.py b/get_subtitle.py index 8a1c69e5f..09b6641c7 100644 --- a/get_subtitle.py +++ b/get_subtitle.py @@ -58,7 +58,7 @@ def wanted_download_subtitles(path): #c_db = conn_db.cursor() #episodes_details = c_db.execute("SELECT table_episodes.path, table_episodes.missing_subtitles, table_episodes.sonarrEpisodeId, table_episodes.sonarrSeriesId, table_shows.hearing_impaired FROM table_episodes INNER JOIN table_shows on table_shows.sonarrSeriesId = table_episodes.sonarrSeriesId WHERE table_episodes.path = ? AND missing_subtitles != '[]'", (path_replace_reverse(path),)).fetchall() #enabled_providers = c_db.execute("SELECT name FROM table_settings_providers WHERE enabled = 1").fetchall() - #c_db.close() + conn.close() #providers_list = [] #for provider in enabled_providers: From 475754a63e58827e0f42e9b4be02408bbf51d48d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Thu, 16 Nov 2017 13:55:37 -0500 Subject: [PATCH 50/55] Test --- get_subtitle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/get_subtitle.py b/get_subtitle.py index 09b6641c7..fd45f6416 100644 --- a/get_subtitle.py +++ b/get_subtitle.py @@ -58,7 +58,7 @@ def wanted_download_subtitles(path): #c_db = conn_db.cursor() #episodes_details = c_db.execute("SELECT table_episodes.path, table_episodes.missing_subtitles, table_episodes.sonarrEpisodeId, table_episodes.sonarrSeriesId, table_shows.hearing_impaired FROM table_episodes INNER JOIN table_shows on table_shows.sonarrSeriesId = table_episodes.sonarrSeriesId WHERE table_episodes.path = ? AND missing_subtitles != '[]'", (path_replace_reverse(path),)).fetchall() #enabled_providers = c_db.execute("SELECT name FROM table_settings_providers WHERE enabled = 1").fetchall() - conn.close() + conn_db.close() #providers_list = [] #for provider in enabled_providers: From 856323f02401191bac2f037972c838322de42add Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Thu, 16 Nov 2017 14:09:40 -0500 Subject: [PATCH 51/55] Test --- get_subtitle.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/get_subtitle.py b/get_subtitle.py index fd45f6416..794b8093b 100644 --- a/get_subtitle.py +++ b/get_subtitle.py @@ -55,22 +55,22 @@ def series_download_subtitles(no): def wanted_download_subtitles(path): conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db')) - #c_db = conn_db.cursor() - #episodes_details = c_db.execute("SELECT table_episodes.path, table_episodes.missing_subtitles, table_episodes.sonarrEpisodeId, table_episodes.sonarrSeriesId, table_shows.hearing_impaired FROM table_episodes INNER JOIN table_shows on table_shows.sonarrSeriesId = table_episodes.sonarrSeriesId WHERE table_episodes.path = ? AND missing_subtitles != '[]'", (path_replace_reverse(path),)).fetchall() - #enabled_providers = c_db.execute("SELECT name FROM table_settings_providers WHERE enabled = 1").fetchall() - conn_db.close() + c_db = conn_db.cursor() + episodes_details = c_db.execute("SELECT table_episodes.path, table_episodes.missing_subtitles, table_episodes.sonarrEpisodeId, table_episodes.sonarrSeriesId, table_shows.hearing_impaired FROM table_episodes INNER JOIN table_shows on table_shows.sonarrSeriesId = table_episodes.sonarrSeriesId WHERE table_episodes.path = ? AND missing_subtitles != '[]'", (path_replace_reverse(path),)).fetchall() + enabled_providers = c_db.execute("SELECT name FROM table_settings_providers WHERE enabled = 1").fetchall() + c_db.close() - #providers_list = [] - #for provider in enabled_providers: - # providers_list.append(provider[0]) + providers_list = [] + for provider in enabled_providers: + providers_list.append(provider[0]) - #for episode in episodes_details: - # for language in ast.literal_eval(episode[1]): - # message = download_subtitle(path_replace(episode[0]), str(pycountry.languages.lookup(language).alpha_3), episode[4], providers_list) - # if message is not None: - # store_subtitles(path_replace(episode[0])) - # list_missing_subtitles(episode[3]) - # history_log(1, episode[3], episode[2], message) + for episode in episodes_details: + for language in ast.literal_eval(episode[1]): + message = download_subtitle(path_replace(episode[0]), str(pycountry.languages.lookup(language).alpha_3), episode[4], providers_list) + if message is not None: + store_subtitles(path_replace(episode[0])) + list_missing_subtitles(episode[3]) + history_log(1, episode[3], episode[2], message) del conn_db del c_db From 3acc2cf8d3f119398131a8ac8ce22cd84e67225f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Fri, 17 Nov 2017 23:12:37 -0500 Subject: [PATCH 52/55] Typo --- list_subtitles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/list_subtitles.py b/list_subtitles.py index e5c47aa03..a5cd58ada 100644 --- a/list_subtitles.py +++ b/list_subtitles.py @@ -36,7 +36,7 @@ def store_subtitles(file): languages = [] actual_subtitles = [] if os.path.exists(file): - if os.path.splitext(file)[1] == '.mkv': + if os.path.splitext(file)[1] == '.mkv': try: with open(file, 'rb') as f: mkv = enzyme.MKV(f) From 5b43af7a4c33f6f0697c47436f3b15d7d478e622 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Sat, 18 Nov 2017 08:34:06 -0500 Subject: [PATCH 53/55] Unexistent variable deletion error --- get_subtitle.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/get_subtitle.py b/get_subtitle.py index 794b8093b..605a7c60a 100644 --- a/get_subtitle.py +++ b/get_subtitle.py @@ -28,10 +28,13 @@ def download_subtitle(path, language, hi, providers): del video del best_subtitles - del result - del downloaded_provider - del downloaded_language - del message + try: + del result + del downloaded_provider + del downloaded_language + del message + except: + pass def series_download_subtitles(no): conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db')) @@ -77,7 +80,10 @@ def wanted_download_subtitles(path): del episodes_details del enabled_providers del providers_list - del message + try: + del message + except: + pass def wanted_search_missing_subtitles(): db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db')) From 09cb87feeb4be108891196d409078c93e3b91381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Sun, 19 Nov 2017 22:38:06 -0500 Subject: [PATCH 54/55] System --> Scheduler fine tuning --- bazarr.py | 79 ++++++++++++++++++++++++++++++++++++++++++++++-- views/system.tpl | 2 +- 2 files changed, 78 insertions(+), 3 deletions(-) diff --git a/bazarr.py b/bazarr.py index ce1d72ea4..d3dcfcc97 100644 --- a/bazarr.py +++ b/bazarr.py @@ -302,12 +302,87 @@ def system(): for line in reversed(open(os.path.join(os.path.dirname(__file__), 'data/log/bazarr.log')).readlines()): logs.append(line.rstrip()) + def get_time_from_interval(interval): + interval_clean = interval.split('[') + interval_clean = interval_clean[1][:-1] + interval_split = interval_clean.split(':') + + text = "every " + if interval_split[0] != "0": + text = text + interval_split[0] + if interval_split[0] == "1": + text = text + " hour" + else: + text = text + " hours" + + if interval_split[2] == "00": + text = text + " and " + elif interval_split[1] != "00": + text = text + ", " + if interval_split[1] != "00": + text = text + interval_split[1].lstrip("0") + if interval_split[1].lstrip("0") == "1": + text = text + " minute" + else: + text = text + " minutes" + + if interval_split[2] != "00": + text = text + " and " + if interval_split[1] == "00": + text = text + " and " + if interval_split[2] != "00": + text = text + interval_split[2].lstrip("0") + if interval_split[2].lstrip("0") == "1": + text = text + " second" + else: + text = text + " seconds" + + return text + + def get_time_from_cron(cron): + text = "at " + hour = str(cron[5]) + minute = str(cron[6]) + second = str(cron[7]) + + if hour != "0" and hour != "*": + text = text + hour + if hour == "0" or hour == "1": + text = text + " hour" + else: + text = text + " hours" + + if minute != "*" and second != "0": + text = text + ", " + elif minute == "*" and second != "0": + text = text + " and " + elif minute != "0" and minute != "*" and second == "0": + text = text + " and " + if minute != "0" and minute != "*": + text = text + minute + if minute == "0" or minute == "1": + text = text + " minute" + else: + text = text + " minutes" + + if second != "0" and second != "*": + text = text + " and " + if second != "0" and second != "*": + text = text + second + if second == "0" or second == "1": + text = text + " second" + else: + text = text + " seconds" + + return text + + task_list = [] for job in scheduler.get_jobs(): if job.trigger.__str__().startswith('interval'): - task_list.append([job.name, job.trigger.interval.__str__(), pretty.date(job.next_run_time.replace(tzinfo=None)), job.id]) + task_list.append([job.name, get_time_from_interval(str(job.trigger)), pretty.date(job.next_run_time.replace(tzinfo=None)), job.id]) elif job.trigger.__str__().startswith('cron'): - task_list.append([job.name, job.trigger.__str__(), pretty.date(job.next_run_time.replace(tzinfo=None)), job.id]) + task_list.append([job.name, get_time_from_cron(job.trigger.fields), pretty.date(job.next_run_time.replace(tzinfo=None)), job.id]) return template('system', tasks=tasks, logs=logs, base_url=base_url, task_list=task_list, bazarr_version=bazarr_version) diff --git a/views/system.tpl b/views/system.tpl index 3f9b43ffb..7f35d7d3e 100644 --- a/views/system.tpl +++ b/views/system.tpl @@ -83,7 +83,7 @@
- + From 3c216ad8a1c0e5a0fb67df60f3bb23ade7b3ed1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Sun, 19 Nov 2017 22:49:17 -0500 Subject: [PATCH 55/55] Bug correction --- bazarr.py | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/bazarr.py b/bazarr.py index d3dcfcc97..55d549548 100644 --- a/bazarr.py +++ b/bazarr.py @@ -307,32 +307,36 @@ def system(): interval_clean = interval_clean[1][:-1] interval_split = interval_clean.split(':') + hour = interval_split[0] + minute = interval_split[1].lstrip("0") + second = interval_split[2].lstrip("0") + text = "every " - if interval_split[0] != "0": - text = text + interval_split[0] - if interval_split[0] == "1": + if hour != "0": + text = text + hour + if hour == "1": text = text + " hour" else: text = text + " hours" - if interval_split[2] == "00": - text = text + " and " - elif interval_split[1] != "00": + if minute != "" and second != "": text = text + ", " - if interval_split[1] != "00": - text = text + interval_split[1].lstrip("0") - if interval_split[1].lstrip("0") == "1": + elif minute == "" and second != "": + text = text + " and " + elif minute != "" and second == "": + text = text + " and " + if minute != "": + text = text + minute + if minute == "1": text = text + " minute" else: text = text + " minutes" - if interval_split[2] != "00": + if second != "": text = text + " and " - if interval_split[1] == "00": - text = text + " and " - if interval_split[2] != "00": - text = text + interval_split[2].lstrip("0") - if interval_split[2].lstrip("0") == "1": + if second != "": + text = text + second + if second == "1": text = text + " second" else: text = text + " seconds"
{{row[4]}}{{!"" if row[4] == None else row[4]}} <% subs_languages_list = [] @@ -200,18 +194,6 @@ }) ; - $('#update_series').click(function(){ - window.location = '{{base_url}}update_series'; - }) - - $('#update_all_episodes').click(function(){ - window.location = '{{base_url}}update_all_episodes'; - }) - - $('#add_new_episodes').click(function(){ - window.location = '{{base_url}}add_new_episodes'; - }) - $('.config').click(function(){ sessionStorage.scrolly=$(window).scrollTop(); diff --git a/views/system.tpl b/views/system.tpl index 16a1c7380..2523898d5 100644 --- a/views/system.tpl +++ b/views/system.tpl @@ -85,6 +85,7 @@ Name Interval Next Execution
{{task[0]}} {{task[1]}} {{task[2]}} +
+ +
+
NameIntervalExecution Frequency Next Execution