summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormorpheus65535 <[email protected]>2024-12-07 09:01:09 -0500
committerGitHub <[email protected]>2024-12-07 09:01:09 -0500
commitf4ca0f9e5586b9b84f137c102e4b1c577b883da8 (patch)
treedb6d39509b3860c92d268aac1731ea108aa429cb
parent1cc5c428ca9d5315f5fb02af69161d6723754fb6 (diff)
downloadbazarr-f4ca0f9e5586b9b84f137c102e4b1c577b883da8.tar.gz
bazarr-f4ca0f9e5586b9b84f137c102e4b1c577b883da8.zip
Added frontend notification during automatic syncing of subtitles. #2724v1.4.6-beta.25
-rw-r--r--bazarr/radarr/sync/movies.py6
-rw-r--r--bazarr/sonarr/sync/series.py6
-rw-r--r--bazarr/subtitles/indexer/movies.py6
-rw-r--r--bazarr/subtitles/indexer/series.py6
-rw-r--r--bazarr/subtitles/mass_download/movies.py6
-rw-r--r--bazarr/subtitles/mass_download/series.py12
-rw-r--r--bazarr/subtitles/sync.py19
-rw-r--r--bazarr/subtitles/tools/translate.py6
-rw-r--r--bazarr/subtitles/upgrade.py12
-rw-r--r--bazarr/subtitles/wanted/movies.py6
-rw-r--r--bazarr/subtitles/wanted/series.py6
-rw-r--r--frontend/src/modules/task/index.ts39
12 files changed, 100 insertions, 30 deletions
diff --git a/bazarr/radarr/sync/movies.py b/bazarr/radarr/sync/movies.py
index 4114ba2c9..c4cb5ab96 100644
--- a/bazarr/radarr/sync/movies.py
+++ b/bazarr/radarr/sync/movies.py
@@ -206,7 +206,11 @@ def update_movies(send_event=True):
files_missing += 1
if send_event:
- hide_progress(id='movies_progress')
+ show_progress(id='movies_progress',
+ header='Syncing movies...',
+ name='',
+ value=movies_count,
+ count=movies_count)
trace(f"Skipped {files_missing} file missing movies out of {movies_count}")
if sync_monitored:
diff --git a/bazarr/sonarr/sync/series.py b/bazarr/sonarr/sync/series.py
index e6eec6c22..065fdaa21 100644
--- a/bazarr/sonarr/sync/series.py
+++ b/bazarr/sonarr/sync/series.py
@@ -178,7 +178,11 @@ def update_series(send_event=True):
event_stream(type='series', action='delete', payload=series)
if send_event:
- hide_progress(id='series_progress')
+ show_progress(id='series_progress',
+ header='Syncing series...',
+ name='',
+ value=series_count,
+ count=series_count)
if sync_monitored:
trace(f"skipped {skipped_count} unmonitored series out of {i}")
diff --git a/bazarr/subtitles/indexer/movies.py b/bazarr/subtitles/indexer/movies.py
index 563a68cff..6502a4354 100644
--- a/bazarr/subtitles/indexer/movies.py
+++ b/bazarr/subtitles/indexer/movies.py
@@ -292,7 +292,11 @@ def movies_full_scan_subtitles(use_cache=None):
count=count_movies)
store_subtitles_movie(movie.path, path_mappings.path_replace_movie(movie.path), use_cache=use_cache)
- hide_progress(id='movies_disk_scan')
+ show_progress(id='movies_disk_scan',
+ header='Full disk scan...',
+ name='Movies subtitles',
+ value=count_movies,
+ count=count_movies)
gc.collect()
diff --git a/bazarr/subtitles/indexer/series.py b/bazarr/subtitles/indexer/series.py
index 64af2e4c3..1d1d98ef8 100644
--- a/bazarr/subtitles/indexer/series.py
+++ b/bazarr/subtitles/indexer/series.py
@@ -294,7 +294,11 @@ def series_full_scan_subtitles(use_cache=None):
count=count_episodes)
store_subtitles(episode.path, path_mappings.path_replace(episode.path), use_cache=use_cache)
- hide_progress(id='episodes_disk_scan')
+ show_progress(id='episodes_disk_scan',
+ header='Full disk scan...',
+ name='Episodes subtitles',
+ value=count_episodes,
+ count=count_episodes)
gc.collect()
diff --git a/bazarr/subtitles/mass_download/movies.py b/bazarr/subtitles/mass_download/movies.py
index 5ca94a81f..da3d7538d 100644
--- a/bazarr/subtitles/mass_download/movies.py
+++ b/bazarr/subtitles/mass_download/movies.py
@@ -99,4 +99,8 @@ def movies_download_subtitles(no):
history_log_movie(1, no, result)
send_notifications_movie(no, result.message)
- hide_progress(id=f'movie_search_progress_{no}')
+ show_progress(id=f'movie_search_progress_{no}',
+ header='Searching missing subtitles...',
+ name=movie.title,
+ value=count_movie,
+ count=count_movie)
diff --git a/bazarr/subtitles/mass_download/series.py b/bazarr/subtitles/mass_download/series.py
index 54f651620..64672cd8f 100644
--- a/bazarr/subtitles/mass_download/series.py
+++ b/bazarr/subtitles/mass_download/series.py
@@ -64,7 +64,11 @@ def series_download_subtitles(no):
logging.info("BAZARR All providers are throttled")
break
- hide_progress(id=f'series_search_progress_{no}')
+ show_progress(id=f'series_search_progress_{no}',
+ header='Searching missing subtitles...',
+ name='',
+ value=count_episodes_details,
+ count=count_episodes_details)
def episode_download_subtitles(no, send_progress=False, providers_list=None):
@@ -145,6 +149,10 @@ def episode_download_subtitles(no, send_progress=False, providers_list=None):
send_notifications(episode.sonarrSeriesId, episode.sonarrEpisodeId, result.message)
if send_progress:
- hide_progress(id=f'episode_search_progress_{no}')
+ show_progress(id=f'episode_search_progress_{no}',
+ header='Searching missing subtitles...',
+ name=f'{episode.title} - S{episode.season:02d}E{episode.episode:02d} - {episode.episodeTitle}',
+ value=1,
+ count=1)
else:
logging.info("BAZARR All providers are throttled")
diff --git a/bazarr/subtitles/sync.py b/bazarr/subtitles/sync.py
index 4726d245f..d2ac761f5 100644
--- a/bazarr/subtitles/sync.py
+++ b/bazarr/subtitles/sync.py
@@ -3,8 +3,10 @@
import logging
import gc
+import os
from app.config import settings
+from app.event_handler import show_progress, hide_progress
from subtitles.tools.subsyncer import SubSyncer
@@ -40,7 +42,22 @@ def sync_subtitles(video_path, srt_path, srt_lang, forced, hi, percent_score, so
'sonarr_episode_id': sonarr_episode_id,
'radarr_id': radarr_id,
}
- subsync.sync(**sync_kwargs)
+ subtitles_filename = os.path.basename(srt_path)
+ show_progress(id=f'subsync_{subtitles_filename}',
+ header='Syncing Subtitle',
+ name=srt_path,
+ value=0,
+ count=1)
+ try:
+ subsync.sync(**sync_kwargs)
+ except Exception:
+ hide_progress(id=f'subsync_{subtitles_filename}')
+ else:
+ show_progress(id=f'subsync_{subtitles_filename}',
+ header='Syncing Subtitle',
+ name=srt_path,
+ value=1,
+ count=1)
del subsync
gc.collect()
return True
diff --git a/bazarr/subtitles/tools/translate.py b/bazarr/subtitles/tools/translate.py
index 1998cb504..0bb4c2830 100644
--- a/bazarr/subtitles/tools/translate.py
+++ b/bazarr/subtitles/tools/translate.py
@@ -94,7 +94,11 @@ def translate_subtitles_file(video_path, source_srt_file, from_lang, to_lang, fo
for i, line in enumerate(translated_lines):
lines_list[line['id']] = line['line']
- hide_progress(id=f'translate_progress_{dest_srt_file}')
+ show_progress(id=f'translate_progress_{dest_srt_file}',
+ header=f'Translating subtitles lines to {language_from_alpha3(to_lang)}...',
+ name='',
+ value=lines_list_len,
+ count=lines_list_len)
logging.debug(f'BAZARR saving translated subtitles to {dest_srt_file}')
for i, line in enumerate(subs):
diff --git a/bazarr/subtitles/upgrade.py b/bazarr/subtitles/upgrade.py
index 97196239a..46f00fb57 100644
--- a/bazarr/subtitles/upgrade.py
+++ b/bazarr/subtitles/upgrade.py
@@ -133,7 +133,11 @@ def upgrade_subtitles():
upgraded_from_id=episode['original_id'])
send_notifications(episode['sonarrSeriesId'], episode['sonarrEpisodeId'], result.message)
- hide_progress(id='upgrade_episodes_progress')
+ show_progress(id='upgrade_episodes_progress',
+ header='Upgrading episodes subtitles...',
+ name='',
+ value=count_episode_to_upgrade,
+ count=count_episode_to_upgrade)
if use_radarr:
movies_to_upgrade = get_upgradable_movies_subtitles()
@@ -231,7 +235,11 @@ def upgrade_subtitles():
history_log_movie(3, movie['radarrId'], result, upgraded_from_id=movie['original_id'])
send_notifications_movie(movie['radarrId'], result.message)
- hide_progress(id='upgrade_movies_progress')
+ show_progress(id='upgrade_movies_progress',
+ header='Upgrading movies subtitles...',
+ name='',
+ value=count_movie_to_upgrade,
+ count=count_movie_to_upgrade)
logging.info('BAZARR Finished searching for Subtitles to upgrade. Check History for more information.')
diff --git a/bazarr/subtitles/wanted/movies.py b/bazarr/subtitles/wanted/movies.py
index b47fe8afb..a6892b79a 100644
--- a/bazarr/subtitles/wanted/movies.py
+++ b/bazarr/subtitles/wanted/movies.py
@@ -122,6 +122,10 @@ def wanted_search_missing_subtitles_movies():
logging.info("BAZARR All providers are throttled")
break
- hide_progress(id='wanted_movies_progress')
+ show_progress(id='wanted_movies_progress',
+ header='Searching subtitles...',
+ name="",
+ value=count_movies,
+ count=count_movies)
logging.info('BAZARR Finished searching for missing Movies Subtitles. Check History for more information.')
diff --git a/bazarr/subtitles/wanted/series.py b/bazarr/subtitles/wanted/series.py
index 5a1e9f55b..7b57cbea9 100644
--- a/bazarr/subtitles/wanted/series.py
+++ b/bazarr/subtitles/wanted/series.py
@@ -134,6 +134,10 @@ def wanted_search_missing_subtitles_series():
logging.info("BAZARR All providers are throttled")
break
- hide_progress(id='wanted_episodes_progress')
+ show_progress(id='wanted_episodes_progress',
+ header='Searching subtitles...',
+ name='',
+ value=count_episodes,
+ count=count_episodes)
logging.info('BAZARR Finished searching for missing Series Subtitles. Check History for more information.')
diff --git a/frontend/src/modules/task/index.ts b/frontend/src/modules/task/index.ts
index 59efcaf56..330444c73 100644
--- a/frontend/src/modules/task/index.ts
+++ b/frontend/src/modules/task/index.ts
@@ -107,27 +107,32 @@ class TaskDispatcher {
public updateProgress(items: Site.Progress[]) {
items.forEach((item) => {
- // TODO: FIX ME!
- item.value += 1;
-
- if (item.value >= item.count && this.progress[item.id]) {
- updateNotification(notification.progress.end(item.id, item.header));
- delete this.progress[item.id];
- } else if (item.value > 1 && this.progress[item.id]) {
- updateNotification(
- notification.progress.update(
- item.id,
- item.header,
- item.name,
- item.value,
- item.count,
- ),
- );
- } else if (item.value > 1 && this.progress[item.id] === undefined) {
+ if (this.progress[item.id] === undefined) {
showNotification(notification.progress.pending(item.id, item.header));
this.progress[item.id] = true;
setTimeout(() => this.updateProgress([item]), 1000);
+
+ return;
}
+
+ if (item.value >= item.count) {
+ updateNotification(notification.progress.end(item.id, item.header));
+ delete this.progress[item.id];
+
+ return;
+ }
+
+ item.value += 1;
+
+ updateNotification(
+ notification.progress.update(
+ item.id,
+ item.header,
+ item.name,
+ item.value,
+ item.count,
+ ),
+ );
});
}