pull/884/head
Louis Vézina 5 years ago
parent b0c82174be
commit 49c93780bf

@ -4,6 +4,7 @@ import libs
from datetime import timedelta from datetime import timedelta
import datetime import datetime
import pretty import pretty
import time
from get_args import args from get_args import args
from config import settings, base_url from config import settings, base_url
@ -376,6 +377,27 @@ class EpisodesSearchMissing(Resource):
return '', 200 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'] = "<div title='" + \
time.strftime('%d/%m/%Y %H:%M:%S', time.localtime(item['timestamp'])) + \
"' data-toggle='tooltip' data-placement='left'>" + \
pretty.date(datetime.datetime.fromtimestamp(item['timestamp'])) + "</div>"
if item['language']:
item['language'] = language_from_alpha2(item['language'])
else:
item['language'] = "<i>undefined</i>"
if item['score']:
item['score'] = str(round((int(item['score']) * 100 / 360), 2)) + "%"
return jsonify(data=episode_history)
class Movies(Resource): class Movies(Resource):
def get(self): def get(self):
start = request.args.get('start') or 0 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(EpisodesSubtitlesUpload, '/episodes_subtitles_upload')
api.add_resource(EpisodesScanDisk, '/episodes_scan_disk') api.add_resource(EpisodesScanDisk, '/episodes_scan_disk')
api.add_resource(EpisodesSearchMissing, '/episodes_search_missing') api.add_resource(EpisodesSearchMissing, '/episodes_search_missing')
api.add_resource(EpisodesHistory, '/episodes_history')
api.add_resource(Movies, '/movies') api.add_resource(Movies, '/movies')
api.add_resource(HistorySeries, '/history_series') api.add_resource(HistorySeries, '/history_series')
api.add_resource(HistoryMovies, '/history_movies') api.add_resource(HistoryMovies, '/history_movies')

@ -1637,25 +1637,6 @@ def episode_history(no):
episode_history = database.execute("SELECT action, timestamp, language, provider, score FROM table_history " episode_history = database.execute("SELECT action, timestamp, language, provider, score FROM table_history "
"WHERE sonarrEpisodeId=? ORDER BY timestamp DESC", (no,)) "WHERE sonarrEpisodeId=? ORDER BY timestamp DESC", (no,))
for item in episode_history: for item in episode_history:
if item['action'] == 0:
item['action'] = "<div class ='ui inverted basic compact icon' data-tooltip='Subtitle file has been " \
"erased.' data-inverted='' data-position='top left'><i class='ui trash icon'></i></div>"
elif item['action'] == 1:
item['action'] = "<div class ='ui inverted basic compact icon' data-tooltip='Subtitle file has been " \
"downloaded.' data-inverted='' data-position='top left'><i class='ui download " \
"icon'></i></div>"
elif item['action'] == 2:
item['action'] = "<div class ='ui inverted basic compact icon' data-tooltip='Subtitle file has been " \
"manually downloaded.' data-inverted='' data-position='top left'><i class='ui user " \
"icon'></i></div>"
elif item['action'] == 3:
item['action'] = "<div class ='ui inverted basic compact icon' data-tooltip='Subtitle file has been " \
"upgraded.' data-inverted='' data-position='top left'><i class='ui recycle " \
"icon'></i></div>"
elif item['action'] == 4:
item['action'] = "<div class ='ui inverted basic compact icon' data-tooltip='Subtitle file has been " \
"manually uploaded.' data-inverted='' data-position='top left'><i class='ui cloud " \
"upload icon'></i></div>"
item['timestamp'] = "<div data-tooltip='" + \ item['timestamp'] = "<div data-tooltip='" + \
time.strftime('%d/%m/%Y %H:%M:%S', time.localtime(item['timestamp'])) + "'>" + \ time.strftime('%d/%m/%Y %H:%M:%S', time.localtime(item['timestamp'])) + "'>" + \
pretty.date(datetime.fromtimestamp(item['timestamp'])) + "</div>" pretty.date(datetime.fromtimestamp(item['timestamp'])) + "</div>"

