From d32b65e1e029b9c2a997faf4467d58f737f2c706 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Tue, 19 Nov 2019 22:01:34 -0500 Subject: [PATCH 1/3] Fix to reduce analytics hits. --- bazarr/analytics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bazarr/analytics.py b/bazarr/analytics.py index 30d509baf..264a9c91c 100644 --- a/bazarr/analytics.py +++ b/bazarr/analytics.py @@ -52,7 +52,7 @@ def track_event(category=None, action=None, label=None): try: tracker.track_event(event, session, visitor) - tracker.track_pageview(page, session, visitor) + # tracker.track_pageview(page, session, visitor) ## Commented because we were having too much hits on GA. except: pass else: From 2d5eb867d951c18b6be16cf5e13d746f62f8b8a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Tue, 19 Nov 2019 22:02:08 -0500 Subject: [PATCH 2/3] Version bump. --- bazarr/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bazarr/main.py b/bazarr/main.py index e66681afa..4837500e0 100644 --- a/bazarr/main.py +++ b/bazarr/main.py @@ -1,6 +1,6 @@ # coding=utf-8 -bazarr_version = '0.8.3.3' +bazarr_version = '0.8.3.4' import os os.environ["SZ_USER_AGENT"] = "Bazarr/1" From a9bf2ee8e4539158b50048e3a2e014b045fe18a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Tue, 19 Nov 2019 22:02:59 -0500 Subject: [PATCH 3/3] Added history modal for episode and tab for movie. --- bazarr/main.py | 86 +++++++++++++++- views/episodes.tpl | 72 +++++++++++++- views/movie.tpl | 238 ++++++++++++++++++++++++++++----------------- 3 files changed, 301 insertions(+), 95 deletions(-) diff --git a/bazarr/main.py b/bazarr/main.py index 4837500e0..8b9f2ed1c 100644 --- a/bazarr/main.py +++ b/bazarr/main.py @@ -42,7 +42,8 @@ from beaker.middleware import SessionMiddleware from cork import Cork from bottle import route, template, static_file, request, redirect, response, HTTPError, app, hook from datetime import timedelta -from get_languages import load_language_in_db, language_from_alpha3 +from get_languages import load_language_in_db, language_from_alpha3, language_from_alpha2, alpha2_from_alpha3 + from get_providers import get_providers, get_providers_auth, list_throttled_providers from get_series import * from get_episodes import * @@ -1729,7 +1730,7 @@ def remove_subtitles(): try: os.remove(subtitlesPath) result = language_from_alpha3(language) + " subtitles deleted from disk." - history_log(0, sonarrSeriesId, sonarrEpisodeId, result) + history_log(0, sonarrSeriesId, sonarrEpisodeId, result, language=alpha2_from_alpha3(language)) except OSError as e: logging.exception('BAZARR cannot delete subtitles file: ' + subtitlesPath) store_subtitles(unicode(episodePath)) @@ -1747,7 +1748,7 @@ def remove_subtitles_movie(): try: os.remove(subtitlesPath) result = language_from_alpha3(language) + " subtitles deleted from disk." - history_log_movie(0, radarrId, result) + history_log_movie(0, radarrId, result, language=alpha2_from_alpha3(language)) except OSError as e: logging.exception('BAZARR cannot delete subtitles file: ' + subtitlesPath) store_subtitles_movie(unicode(moviePath)) @@ -2127,6 +2128,85 @@ def running_tasks_list(): return dict(tasks=running_tasks) +@route(base_url + 'episode_history/') +@custom_auth_basic(check_credentials) +def episode_history(no): + authorize() + episode_history = database.execute("SELECT action, timestamp, language, provider, score FROM table_history " + "WHERE sonarrEpisodeId=? ORDER BY timestamp DESC", (no,)) + for item in episode_history: + if item['action'] == 0: + item['action'] = "
" + elif item['action'] == 1: + item['action'] = "
" + elif item['action'] == 2: + item['action'] = "
" + elif item['action'] == 3: + item['action'] = "
" + elif item['action'] == 4: + item['action'] = "
" + item['timestamp'] = "
" + \ + pretty.date(datetime.fromtimestamp(item['timestamp'])) + "
" + if item['language']: + item['language'] = language_from_alpha2(item['language']) + else: + item['language'] = "undefined" + if item['score']: + item['score'] = str(round((int(item['score']) * 100 / 360), 2)) + "%" + + return dict(data=episode_history) + + +@route(base_url + 'movie_history/') +@custom_auth_basic(check_credentials) +def movie_history(no): + authorize() + movie_history = database.execute("SELECT action, timestamp, language, provider, score FROM table_history_movie " + "WHERE radarrId=? ORDER BY timestamp DESC", (no,)) + for item in movie_history: + if item['action'] == 0: + item['action'] = "
" + elif item['action'] == 1: + item['action'] = "
" + elif item['action'] == 2: + item['action'] = "
" + elif item['action'] == 3: + item['action'] = "
" + elif item['action'] == 4: + item['action'] = "
" + + item['timestamp'] = "
" + \ + pretty.date(datetime.fromtimestamp(item['timestamp'])) + "
" + if item['language']: + item['language'] = language_from_alpha2(item['language']) + else: + item['language'] = "undefined" + if item['score']: + item['score'] = str(round((int(item['score']) * 100 / 120), 2)) + '%' + + return dict(data=movie_history) + + # Mute DeprecationWarning warnings.simplefilter("ignore", DeprecationWarning) server = CherryPyWSGIServer((str(settings.general.ip), (int(args.port) if args.port else int(settings.general.port))), app) diff --git a/views/episodes.tpl b/views/episodes.tpl index 949788a39..9567098d9 100644 --- a/views/episodes.tpl +++ b/views/episodes.tpl @@ -217,7 +217,7 @@ % if episode['scene_name'] is not None: % end - {{episode['title']}} + {{episode['title']}} %if episode['subtitles'] is not None: @@ -379,6 +379,29 @@ + + +
+
+ + + + + + + + + + +
Language.:Provider:Score:Date:
+
+
@@ -420,6 +444,9 @@