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 @@
-
+
-
+
|
@@ -341,7 +341,7 @@
{"data": "episode"},
{"data": null,
"render": function (data) {
- return ''+data.title+'';
+ return ''+data.title+'';
}
},
{"data": null,
@@ -400,7 +400,7 @@
});
$('#episodes').on('click', '.remove_subtitles', function(e){
- $(this).tooltip('hide');
+ $(this).tooltip('dispose');
e.preventDefault();
const values = {
episodePath: $(this).attr("data-episodePath"),
@@ -423,7 +423,7 @@
});
$('#episodes').on('click', '.get_subtitle', function(e){
- $(this).tooltip('hide');
+ $(this).tooltip('dispose');
e.preventDefault();
const values = {
episodePath: $(this).attr("data-episodepath"),
@@ -741,14 +741,15 @@
}
});
- $('.episode_history').on('click', function(e){
+ $('#episodes').on('click', '.episode_history', function(e){
+ $(this).tooltip('dispose');
e.preventDefault();
- $("#episode_history_title_span").html(seriesDetails['title'] + ' - ' + $(this).data("season") + 'x' + $(this).data("episode") + ' - ' + $(this).data("episode_title"));
+ $("#episode_history_title_span").html(seriesDetails['title'] + ' - ' + $(this).data("season") + 'x' + $(this).data("episode") + ' - ' + $(this).data("episodetitle"));
- sonarrEpisodeId = $(this).data("sonarrEpisodeId");
+ sonarrEpisodeId = $(this).data("sonarrepisodeid");
- $('#episode_result').DataTable( {
+ $('#episode_history_result').DataTable( {
destroy: true,
language: {
zeroRecords: 'No History Records Found For This Episode'
@@ -761,10 +762,17 @@
processing: false,
serverSide: false,
ajax: {
- url: '/bazarr-dev/episode_history/' + sonarrEpisodeId
+ url: '{{ url_for( 'api.episodeshistory' )}}?episodeid=' + sonarrEpisodeId
},
columns: [
- { data: 'action'},
+ { data: 'action',
+ "render": function(data) {
+ if (data === 0) {return "";}
+ else if (data === 1) {return "";}
+ else if (data === 2) {return "";}
+ else if (data === 3) {return "";}
+ else if (data === 4) {return "";}
+ }},
{ data: 'language' },
{ data: 'provider' },
{ data: 'score'},
@@ -772,7 +780,7 @@
]
} );
- $('#episodeHistoryModal ')
+ $('#episodeHistoryModal')
.modal({
focus: false
});
@@ -790,8 +798,7 @@
$('#seriesTitle').text(seriesDetails['title']);
if (seriesDetails['alternateTitles'].length > 0) {
- $('#seriesAlternateTitles').attr("title", "Alternative Titles:
" + seriesDetails['alternateTitles']);
- $('#seriesAlternateTitles').tooltip({html: true});
+ $('#seriesAlternateTitles').attr("data-original-title", "Alternative Titles:
" + seriesDetails['alternateTitles']);
} else {
$('#seriesAlternateTitles').hide();
}