@ -67,7 +67,7 @@
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<h1><span id="seriesTitle"></span></h1> <h1><span id="seriesTitle"></span></h1>
<i class="far fa-clone" id="seriesAlternateTitles" data-toggle="tooltip" data-placement="right"></i> <i class="far fa-clone" id="seriesAlternateTitles" data-toggle="tooltip" data-placement="right" title="None" data-html="true"></i>
</div> </div>
<div class="row"> <div class="row">
<h5><span id="seriesAudioLanguage" class="badge badge-secondary"></span></h5> <h5><span id="seriesAudioLanguage" class="badge badge-secondary"></span></h5>
@ -264,7 +264,7 @@
</div> </div>
</div> </div>
<div id="episodeHistoryModal " class="modal" tabindex="-1" role="dialog"> <div id="episodeHistoryModal" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document"> <div class="modal-dialog modal-lg" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
@ -275,7 +275,7 @@
</div> </div>
<div class="modal-body"> <div class="modal-body">
<div class="container-fluid"> <div class="container-fluid">
<table id="episode_result" class="display" style="width:100%"> <table id="episode_history_result" class="table table-striped">
<thead> <thead>
<tr> <tr>
<th></th> <th></th>
@ -341,7 +341,7 @@
{"data": "episode"}, {"data": "episode"},
{"data": null, {"data": null,
"render": function (data) { "render": function (data) {
return '<a href="" data-season='+data.season+' data-episode='+data.episode+' data-episode_title="'+data.title+'" data-sonarrEpisodeId='+data.sonarrEpisodeId+' class="episode_history">'+data.title+'</a>'; return '<a href="" data-toggle="tooltip" title="Path is: '+data.mapped_path+'" data-season='+data.season+' data-episode='+data.episode+' data-episodeTitle="'+data.title+'" data-sonarrEpisodeId='+data.sonarrEpisodeId+' class="episode_history">'+data.title+'</a>';
} }
}, },
{"data": null, {"data": null,
@ -400,7 +400,7 @@
}); });
$('#episodes').on('click', '.remove_subtitles', function(e){ $('#episodes').on('click', '.remove_subtitles', function(e){
$(this).tooltip('hide'); $(this).tooltip('dispose');
e.preventDefault(); e.preventDefault();
const values = { const values = {
episodePath: $(this).attr("data-episodePath"), episodePath: $(this).attr("data-episodePath"),
@ -423,7 +423,7 @@
}); });
$('#episodes').on('click', '.get_subtitle', function(e){ $('#episodes').on('click', '.get_subtitle', function(e){
$(this).tooltip('hide'); $(this).tooltip('dispose');
e.preventDefault(); e.preventDefault();
const values = { const values = {
episodePath: $(this).attr("data-episodepath"), 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(); 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, destroy: true,
language: { language: {
zeroRecords: 'No History Records Found For This Episode' zeroRecords: 'No History Records Found For This Episode'
@ -761,10 +762,17 @@
processing: false, processing: false,
serverSide: false, serverSide: false,
ajax: { ajax: {
url: '/bazarr-dev/episode_history/' + sonarrEpisodeId url: '{{ url_for( 'api.episodeshistory' )}}?episodeid=' + sonarrEpisodeId
}, },
columns: [ columns: [
{ data: 'action'}, { data: 'action',
"render": function(data) {
if (data === 0) {return "<i class='fas fa-trash' title='Subtitle file has been erased.' data-toggle='tooltip' data-placement='right'></i>";}
else if (data === 1) {return "<i class='fas fa-download' title='Subtitle file has been downloaded.' data-toggle='tooltip' data-placement='right'></i>";}
else if (data === 2) {return "<i class='fas fa-user' title='Subtitle file has been manually downloaded.' data-toggle='tooltip' data-placement='right'></i>";}
else if (data === 3) {return "<i class='fas fa-recycle' title='Subtitle file has been upgraded.' data-toggle='tooltip' data-placement='right'></i>";}
else if (data === 4) {return "<i class='fas fa-cloud-upload-alt' title='Subtitle file has been manually uploaded.' data-toggle='tooltip' data-placement='right'></i>";}
}},
{ data: 'language' }, { data: 'language' },
{ data: 'provider' }, { data: 'provider' },
{ data: 'score'}, { data: 'score'},
@ -772,7 +780,7 @@
] ]
} ); } );
$('#episodeHistoryModal ') $('#episodeHistoryModal')
.modal({ .modal({
focus: false focus: false
}); });
@ -790,8 +798,7 @@
$('#seriesTitle').text(seriesDetails['title']); $('#seriesTitle').text(seriesDetails['title']);
if (seriesDetails['alternateTitles'].length > 0) { if (seriesDetails['alternateTitles'].length > 0) {
$('#seriesAlternateTitles').attr("title", "Alternative Titles:<br>" + seriesDetails['alternateTitles']); $('#seriesAlternateTitles').attr("data-original-title", "<b>Alternative Titles:</b><br>" + seriesDetails['alternateTitles']);
$('#seriesAlternateTitles').tooltip({html: true});
} else { } else {
$('#seriesAlternateTitles').hide(); $('#seriesAlternateTitles').hide();
} }

Loading…
Cancel
Save