diff --git a/bazarr/analytics.py b/bazarr/analytics.py index 8097c6719..66157ece8 100644 --- a/bazarr/analytics.py +++ b/bazarr/analytics.py @@ -53,7 +53,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: diff --git a/bazarr/main.py b/bazarr/main.py index 5eda8c3f8..51d26c254 100644 --- a/bazarr/main.py +++ b/bazarr/main.py @@ -47,7 +47,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 * @@ -1738,7 +1739,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(path_replace_reverse(episodePath), episodePath) @@ -1756,7 +1757,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(path_replace_reverse_movie(moviePath), moviePath) @@ -2136,6 +2137,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 7131826f3..3b928335b 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 @@