From 20e10d6720b1c977382dbdd78ba3ae7457f97417 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Thu, 4 Apr 2019 15:04:06 -0400
Subject: [PATCH 1/5] Notification progress bar.
---
bazarr/get_episodes.py | 9 ++++-----
bazarr/queueconfig.py | 10 +++++++---
views/menu.tpl | 17 ++++++++++++++++-
3 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/bazarr/get_episodes.py b/bazarr/get_episodes.py
index 49ddc0a4c..c5fc868e8 100644
--- a/bazarr/get_episodes.py
+++ b/bazarr/get_episodes.py
@@ -49,9 +49,10 @@ def sync_episodes():
# Close database connection
c.close()
-
- for seriesId in seriesIdList:
- notifications.write(msg='Getting episodes data for this show: ' + seriesId[1], queue='get_episodes')
+
+ seriesIdListLength = len(seriesIdList)
+ for i, seriesId in enumerate(seriesIdList, 1):
+ notifications.write(msg='Getting episodes data from Sonarr...', queue='get_episodes', item=i, length=seriesIdListLength)
# Get episodes data for a series from Sonarr
url_sonarr_api_episode = url_sonarr + "/api/episode?seriesId=" + str(seriesId[0]) + "&apikey=" + apikey_sonarr
try:
@@ -151,8 +152,6 @@ def sync_episodes():
list_missing_subtitles()
logging.debug('BAZARR All missing subtitles updated in database.')
-
- notifications.write(msg='Episodes sync from Sonarr ended.', queue='get_episodes')
def SonarrFormatAudioCodec(audioCodec):
diff --git a/bazarr/queueconfig.py b/bazarr/queueconfig.py
index df81d0c2d..ad33e3218 100644
--- a/bazarr/queueconfig.py
+++ b/bazarr/queueconfig.py
@@ -10,7 +10,7 @@ class Notify:
def __init__(self):
self.queue = deque(maxlen=10)
- def write(self, msg, type='info', duration='temporary', button='null', queue='main'):
+ def write(self, msg, type='info', duration='temporary', button='null', queue='main', item=0, length=0):
"""
:param msg: The message to display.
:type msg: str
@@ -19,12 +19,16 @@ class Notify:
:param duration: The duration of the notification that can be: temporary, permanent
:type duration: str
:param button: The kind of button desired that can be: null, refresh, restart
- :type duration: str
+ :type button: str
:param queue: The name of the notification queue to use. Default is 'main'
:type duration: str
+ :param item: The number of the item for progress bar
+ :type item: int
+ :param length: The length of the group of item for progress bar
+ :type length: int
"""
- self.queue.append(json.dumps([msg, type, duration, button, queue]))
+ self.queue.append(json.dumps([msg, type, duration, button, queue, item, length]))
def read(self):
"""
diff --git a/views/menu.tpl b/views/menu.tpl
index 4dfdc9f1b..84dc6876b 100644
--- a/views/menu.tpl
+++ b/views/menu.tpl
@@ -250,6 +250,14 @@
var duration = data[2];
var button = data[3];
var queue = data[4];
+ var item = data[5];
+ var length = data[6];
+
+ if (length === 0) {
+ var message = msg;
+ } else {
+ var message = msg + '
'
+ }
if (duration === 'temporary') {
timeout = 3000;
@@ -269,7 +277,7 @@
}
new Noty({
- text: msg,
+ text: message,
progressBar: false,
animation: {
open: null,
@@ -284,6 +292,13 @@
buttons: button,
force: true
}).show();
+
+ $('.notification_progress').progress({
+ duration : 0,
+ autoSuccess: false,
+ value : item,
+ total : length
+ });
}
},
complete: function (data) {
From 9e1c8718336801b26c9997fd3cf15a3f6f9f4b60 Mon Sep 17 00:00:00 2001
From: Halali
Date: Fri, 5 Apr 2019 00:33:49 +0200
Subject: [PATCH 2/5] Add more progress notifications
---
bazarr/get_subtitle.py | 36 ++++++++++++++++++++----------------
1 file changed, 20 insertions(+), 16 deletions(-)
diff --git a/bazarr/get_subtitle.py b/bazarr/get_subtitle.py
index 1e617e020..315810702 100644
--- a/bazarr/get_subtitle.py
+++ b/bazarr/get_subtitle.py
@@ -448,10 +448,12 @@ def series_download_subtitles(no):
providers_list = get_providers()
providers_auth = get_providers_auth()
- for episode in episodes_details:
+ count_episodes_details = len(episodes_details)
+
+ for i, episode in enumerate(episodes_details, 1):
for language in ast.literal_eval(episode[1]):
if language is not None:
- notifications.write(msg='Searching for ' + str(language_from_alpha2(language)) + ' subtitles for this episode: ' + path_replace(episode[0]), queue='get_subtitle')
+ notifications.write(msg='Searching for series subtitles : ' + str(i) + '/' + str(count_episodes_details), queue='get_subtitle', duration='long', item=i, length=count_episodes_details)
result = 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')
@@ -480,9 +482,11 @@ def movies_download_subtitles(no):
providers_list = get_providers()
providers_auth = get_providers_auth()
- for language in ast.literal_eval(movie[1]):
+ count_movie = len(ast.literal_eval(movie[1]))
+
+ for i, language in enumerate(ast.literal_eval(movie[1]), 1):
if language is not None:
- notifications.write(msg='Searching for ' + str(language_from_alpha2(language)) + ' subtitles for this movie: ' + path_replace_movie(movie[0]), queue='get_subtitle')
+ notifications.write(msg='Searching for movies subtitles : ' + str(i) + '/' + str(count_movie), queue='get_subtitle', duration='long', item=i, length=count_movie)
result = 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 result is not None:
@@ -499,7 +503,7 @@ def movies_download_subtitles(no):
notifications.write(msg='Searching completed. Please reload the page.', type='success', duration='permanent', button='refresh', queue='get_subtitle')
-def wanted_download_subtitles(path):
+def wanted_download_subtitles(path, l, count_episodes):
conn_db = sqlite3.connect(os.path.join(args.config_dir, 'db', 'bazarr.db'), timeout=30)
c_db = conn_db.cursor()
episodes_details = c_db.execute(
@@ -533,8 +537,7 @@ def wanted_download_subtitles(path):
for i in range(len(attempt)):
if attempt[i][0] == language:
if search_active(attempt[i][1]):
- notifications.write(
- msg='Searching ' + str(language_from_alpha2(language)) + ' subtitles for this episode: ' + path, queue='get_subtitle')
+ notifications.write(msg='Searching for series subtitles : ' + str(l) + '/' + str(count_episodes), queue='get_subtitle', duration='long', item=l, length=count_episodes)
result = download_subtitle(path_replace(episode[0]), str(alpha3_from_alpha2(language)),
episode[4], providers_list, providers_auth, str(episode[5]),
episode[7], 'series')
@@ -553,7 +556,7 @@ def wanted_download_subtitles(path):
'BAZARR Search is not active for episode ' + episode[0] + ' Language: ' + attempt[i][0])
-def wanted_download_subtitles_movie(path):
+def wanted_download_subtitles_movie(path, l, count_movies):
conn_db = sqlite3.connect(os.path.join(args.config_dir, 'db', 'bazarr.db'), timeout=30)
c_db = conn_db.cursor()
movies_details = c_db.execute(
@@ -586,8 +589,7 @@ def wanted_download_subtitles_movie(path):
for i in range(len(attempt)):
if attempt[i][0] == language:
if search_active(attempt[i][1]) is True:
- notifications.write(
- msg='Searching ' + str(language_from_alpha2(language)) + ' subtitles for this movie: ' + path, queue='get_subtitle')
+ notifications.write(msg='Searching for movies subtitles : ' + str(l) + '/' + str(count_movies), queue='get_subtitle', duration='long', item=l, length=count_movies)
result = download_subtitle(path_replace_movie(movie[0]), str(alpha3_from_alpha2(language)),
movie[4], providers_list, providers_auth, str(movie[5]), movie[7],
'movie')
@@ -634,16 +636,18 @@ def wanted_search_missing_subtitles():
providers = get_providers()
if settings.general.getboolean('use_sonarr'):
if providers:
- for episode in episodes:
- wanted_download_subtitles(episode[0])
+ count_episodes= len(episodes)
+ for i, episode in enumerate(episodes, 1):
+ wanted_download_subtitles(episode[0], i, count_episodes)
else:
notifications.write(msg='BAZARR All providers are throttled', queue='get_subtitle')
logging.info("BAZARR All providers are throttled")
if settings.general.getboolean('use_radarr'):
if providers:
- for movie in movies:
- wanted_download_subtitles_movie(movie[0])
+ count_movies = len(movies)
+ for i, movie in enumerate(movies, 1):
+ wanted_download_subtitles_movie(movie[0], i, count_movies)
else:
notifications.write(msg='BAZARR All providers are throttled', queue='get_subtitle')
logging.info("BAZARR All providers are throttled")
@@ -772,7 +776,7 @@ def upgrade_subtitles():
for i, episode in enumerate(episodes_to_upgrade, 1):
if episode[1] in ast.literal_eval(str(episode[9])):
notifications.write(msg='Upgrading series subtitles : ' + str(i) + '/' + str(count_episode_to_upgrade),
- queue='get_subtitle', duration='long')
+ queue='get_subtitle', duration='long', item=i, length=count_episode_to_upgrade)
result = download_subtitle(path_replace(episode[0]), str(alpha3_from_alpha2(episode[1])),
episode[3], providers_list, providers_auth, str(episode[4]),
episode[5], 'series', forced_minimum_score=int(episode[2]), is_upgrade=True)
@@ -789,7 +793,7 @@ def upgrade_subtitles():
for i, movie in enumerate(movies_to_upgrade, 1):
if movie[1] in ast.literal_eval(str(movie[8])):
notifications.write(msg='Upgrading movie subtitles : ' + str(i) + '/' + str(count_movie_to_upgrade),
- queue='get_subtitle', duration='long')
+ queue='get_subtitle', duration='long', item=i, length=count_movie_to_upgrad)
result = download_subtitle(path_replace_movie(movie[0]), str(alpha3_from_alpha2(movie[1])),
movie[3], providers_list, providers_auth, str(movie[4]),
movie[5], 'movie', forced_minimum_score=int(movie[2]), is_upgrade=True)
From 2c97d0ba72a34da34be89deb215e774172df97f4 Mon Sep 17 00:00:00 2001
From: Halali
Date: Wed, 10 Apr 2019 22:05:33 +0200
Subject: [PATCH 3/5] Add more progress notifications
---
bazarr/get_subtitle.py | 2 +-
bazarr/list_subtitles.py | 14 ++++++++++----
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/bazarr/get_subtitle.py b/bazarr/get_subtitle.py
index 315810702..e478905db 100644
--- a/bazarr/get_subtitle.py
+++ b/bazarr/get_subtitle.py
@@ -793,7 +793,7 @@ def upgrade_subtitles():
for i, movie in enumerate(movies_to_upgrade, 1):
if movie[1] in ast.literal_eval(str(movie[8])):
notifications.write(msg='Upgrading movie subtitles : ' + str(i) + '/' + str(count_movie_to_upgrade),
- queue='get_subtitle', duration='long', item=i, length=count_movie_to_upgrad)
+ queue='get_subtitle', duration='long', item=i, length=count_movie_to_upgrade)
result = download_subtitle(path_replace_movie(movie[0]), str(alpha3_from_alpha2(movie[1])),
movie[3], providers_list, providers_auth, str(movie[4]),
movie[5], 'movie', forced_minimum_score=int(movie[2]), is_upgrade=True)
diff --git a/bazarr/list_subtitles.py b/bazarr/list_subtitles.py
index a70607069..919c7f7a5 100644
--- a/bazarr/list_subtitles.py
+++ b/bazarr/list_subtitles.py
@@ -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(msg='Analyzing this file for subtitles: ' + file, queue='list_subtitles')
+ # notifications.write(msg='Analyzing this file for subtitles: ' + file, queue='list_subtitles')
if settings.general.getboolean('use_embedded_subs'):
if os.path.splitext(file)[1] == '.mkv':
logging.debug("BAZARR is trying to index embedded subtitles.")
@@ -116,7 +116,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(msg='Analyzing this file for subtitles: ' + file, queue='list_subtitles')
+ # notifications.write(msg='Analyzing this file for subtitles: ' + file, queue='list_subtitles')
if settings.general.getboolean('use_embedded_subs'):
if os.path.splitext(file)[1] == '.mkv':
logging.debug("BAZARR is trying to index embedded subtitles.")
@@ -298,8 +298,11 @@ def series_full_scan_subtitles():
c_db = conn_db.cursor()
episodes = c_db.execute("SELECT path FROM table_episodes").fetchall()
c_db.close()
+ count_episodes = len(episodes)
- for episode in episodes:
+ for i, episode in enumerate(episodes, 1):
+ notifications.write(msg='Updating all episodes subtitles from disk : ' + str(i) + '/' + str(count_episodes),
+ queue='list_subtitles_episodes', duration='long', item=i, length=count_episodes)
store_subtitles(path_replace(episode[0]))
gc.collect()
@@ -310,8 +313,11 @@ def movies_full_scan_subtitles():
c_db = conn_db.cursor()
movies = c_db.execute("SELECT path FROM table_movies").fetchall()
c_db.close()
+ count_movies = len(movies)
- for movie in movies:
+ for i, movie in enumerate(movies, 1):
+ notifications.write(msg='Updating all movies subtitles from disk : ' + str(i) + '/' + str(count_movies),
+ queue='list_subtitles_movies', duration='long', item=i, length=count_movies)
store_subtitles_movie(path_replace_movie(movie[0]))
gc.collect()
From 03b5cc456ec4bb238b3421bff13fd56d15a23ddc Mon Sep 17 00:00:00 2001
From: Halali
Date: Fri, 19 Apr 2019 21:49:45 +0200
Subject: [PATCH 4/5] Finished development
---
bazarr/get_episodes.py | 2 +-
bazarr/get_movies.py | 8 +++++---
bazarr/get_subtitle.py | 22 +++++++++++++---------
bazarr/list_subtitles.py | 6 +++---
views/menu.tpl | 14 +++++++++++++-
5 files changed, 35 insertions(+), 17 deletions(-)
diff --git a/bazarr/get_episodes.py b/bazarr/get_episodes.py
index c5fc868e8..46d2a2cbd 100644
--- a/bazarr/get_episodes.py
+++ b/bazarr/get_episodes.py
@@ -52,7 +52,7 @@ def sync_episodes():
seriesIdListLength = len(seriesIdList)
for i, seriesId in enumerate(seriesIdList, 1):
- notifications.write(msg='Getting episodes data from Sonarr...', queue='get_episodes', item=i, length=seriesIdListLength)
+ notifications.write(msg='Getting episodes data from Sonarr...', queue='get_episodes', item=i, length=seriesIdListLength, duration='long')
# Get episodes data for a series from Sonarr
url_sonarr_api_episode = url_sonarr + "/api/episode?seriesId=" + str(seriesId[0]) + "&apikey=" + apikey_sonarr
try:
diff --git a/bazarr/get_movies.py b/bazarr/get_movies.py
index 858142a70..692948735 100644
--- a/bazarr/get_movies.py
+++ b/bazarr/get_movies.py
@@ -49,9 +49,11 @@ def update_movies():
current_movies_radarr = []
movies_to_update = []
movies_to_add = []
-
- for movie in r.json():
- notifications.write(msg="Getting data for this movie: " + movie['title'], queue='get_movies')
+
+ moviesIdListLength = len(r.json())
+ for i, movie in enumerate(r.json(), 1):
+ notifications.write(msg="Getting data for this movie...", queue='get_movies', item=i,
+ length=moviesIdListLength, duration='long')
if movie['hasFile'] is True:
if 'movieFile' in movie:
if movie["path"] != None and movie['movieFile']['relativePath'] != None:
diff --git a/bazarr/get_subtitle.py b/bazarr/get_subtitle.py
index e478905db..e891a9319 100644
--- a/bazarr/get_subtitle.py
+++ b/bazarr/get_subtitle.py
@@ -453,7 +453,7 @@ def series_download_subtitles(no):
for i, episode in enumerate(episodes_details, 1):
for language in ast.literal_eval(episode[1]):
if language is not None:
- notifications.write(msg='Searching for series subtitles : ' + str(i) + '/' + str(count_episodes_details), queue='get_subtitle', duration='long', item=i, length=count_episodes_details)
+ notifications.write(msg='Searching for series subtitles', queue='get_subtitle', duration='long', item=i, length=count_episodes_details)
result = 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')
@@ -486,7 +486,7 @@ def movies_download_subtitles(no):
for i, language in enumerate(ast.literal_eval(movie[1]), 1):
if language is not None:
- notifications.write(msg='Searching for movies subtitles : ' + str(i) + '/' + str(count_movie), queue='get_subtitle', duration='long', item=i, length=count_movie)
+ notifications.write(msg='Searching for movies subtitles', queue='get_subtitle', duration='long', item=i, length=count_movie)
result = 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 result is not None:
@@ -537,7 +537,7 @@ def wanted_download_subtitles(path, l, count_episodes):
for i in range(len(attempt)):
if attempt[i][0] == language:
if search_active(attempt[i][1]):
- notifications.write(msg='Searching for series subtitles : ' + str(l) + '/' + str(count_episodes), queue='get_subtitle', duration='long', item=l, length=count_episodes)
+ notifications.write(msg='Searching for series subtitles...', queue='get_subtitle', duration='long', item=l, length=count_episodes)
result = download_subtitle(path_replace(episode[0]), str(alpha3_from_alpha2(language)),
episode[4], providers_list, providers_auth, str(episode[5]),
episode[7], 'series')
@@ -552,6 +552,8 @@ def wanted_download_subtitles(path, l, count_episodes):
history_log(1, episode[3], episode[2], message, path, language_code, provider, score)
send_notifications(episode[3], episode[2], message)
else:
+ notifications.write(msg='Searching for series subtitles', queue='get_subtitle', duration='long',
+ item=l, length=count_episodes)
logging.debug(
'BAZARR Search is not active for episode ' + episode[0] + ' Language: ' + attempt[i][0])
@@ -589,7 +591,7 @@ def wanted_download_subtitles_movie(path, l, count_movies):
for i in range(len(attempt)):
if attempt[i][0] == language:
if search_active(attempt[i][1]) is True:
- notifications.write(msg='Searching for movies subtitles : ' + str(l) + '/' + str(count_movies), queue='get_subtitle', duration='long', item=l, length=count_movies)
+ notifications.write(msg='Searching for movies subtitles...', queue='get_subtitle', duration='long', item=l, length=count_movies)
result = download_subtitle(path_replace_movie(movie[0]), str(alpha3_from_alpha2(language)),
movie[4], providers_list, providers_auth, str(movie[5]), movie[7],
'movie')
@@ -604,6 +606,8 @@ def wanted_download_subtitles_movie(path, l, count_movies):
history_log_movie(1, movie[3], message, path, language_code, provider, score)
send_notifications_movie(movie[3], message)
else:
+ notifications.write(msg='Searching for movies subtitles...', queue='get_subtitle', duration='long',
+ item=l, length=count_movies)
logging.info(
'BAZARR Search is not active for movie ' + movie[0] + ' Language: ' + attempt[i][0])
@@ -640,7 +644,7 @@ def wanted_search_missing_subtitles():
for i, episode in enumerate(episodes, 1):
wanted_download_subtitles(episode[0], i, count_episodes)
else:
- notifications.write(msg='BAZARR All providers are throttled', queue='get_subtitle')
+ notifications.write(msg='BAZARR All providers are throttled', queue='get_subtitle', duration='long')
logging.info("BAZARR All providers are throttled")
if settings.general.getboolean('use_radarr'):
@@ -775,8 +779,8 @@ def upgrade_subtitles():
for i, episode in enumerate(episodes_to_upgrade, 1):
if episode[1] in ast.literal_eval(str(episode[9])):
- notifications.write(msg='Upgrading series subtitles : ' + str(i) + '/' + str(count_episode_to_upgrade),
- queue='get_subtitle', duration='long', item=i, length=count_episode_to_upgrade)
+ notifications.write(msg='Upgrading series subtitles...',
+ queue='upgrade_subtitle', duration='long', item=i, length=count_episode_to_upgrade)
result = download_subtitle(path_replace(episode[0]), str(alpha3_from_alpha2(episode[1])),
episode[3], providers_list, providers_auth, str(episode[4]),
episode[5], 'series', forced_minimum_score=int(episode[2]), is_upgrade=True)
@@ -792,8 +796,8 @@ def upgrade_subtitles():
for i, movie in enumerate(movies_to_upgrade, 1):
if movie[1] in ast.literal_eval(str(movie[8])):
- notifications.write(msg='Upgrading movie subtitles : ' + str(i) + '/' + str(count_movie_to_upgrade),
- queue='get_subtitle', duration='long', item=i, length=count_movie_to_upgrade)
+ notifications.write(msg='Upgrading movie subtitles...',
+ queue='upgrade_subtitle', duration='long', item=i, length=count_movie_to_upgrade)
result = download_subtitle(path_replace_movie(movie[0]), str(alpha3_from_alpha2(movie[1])),
movie[3], providers_list, providers_auth, str(movie[4]),
movie[5], 'movie', forced_minimum_score=int(movie[2]), is_upgrade=True)
diff --git a/bazarr/list_subtitles.py b/bazarr/list_subtitles.py
index 919c7f7a5..fe01e8aaa 100644
--- a/bazarr/list_subtitles.py
+++ b/bazarr/list_subtitles.py
@@ -301,8 +301,8 @@ def series_full_scan_subtitles():
count_episodes = len(episodes)
for i, episode in enumerate(episodes, 1):
- notifications.write(msg='Updating all episodes subtitles from disk : ' + str(i) + '/' + str(count_episodes),
- queue='list_subtitles_episodes', duration='long', item=i, length=count_episodes)
+ notifications.write(msg='Updating all episodes subtitles from disk...',
+ queue='list_subtitles_series', duration='long', item=i, length=count_episodes)
store_subtitles(path_replace(episode[0]))
gc.collect()
@@ -316,7 +316,7 @@ def movies_full_scan_subtitles():
count_movies = len(movies)
for i, movie in enumerate(movies, 1):
- notifications.write(msg='Updating all movies subtitles from disk : ' + str(i) + '/' + str(count_movies),
+ notifications.write(msg='Updating all movies subtitles from disk...',
queue='list_subtitles_movies', duration='long', item=i, length=count_movies)
store_subtitles_movie(path_replace_movie(movie[0]))
diff --git a/views/menu.tpl b/views/menu.tpl
index a34dddf9c..2cee1f1af 100644
--- a/views/menu.tpl
+++ b/views/menu.tpl
@@ -19,6 +19,14 @@
.searchicon {
color: white !important;
}
+ .ui.progress .bar>.progress {
+ right: auto;
+ left: .5em;
+ color: black !important;
+ }
+ .ui.disabled.progress.notification_progress {
+ opacity: unset !important;
+ }
div.disabled { pointer-events: none; }
button.disabled { pointer-events: none; }
@@ -300,7 +308,11 @@
duration : 0,
autoSuccess: false,
value : item,
- total : length
+ total : length,
+ label: 'ratio',
+ text: {
+ ratio: '{value} / {total}'
+ }
});
}
},
From 3ffce6e5fae43d9345e3ae297d63206ff4692d13 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Mon, 22 Apr 2019 21:08:26 -0400
Subject: [PATCH 5/5] Some fixes and improvements.
---
bazarr/get_episodes.py | 4 +---
bazarr/get_movies.py | 7 ++-----
bazarr/get_series.py | 9 ++++-----
bazarr/get_subtitle.py | 29 +++++++++++++----------------
bazarr/list_subtitles.py | 4 ++--
views/menu.tpl | 8 ++++----
6 files changed, 26 insertions(+), 35 deletions(-)
diff --git a/bazarr/get_episodes.py b/bazarr/get_episodes.py
index 0ec9d005d..0863c8d4b 100644
--- a/bazarr/get_episodes.py
+++ b/bazarr/get_episodes.py
@@ -53,7 +53,7 @@ def sync_episodes():
seriesIdListLength = len(seriesIdList)
for i, seriesId in enumerate(seriesIdList, 1):
- notifications.write(msg='Getting episodes data from Sonarr...', queue='get_episodes', item=i, length=seriesIdListLength, duration='long')
+ notifications.write(msg='Getting episodes data from Sonarr...', queue='get_episodes', item=i, length=seriesIdListLength)
# Get episodes data for a series from Sonarr
url_sonarr_api_episode = url_sonarr + "/api/episode?seriesId=" + str(seriesId[0]) + "&apikey=" + apikey_sonarr
try:
@@ -160,8 +160,6 @@ def sync_episodes():
else:
logging.debug("BAZARR More than 5 episodes were added during this sync then we wont search for subtitles.")
- notifications.write(msg='Episodes sync from Sonarr ended.', queue='get_episodes')
-
def SonarrFormatAudioCodec(audioCodec):
if audioCodec == 'AC-3': return 'AC3'
diff --git a/bazarr/get_movies.py b/bazarr/get_movies.py
index 415594df9..7e582ebbc 100644
--- a/bazarr/get_movies.py
+++ b/bazarr/get_movies.py
@@ -14,7 +14,6 @@ from get_subtitle import movies_download_subtitles
def update_movies():
- 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')
@@ -53,8 +52,8 @@ def update_movies():
moviesIdListLength = len(r.json())
for i, movie in enumerate(r.json(), 1):
- notifications.write(msg="Getting data for this movie...", queue='get_movies', item=i,
- length=moviesIdListLength, duration='long')
+ notifications.write(msg="Getting movies data from Radarr...", queue='get_movies', item=i,
+ length=moviesIdListLength)
if movie['hasFile'] is True:
if 'movieFile' in movie:
if movie["path"] != None and movie['movieFile']['relativePath'] != None:
@@ -198,8 +197,6 @@ def update_movies():
logging.debug("BAZARR More than 5 movies were added during this sync then we wont search for subtitles.")
logging.debug('BAZARR All movies synced from Radarr into database.')
-
- notifications.write(msg="Update movies list from Radarr is ended.", queue='get_movies')
def get_profile_list():
diff --git a/bazarr/get_series.py b/bazarr/get_series.py
index b58d29e5e..21016d2e0 100644
--- a/bazarr/get_series.py
+++ b/bazarr/get_series.py
@@ -52,9 +52,10 @@ def update_series():
current_shows_sonarr = []
series_to_update = []
series_to_add = []
-
- for show in r.json():
- notifications.write(msg="Getting series data for this show: " + show['title'], queue='get_series')
+
+ seriesListLength = len(r.json())
+ for i, show in enumerate(r.json(), 1):
+ notifications.write(msg="Getting series data from Sonarr...", queue='get_series', item=i, length=seriesListLength)
try:
overview = unicode(show['overview'])
except:
@@ -126,8 +127,6 @@ def update_series():
c.executemany('DELETE FROM table_shows WHERE tvdbId = ?', deleted_items)
db.commit()
db.close()
-
- notifications.write(msg="Update series list from Sonarr is ended.", queue='get_series')
def get_profile_list():
diff --git a/bazarr/get_subtitle.py b/bazarr/get_subtitle.py
index e45296ff8..0eefff6ab 100644
--- a/bazarr/get_subtitle.py
+++ b/bazarr/get_subtitle.py
@@ -351,7 +351,6 @@ def manual_download_subtitle(path, language, hi, subtitle, provider, providers_a
return None
else:
if not subtitle.is_valid():
- 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)
@@ -453,7 +452,7 @@ def series_download_subtitles(no):
for i, episode in enumerate(episodes_details, 1):
for language in ast.literal_eval(episode[1]):
if language is not None:
- notifications.write(msg='Searching for series subtitles', queue='get_subtitle', duration='long', item=i, length=count_episodes_details)
+ notifications.write(msg='Searching for series subtitles...', queue='get_subtitle', item=i, length=count_episodes_details)
result = 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')
@@ -468,7 +467,8 @@ 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', queue='get_subtitle')
+ if count_episodes_details:
+ notifications.write(msg='Searching completed. Please reload the page.', type='success', duration='permanent', button='refresh', queue='get_subtitle')
def episode_download_subtitles(no):
@@ -523,7 +523,7 @@ def movies_download_subtitles(no):
for i, language in enumerate(ast.literal_eval(movie[1]), 1):
if language is not None:
- notifications.write(msg='Searching for movies subtitles', queue='get_subtitle', duration='long', item=i, length=count_movie)
+ notifications.write(msg='Searching for movies subtitles', queue='get_subtitle', item=i, length=count_movie)
result = 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 result is not None:
@@ -537,7 +537,8 @@ 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', queue='get_subtitle')
+ if count_movie:
+ notifications.write(msg='Searching completed. Please reload the page.', type='success', duration='permanent', button='refresh', queue='get_subtitle')
def wanted_download_subtitles(path, l, count_episodes):
@@ -574,7 +575,7 @@ def wanted_download_subtitles(path, l, count_episodes):
for i in range(len(attempt)):
if attempt[i][0] == language:
if search_active(attempt[i][1]):
- notifications.write(msg='Searching for series subtitles...', queue='get_subtitle', duration='long', item=l, length=count_episodes)
+ notifications.write(msg='Searching for series subtitles...', queue='get_subtitle', item=l, length=count_episodes)
result = download_subtitle(path_replace(episode[0]), str(alpha3_from_alpha2(language)),
episode[4], providers_list, providers_auth, str(episode[5]),
episode[7], 'series')
@@ -589,8 +590,6 @@ def wanted_download_subtitles(path, l, count_episodes):
history_log(1, episode[3], episode[2], message, path, language_code, provider, score)
send_notifications(episode[3], episode[2], message)
else:
- notifications.write(msg='Searching for series subtitles', queue='get_subtitle', duration='long',
- item=l, length=count_episodes)
logging.debug(
'BAZARR Search is not active for episode ' + episode[0] + ' Language: ' + attempt[i][0])
@@ -628,7 +627,7 @@ def wanted_download_subtitles_movie(path, l, count_movies):
for i in range(len(attempt)):
if attempt[i][0] == language:
if search_active(attempt[i][1]) is True:
- notifications.write(msg='Searching for movies subtitles...', queue='get_subtitle', duration='long', item=l, length=count_movies)
+ notifications.write(msg='Searching for movies subtitles...', queue='get_subtitle', item=l, length=count_movies)
result = download_subtitle(path_replace_movie(movie[0]), str(alpha3_from_alpha2(language)),
movie[4], providers_list, providers_auth, str(movie[5]), movie[7],
'movie')
@@ -643,8 +642,6 @@ def wanted_download_subtitles_movie(path, l, count_movies):
history_log_movie(1, movie[3], message, path, language_code, provider, score)
send_notifications_movie(movie[3], message)
else:
- notifications.write(msg='Searching for movies subtitles...', queue='get_subtitle', duration='long',
- item=l, length=count_movies)
logging.info(
'BAZARR Search is not active for movie ' + movie[0] + ' Language: ' + attempt[i][0])
@@ -690,7 +687,7 @@ def wanted_search_missing_subtitles():
for i, movie in enumerate(movies, 1):
wanted_download_subtitles_movie(movie[0], i, count_movies)
else:
- notifications.write(msg='BAZARR All providers are throttled', queue='get_subtitle')
+ notifications.write(msg='BAZARR All providers are throttled', queue='get_subtitle', duration='long')
logging.info("BAZARR All providers are throttled")
logging.info('BAZARR Finished searching for missing subtitles. Check histories for more information.')
@@ -800,12 +797,12 @@ def upgrade_subtitles():
episodes_to_upgrade = []
for episode in episodes_list:
- if os.path.exists(path_replace(episode[0])) and int(episode[2]) < 360:
+ if os.path.exists(path_replace(episode[0])) and int(episode[2]) < 357:
episodes_to_upgrade.append(episode)
movies_to_upgrade = []
for movie in movies_list:
- if os.path.exists(path_replace_movie(movie[0])) and int(movie[2]) < 120:
+ if os.path.exists(path_replace_movie(movie[0])) and int(movie[2]) < 117:
movies_to_upgrade.append(movie)
providers_list = get_providers()
@@ -817,7 +814,7 @@ def upgrade_subtitles():
for i, episode in enumerate(episodes_to_upgrade, 1):
if episode[1] in ast.literal_eval(str(episode[9])):
notifications.write(msg='Upgrading series subtitles...',
- queue='upgrade_subtitle', duration='long', item=i, length=count_episode_to_upgrade)
+ queue='upgrade_subtitle', item=i, length=count_episode_to_upgrade)
result = download_subtitle(path_replace(episode[0]), str(alpha3_from_alpha2(episode[1])),
episode[3], providers_list, providers_auth, str(episode[4]),
episode[5], 'series', forced_minimum_score=int(episode[2]), is_upgrade=True)
@@ -834,7 +831,7 @@ def upgrade_subtitles():
for i, movie in enumerate(movies_to_upgrade, 1):
if movie[1] in ast.literal_eval(str(movie[8])):
notifications.write(msg='Upgrading movie subtitles...',
- queue='upgrade_subtitle', duration='long', item=i, length=count_movie_to_upgrade)
+ queue='upgrade_subtitle', item=i, length=count_movie_to_upgrade)
result = download_subtitle(path_replace_movie(movie[0]), str(alpha3_from_alpha2(movie[1])),
movie[3], providers_list, providers_auth, str(movie[4]),
movie[5], 'movie', forced_minimum_score=int(movie[2]), is_upgrade=True)
diff --git a/bazarr/list_subtitles.py b/bazarr/list_subtitles.py
index 943d260ca..2e56b7e88 100644
--- a/bazarr/list_subtitles.py
+++ b/bazarr/list_subtitles.py
@@ -302,7 +302,7 @@ def series_full_scan_subtitles():
for i, episode in enumerate(episodes, 1):
notifications.write(msg='Updating all episodes subtitles from disk...',
- queue='list_subtitles_series', duration='long', item=i, length=count_episodes)
+ queue='list_subtitles_series', item=i, length=count_episodes)
store_subtitles(path_replace(episode[0]))
gc.collect()
@@ -317,7 +317,7 @@ def movies_full_scan_subtitles():
for i, movie in enumerate(movies, 1):
notifications.write(msg='Updating all movies subtitles from disk...',
- queue='list_subtitles_movies', duration='long', item=i, length=count_movies)
+ queue='list_subtitles_movies', item=i, length=count_movies)
store_subtitles_movie(path_replace_movie(movie[0]))
gc.collect()
diff --git a/views/menu.tpl b/views/menu.tpl
index 187a33610..315070320 100644
--- a/views/menu.tpl
+++ b/views/menu.tpl
@@ -320,6 +320,8 @@
var notificationTimeout;
var timeout;
var killer;
+ var item = {};
+ var length = {};
function doNotificationsAjax() {
$.ajax({
url: url_notifications,
@@ -337,7 +339,7 @@
if (length === 0) {
var message = msg;
} else {
- var message = msg + ''
+ var message = msg + ''
}
if (duration === 'temporary') {
@@ -374,14 +376,12 @@
timeout: timeout,
killer: killer,
buttons: button,
- force: true
+ force: false
}).show();
$('.notification_progress').progress({
duration : 0,
autoSuccess: false,
- value : item,
- total : length,
label: 'ratio',
text: {
ratio: '{value} / {total}'