From 49c93780bf726f9342fcbd8abe9be8cec9576b60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Wed, 22 Jan 2020 23:10:33 -0500 Subject: [PATCH] WIP --- bazarr/api.py | 23 +++++++++++++++++++++++ bazarr/main.py | 19 ------------------- views/episodes.html | 37 ++++++++++++++++++++++--------------- 3 files changed, 45 insertions(+), 34 deletions(-) diff --git a/bazarr/api.py b/bazarr/api.py index b3440c22c..80538ab93 100644 --- a/bazarr/api.py +++ b/bazarr/api.py @@ -4,6 +4,7 @@ import libs from datetime import timedelta import datetime import pretty +import time from get_args import args from config import settings, base_url @@ -376,6 +377,27 @@ class EpisodesSearchMissing(Resource): return '', 200 +class EpisodesHistory(Resource): + def get(self): + episodeid = request.args.get('episodeid') + + episode_history = database.execute("SELECT action, timestamp, language, provider, score FROM table_history " + "WHERE sonarrEpisodeId=? ORDER BY timestamp DESC", (episodeid,)) + for item in episode_history: + item['timestamp'] = "
" + \ + pretty.date(datetime.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 jsonify(data=episode_history) + + class Movies(Resource): def get(self): start = request.args.get('start') or 0 @@ -691,6 +713,7 @@ api.add_resource(EpisodesSubtitlesManualDownload, '/episodes_subtitles_manual_do api.add_resource(EpisodesSubtitlesUpload, '/episodes_subtitles_upload') api.add_resource(EpisodesScanDisk, '/episodes_scan_disk') api.add_resource(EpisodesSearchMissing, '/episodes_search_missing') +api.add_resource(EpisodesHistory, '/episodes_history') api.add_resource(Movies, '/movies') api.add_resource(HistorySeries, '/history_series') api.add_resource(HistoryMovies, '/history_movies') diff --git a/bazarr/main.py b/bazarr/main.py index 600fb69f5..8e7363103 100644 --- a/bazarr/main.py +++ b/bazarr/main.py @@ -1637,25 +1637,6 @@ def episode_history(no): 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'])) + "
" diff --git a/views/episodes.html b/views/episodes.html index c1832b8bf..f76c06748 100644 --- a/views/episodes.html +++ b/views/episodes.html @@ -67,7 +67,7 @@

- +
@@ -264,7 +264,7 @@
-