Added queue argument for notifications.

pull/489/head
Louis Vézina 5 years ago
parent 862aa8c29e
commit 7d823a2930

@ -28,7 +28,7 @@ def update_all_movies():
def sync_episodes():
notifications.write('Episodes sync from Sonarr started...')
notifications.write(msg='Episodes sync from Sonarr started...', queue='get_episodes')
logging.debug('BAZARR Starting episodes sync from Sonarr.')
apikey_sonarr = settings.sonarr.apikey
@ -51,7 +51,7 @@ def sync_episodes():
c.close()
for seriesId in seriesIdList:
notifications.write('Getting episodes data for this show: ' + seriesId[1])
notifications.write(msg='Getting episodes data for this show: ' + seriesId[1], queue='get_episodes')
# Get episodes data for a series from Sonarr
url_sonarr_api_episode = url_sonarr + "/api/episode?seriesId=" + str(seriesId[0]) + "&apikey=" + apikey_sonarr
try:
@ -149,7 +149,7 @@ def sync_episodes():
list_missing_subtitles()
logging.debug('BAZARR All missing subtitles updated in database.')
notifications.write('Episodes sync from Sonarr ended.')
notifications.write(msg='Episodes sync from Sonarr ended.', queue='get_episodes')
def SonarrFormatAudioCodec(audioCodec):

@ -13,7 +13,7 @@ from list_subtitles import store_subtitles_movie, list_missing_subtitles_movies
def update_movies():
notifications.write("Update movies list from Radarr is running...")
notifications.write(msg="Update movies list from Radarr is running...", queue='get_movies')
logging.debug('BAZARR Starting movie sync from Radarr.')
apikey_radarr = settings.radarr.apikey
movie_default_enabled = settings.general.getboolean('movie_default_enabled')
@ -51,7 +51,7 @@ def update_movies():
movies_to_add = []
for movie in r.json():
notifications.write("Getting data for this movie: " + movie['title'])
notifications.write(msg="Getting data for this movie: " + movie['title'], queue='get_movies')
if movie['hasFile'] is True:
if 'movieFile' in movie:
if movie["path"] != None and movie['movieFile']['relativePath'] != None:
@ -187,7 +187,7 @@ def update_movies():
list_missing_subtitles_movies()
logging.debug('BAZARR All movie missing subtitles updated in database.')
notifications.write("Update movies list from Radarr is ended.")
notifications.write(msg="Update movies list from Radarr is ended.", queue='get_movies')
def get_profile_list():

@ -13,7 +13,7 @@ from list_subtitles import list_missing_subtitles
def update_series():
notifications.write("Update series list from Sonarr is running...")
notifications.write(msg="Update series list from Sonarr is running...", queue='get_series')
apikey_sonarr = settings.sonarr.apikey
serie_default_enabled = settings.general.getboolean('serie_default_enabled')
serie_default_language = settings.general.serie_default_language
@ -54,7 +54,7 @@ def update_series():
series_to_add = []
for show in r.json():
notifications.write("Getting series data for this show: " + show['title'])
notifications.write(msg="Getting series data for this show: " + show['title'], queue='get_series')
try:
overview = unicode(show['overview'])
except:
@ -127,7 +127,7 @@ def update_series():
db.commit()
db.close()
notifications.write("Update series list from Sonarr is ended.")
notifications.write(msg="Update series list from Sonarr is ended.", queue='get_series')
def get_profile_list():

