pull/884/head
Louis Vézina 5 years ago
parent 184b57da41
commit 8543ee1b7a

@ -12,7 +12,7 @@ class EventStream:
def __init__(self):
self.queue = deque(maxlen=100)
def write(self, type=None, series=None, episode=None, movie=None):
def write(self, type=None, action=None, series=None, episode=None, movie=None):
"""
:param type: The type of element.
:type type: str
@ -23,7 +23,7 @@ class EventStream:
:param type: The movie id.
:type type: str
"""
msg = {"type": type, "series": series, "episode": episode, "movie": movie}
msg = {"type": type, "action": action, "series": series, "episode": episode, "movie": movie}
self.queue.append("data:" + json.dumps(msg) + "\n\n")
def read(self):

@ -16,6 +16,7 @@ from database import database, dict_converter
from utils import get_sonarr_version
import six
from helper import path_replace
from SSE import event_stream
def update_series():
@ -96,7 +97,7 @@ def update_series():
'fanart': fanart,
'audio_language': profile_id_to_language((show['qualityProfileId'] if get_sonarr_version().startswith('2') else show['languageProfileId']), audio_profiles),
'sortTitle': show['sortTitle'],
'year': show['year'],
'year': str(show['year']),
'alternateTitles': alternateTitles})
else:
if serie_default_enabled is True:
@ -148,6 +149,8 @@ def update_series():
database.execute('''UPDATE table_shows SET ''' + query.keys_update + ''' WHERE sonarrSeriesId = ?''',
query.values + (updated_series['sonarrSeriesId'],))
event_stream.write(type='series', series=updated_series['sonarrSeriesId'])
# Insert new series in DB
for added_series in series_to_add:
query = dict_converter.convert(added_series)
@ -160,6 +163,8 @@ def update_series():
logging.debug('BAZARR unable to insert this series into the database:',
path_replace(added_series['path']))
event_stream.write(type='series', series=added_series['sonarrSeriesId'])
logging.debug('BAZARR All series synced from Sonarr into database.')

@ -178,6 +178,8 @@ def store_subtitles_movie(original_path, reversed_path):
logging.debug('BAZARR ended subtitles indexing for this file: ' + reversed_path)
event_stream.write(type='movie', movie=movie['radarrId'])
return actual_subtitles

@ -265,7 +265,7 @@
events.onmessage = function (event) {
var event_json = JSON.parse(event.data);
if (event_json.type === 'episode') {
rowId = $('#episodes').DataTable().row('#row_'+event_json.episode);
var rowId = $('#episodes').DataTable().row('#row_'+event_json.episode);
if (rowId.length) {
$.ajax({
url: "{{ url_for('api.episodes') }}?seriesid="+event_json.series+"&episodeid="+event_json.episode,
@ -277,6 +277,25 @@
})
}
}
if (event_json.type === 'series') {
if (event_json.series === {{id}}) {
seriesDetailsRefresh();
}
/*
var rowId = $('#episodes').DataTable().row('#row_'+event_json.episode);
if (rowId.length) {
$.ajax({
url: "{{ url_for('api.episodes') }}?seriesid="+event_json.series+"&episodeid="+event_json.episode,
async: true,
success: function (data) {
$('#episodes').DataTable().row(rowId).data(data.data[0]);
$('[data-toggle="tooltip"]').tooltip({html: true});
}
})
}
*/
}
};
function BadgesAjax() {

@ -211,41 +211,7 @@
nextSibling.innerText = fileName;
});
$.ajax({
url: "{{ url_for('api.series') }}?id={{id}}"
})
.done(function( data ) {
seriesDetails = data.data[0];
$(document).prop('title', seriesDetails['title'] + ' - Bazarr');
$('#seriesFanart').css('background-image', "url('{{ url_for('image_proxy', url='MediaCover/'+id+'/fanart.jpg') }}')");
$('#seriesPoster').attr("src","{{ url_for('image_proxy', url='MediaCover/'+id+'/poster-250.jpg') }}");
$('#seriesTitle').text(seriesDetails['title']);
if (seriesDetails['alternateTitles'].length > 0) {
$('#seriesAlternateTitles').attr("title", "Alternative Titles:<br>"+seriesDetails['alternateTitles']);
$('#seriesAlternateTitles').tooltip({html:true});
} else {
$('#seriesAlternateTitles').hide();
}
$('#seriesAudioLanguage').text(seriesDetails['audio_language'].name);
$('#seriesMappedPath').text(seriesDetails['mapped_path']);
$('#seriesFileCount').text(seriesDetails['episodeFileCount']+' files');
var languages = '';
if (seriesDetails['languages'] !== 'None') {
seriesDetails['languages'].forEach(appendFunc);
}
function appendFunc(value) {
languages = languages + '<span class="badge badge-secondary" data-toggle="tooltip" data-placement="right" title="' + value.name + '">' + value.code2 + '</span> ';
}
$('#seriesSubtitlesLanguages').html(languages);
$('#seriesHearingImpaired').text('Hearing-Impaired: '+seriesDetails['hearing_impaired']);
$('#seriesForced').text('Forced: '+seriesDetails['forced']);
$('#seriesDescription').text(seriesDetails['overview']);
});
seriesDetailsRefresh();
var table = $('#episodes').DataTable({
"processing": true,
@ -566,5 +532,42 @@
$(this).find('form')[0].reset();
});
});
function seriesDetailsRefresh() {
$.ajax({
url: "{{ url_for('api.series') }}?id={{id}}"
}).done(function (data) {
seriesDetails = data.data[0];
$(document).prop('title', seriesDetails['title'] + ' - Bazarr');
$('#seriesFanart').css('background-image', "url('{{ url_for('image_proxy', url='MediaCover/'+id+'/fanart.jpg') }}')");
$('#seriesPoster').attr("src", "{{ url_for('image_proxy', url='MediaCover/'+id+'/poster-250.jpg') }}");
$('#seriesTitle').text(seriesDetails['title']);
if (seriesDetails['alternateTitles'].length > 0) {
$('#seriesAlternateTitles').attr("title", "Alternative Titles:<br>" + seriesDetails['alternateTitles']);
$('#seriesAlternateTitles').tooltip({html: true});
} else {
$('#seriesAlternateTitles').hide();
}
$('#seriesAudioLanguage').text(seriesDetails['audio_language'].name);
$('#seriesMappedPath').text(seriesDetails['mapped_path']);
$('#seriesFileCount').text(seriesDetails['episodeFileCount'] + ' files');
var languages = '';
if (seriesDetails['languages'] !== 'None') {
seriesDetails['languages'].forEach(appendFunc);
}
function appendFunc(value) {
languages = languages + '<span class="badge badge-secondary" data-toggle="tooltip" data-placement="right" title="' + value.name + '">' + value.code2 + '</span> ';
}
$('#seriesSubtitlesLanguages').html(languages);
$('#seriesHearingImpaired').text('Hearing-Impaired: ' + seriesDetails['hearing_impaired']);
$('#seriesForced').text('Forced: ' + seriesDetails['forced']);
$('#seriesDescription').text(seriesDetails['overview']);
});
}
</script>
{% endblock tail %}

Loading…
Cancel
Save