From 025ecb941c5de6043e78d70197f5d48fbc7a4709 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Sun, 19 Jan 2020 23:00:03 -0500 Subject: [PATCH] WIP --- bazarr/SSE.py | 10 +++------- bazarr/list_subtitles.py | 5 +++-- views/_main.html | 31 ++++++++++++++++++++++++++++--- 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/bazarr/SSE.py b/bazarr/SSE.py index f37d6fe42..1560e8464 100644 --- a/bazarr/SSE.py +++ b/bazarr/SSE.py @@ -1,7 +1,6 @@ from __future__ import absolute_import from collections import deque import json -import time class EventStream: @@ -26,7 +25,7 @@ class EventStream: :type movie: str """ msg = {"type": type, "action": action, "series": series, "episode": episode, "movie": movie} - self.queue.append("retry: 1000\ndata:" + json.dumps(msg) + "\n\n") + self.queue.append("data:" + json.dumps(msg) + "\n\n") def read(self): """ @@ -35,11 +34,8 @@ class EventStream: """ while True: - if self.queue: - return self.queue.popleft() - else: - return ':' - time.sleep(0.1) + while self.queue: + yield self.queue.popleft() event_stream = EventStream() diff --git a/bazarr/list_subtitles.py b/bazarr/list_subtitles.py index fac0b16d0..0fffb81ab 100644 --- a/bazarr/list_subtitles.py +++ b/bazarr/list_subtitles.py @@ -326,14 +326,15 @@ def movies_full_scan_subtitles(): def series_scan_subtitles(no): - episodes = database.execute("SELECT path FROM table_episodes WHERE sonarrSeriesId=?", (no,)) + episodes = database.execute("SELECT path FROM table_episodes WHERE sonarrSeriesId=? ORDER BY sonarrEpisodeId", + (no,)) for episode in episodes: store_subtitles(episode['path'], path_replace(episode['path'])) def movies_scan_subtitles(no): - movies = database.execute("SELECT path FROM table_movies WHERE radarrId=?", (no,)) + movies = database.execute("SELECT path FROM table_movies WHERE radarrId=? ORDER BY radarrId", (no,)) for movie in movies: store_subtitles_movie(movie['path'], path_replace_movie(movie['path'])) diff --git a/views/_main.html b/views/_main.html index f67b3e3cc..89414fd60 100644 --- a/views/_main.html +++ b/views/_main.html @@ -252,6 +252,8 @@ + + {% endblock tail_js %} {% block tail %}