@ -413,7 +413,7 @@ def manual_download_subtitle(path, language, hi, subtitle, provider, providers_a
return None
else:
if not subtitle.is_valid():
notifications.write('No valid subtitles file found for this file: ' + path)
notifications.write(msg='No valid subtitles file found for this file: ' + path, queue='get_subtitle')
logging.exception('BAZARR No valid subtitles file found for this file: ' + path)
return
logging.debug('BAZARR Subtitles file downloaded for this file:' + path)
@ -498,7 +498,7 @@ def series_download_subtitles(no):
for episode in episodes_details:
for language in ast.literal_eval(episode[1]):
if language is not None:
notifications.write('Searching for ' + str(language_from_alpha2(language)) + ' subtitles for this episode: ' + path_replace(episode[0]))
notifications.write(msg='Searching for ' + str(language_from_alpha2(language)) + ' subtitles for this episode: ' + path_replace(episode[0]), queue='get_subtitle')
message = download_subtitle(path_replace(episode[0]), str(alpha3_from_alpha2(language)),
series_details[0], providers_list, providers_auth, str(episode[3]),
series_details[1], 'series')
@ -508,7 +508,7 @@ def series_download_subtitles(no):
send_notifications(no, episode[2], message)
list_missing_subtitles(no)
notifications.write(msg='Searching completed. Please reload the page.', type='success', duration='permanent', button='refresh')
notifications.write(msg='Searching completed. Please reload the page.', type='success', duration='permanent', button='refresh', queue='get_subtitle')
def movies_download_subtitles(no):
@ -524,7 +524,7 @@ def movies_download_subtitles(no):
for language in ast.literal_eval(movie[1]):
if language is not None:
notifications.write('Searching for ' + str(language_from_alpha2(language)) + ' subtitles for this movie: ' + path_replace_movie(movie[0]))
notifications.write(msg='Searching for ' + str(language_from_alpha2(language)) + ' subtitles for this movie: ' + path_replace_movie(movie[0]), queue='get_subtitle')
message = download_subtitle(path_replace_movie(movie[0]), str(alpha3_from_alpha2(language)), movie[4],
providers_list, providers_auth, str(movie[3]), movie[5], 'movie')
if message is not None:
@ -533,7 +533,7 @@ def movies_download_subtitles(no):
send_notifications_movie(no, message)
list_missing_subtitles_movies(no)
notifications.write(msg='Searching completed. Please reload the page.', type='success', duration='permanent', button='refresh')
notifications.write(msg='Searching completed. Please reload the page.', type='success', duration='permanent', button='refresh', queue='get_subtitle')
def wanted_download_subtitles(path):
@ -571,7 +571,7 @@ def wanted_download_subtitles(path):
if attempt[i][0] == language:
if search_active(attempt[i][1]) is True:
notifications.write(
'Searching ' + str(language_from_alpha2(language)) + ' subtitles for this episode: ' + path)
msg='Searching ' + str(language_from_alpha2(language)) + ' subtitles for this episode: ' + path, queue='get_subtitle')
message = download_subtitle(path_replace(episode[0]), str(alpha3_from_alpha2(language)),
episode[4], providers_list, providers_auth, str(episode[5]),
episode[7], 'series')
@ -619,7 +619,7 @@ def wanted_download_subtitles_movie(path):
if attempt[i][0] == language:
if search_active(attempt[i][1]) is True:
notifications.write(
'Searching ' + str(language_from_alpha2(language)) + ' subtitles for this movie: ' + path)
msg='Searching ' + str(language_from_alpha2(language)) + ' subtitles for this movie: ' + path, queue='get_subtitle')
message = download_subtitle(path_replace_movie(movie[0]), str(alpha3_from_alpha2(language)),
movie[4], providers_list, providers_auth, str(movie[5]), movie[7],
'movie')
@ -669,7 +669,7 @@ def wanted_search_missing_subtitles():
logging.info('BAZARR Finished searching for missing subtitles. Check histories for more information.')
notifications.write(msg='Searching completed. Please reload the page.', type='success', duration='permanent', button='refresh')
notifications.write(msg='Searching completed. Please reload the page.', type='success', duration='permanent', button='refresh', queue='get_subtitle')
def search_active(timestamp):

@ -30,7 +30,7 @@ def store_subtitles(file):
logging.debug('BAZARR started subtitles indexing for this file: ' + file)
actual_subtitles = []
if os.path.exists(file):
notifications.write('Analyzing this file for subtitles: ' + file)
notifications.write(msg='Analyzing this file for subtitles: ' + file, queue='list_subtitles')
if os.path.splitext(file)[1] == '.mkv':
logging.debug("BAZARR is trying to index embedded subtitles.")
try:
@ -113,7 +113,7 @@ def store_subtitles_movie(file):
logging.debug('BAZARR started subtitles indexing for this file: ' + file)
actual_subtitles = []
if os.path.exists(file):
notifications.write('Analyzing this file for subtitles: ' + file)
notifications.write(msg='Analyzing this file for subtitles: ' + file, queue='list_subtitles')
if os.path.splitext(file)[1] == '.mkv':
logging.debug("BAZARR is trying to index embedded subtitles.")
try:

@ -10,7 +10,7 @@ class Notify:
def __init__(self):
self.queue = deque(maxlen=10)
def write(self, msg, type='info', duration='temporary', button='null'):
def write(self, msg, type='info', duration='temporary', button='null', queue='main'):
"""
:param msg: The message to display.
:type msg: str
@ -20,9 +20,11 @@ class Notify:
:type duration: str
:param button: The kind of button desired that can be: null, refresh, restart
:type duration: str
:param queue: The name of the notification queue to use. Default is 'main'
:type duration: str
"""
self.queue.append(json.dumps([msg, type, duration, button]))
self.queue.append(json.dumps([msg, type, duration, button, queue]))
def read(self):
"""

@ -236,10 +236,11 @@
var type = data[1];
var duration = data[2];
var button = data[3];
var queue = data[4];
if (duration === 'temporary') {
timeout = 3000;
killer = duration;
killer = queue;
} else {
timeout = false;
killer = false;
@ -264,7 +265,7 @@
type: type,
layout: 'bottomRight',
theme: 'semanticui',
queue: duration,
queue: queue,
timeout: timeout,
killer: killer,
buttons: button,

Loading…
Cancel
Save