mirror of
https://github.com/morpheus65535/bazarr
synced 2025-03-04 10:28:15 +00:00
WIP
This commit is contained in:
parent
184b57da41
commit
8543ee1b7a
5 changed files with 68 additions and 39 deletions
|
@ -12,7 +12,7 @@ class EventStream:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.queue = deque(maxlen=100)
|
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.
|
:param type: The type of element.
|
||||||
:type type: str
|
:type type: str
|
||||||
|
@ -23,7 +23,7 @@ class EventStream:
|
||||||
:param type: The movie id.
|
:param type: The movie id.
|
||||||
:type type: str
|
: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")
|
self.queue.append("data:" + json.dumps(msg) + "\n\n")
|
||||||
|
|
||||||
def read(self):
|
def read(self):
|
||||||
|
|
|
@ -16,6 +16,7 @@ from database import database, dict_converter
|
||||||
from utils import get_sonarr_version
|
from utils import get_sonarr_version
|
||||||
import six
|
import six
|
||||||
from helper import path_replace
|
from helper import path_replace
|
||||||
|
from SSE import event_stream
|
||||||
|
|
||||||
|
|
||||||
def update_series():
|
def update_series():
|
||||||
|
@ -96,7 +97,7 @@ def update_series():
|
||||||
'fanart': fanart,
|
'fanart': fanart,
|
||||||
'audio_language': profile_id_to_language((show['qualityProfileId'] if get_sonarr_version().startswith('2') else show['languageProfileId']), audio_profiles),
|
'audio_language': profile_id_to_language((show['qualityProfileId'] if get_sonarr_version().startswith('2') else show['languageProfileId']), audio_profiles),
|
||||||
'sortTitle': show['sortTitle'],
|
'sortTitle': show['sortTitle'],
|
||||||
'year': show['year'],
|
'year': str(show['year']),
|
||||||
'alternateTitles': alternateTitles})
|
'alternateTitles': alternateTitles})
|
||||||
else:
|
else:
|
||||||
if serie_default_enabled is True:
|
if serie_default_enabled is True:
|
||||||
|
@ -148,6 +149,8 @@ def update_series():
|
||||||
database.execute('''UPDATE table_shows SET ''' + query.keys_update + ''' WHERE sonarrSeriesId = ?''',
|
database.execute('''UPDATE table_shows SET ''' + query.keys_update + ''' WHERE sonarrSeriesId = ?''',
|
||||||
query.values + (updated_series['sonarrSeriesId'],))
|
query.values + (updated_series['sonarrSeriesId'],))
|
||||||
|
|
||||||
|
event_stream.write(type='series', series=updated_series['sonarrSeriesId'])
|
||||||
|
|
||||||
# Insert new series in DB
|
# Insert new series in DB
|
||||||
for added_series in series_to_add:
|
for added_series in series_to_add:
|
||||||
query = dict_converter.convert(added_series)
|
query = dict_converter.convert(added_series)
|
||||||
|
@ -160,6 +163,8 @@ def update_series():
|
||||||
logging.debug('BAZARR unable to insert this series into the database:',
|
logging.debug('BAZARR unable to insert this series into the database:',
|
||||||
path_replace(added_series['path']))
|
path_replace(added_series['path']))
|
||||||
|
|
||||||
|
event_stream.write(type='series', series=added_series['sonarrSeriesId'])
|
||||||
|
|
||||||
logging.debug('BAZARR All series synced from Sonarr into database.')
|
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)
|
logging.debug('BAZARR ended subtitles indexing for this file: ' + reversed_path)
|
||||||
|
|
||||||
|
event_stream.write(type='movie', movie=movie['radarrId'])
|
||||||
|
|
||||||
return actual_subtitles
|
return actual_subtitles
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -265,7 +265,7 @@
|
||||||
events.onmessage = function (event) {
|
events.onmessage = function (event) {
|
||||||
var event_json = JSON.parse(event.data);
|
var event_json = JSON.parse(event.data);
|
||||||
if (event_json.type === 'episode') {
|
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) {
|
if (rowId.length) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "{{ url_for('api.episodes') }}?seriesid="+event_json.series+"&episodeid="+event_json.episode,
|
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() {
|
function BadgesAjax() {
|
||||||
|
|
|
@ -211,41 +211,7 @@
|
||||||
nextSibling.innerText = fileName;
|
nextSibling.innerText = fileName;
|
||||||
});
|
});
|
||||||
|
|
||||||
$.ajax({
|
seriesDetailsRefresh();
|
||||||
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']);
|
|
||||||
});
|
|
||||||
|
|
||||||
var table = $('#episodes').DataTable({
|
var table = $('#episodes').DataTable({
|
||||||
"processing": true,
|
"processing": true,
|
||||||
|
@ -566,5 +532,42 @@
|
||||||
$(this).find('form')[0].reset();
|
$(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>
|
</script>
|
||||||
{% endblock tail %}
|
{% endblock tail %}
|
||||||
|
|
Loading…
Add table
Reference in a new issue