mirror of
https://github.com/morpheus65535/bazarr
synced 2025-02-26 15:53:07 +00:00
Continue developing
This commit is contained in:
parent
34d33f65fa
commit
e5c2e8026f
4 changed files with 48 additions and 7 deletions
|
@ -12,7 +12,7 @@ import json
|
|||
|
||||
from get_args import args
|
||||
from config import settings, bazarr_url
|
||||
from queueconfig import q4ws
|
||||
from queueconfig import q4ws, q4ws_updater
|
||||
|
||||
|
||||
def check_releases():
|
||||
|
@ -137,7 +137,7 @@ def check_updates():
|
|||
update()
|
||||
|
||||
elif commits_behind == 0:
|
||||
q4ws.append('BAZZAR is up to date')
|
||||
q4ws_updater.append('BAZZAR is up to date')
|
||||
logging.info('BAZZAR is up to date')
|
||||
|
||||
return latest_version
|
||||
|
|
|
@ -1886,6 +1886,26 @@ def handle_websocket():
|
|||
break
|
||||
|
||||
|
||||
@route(base_url + 'websocket_updater')
|
||||
@custom_auth_basic(check_credentials)
|
||||
def handle_websocket():
|
||||
wsock = request.environ.get('wsgi.websocket')
|
||||
if not wsock:
|
||||
abort(400, 'Expected WebSocket request.')
|
||||
|
||||
queueconfig.q4ws_updater.clear()
|
||||
|
||||
while True:
|
||||
try:
|
||||
if queueconfig.q4ws_updater:
|
||||
wsock.send(queueconfig.q4ws_updater.popleft())
|
||||
gevent.sleep(0.1)
|
||||
else:
|
||||
gevent.sleep(0.5)
|
||||
except WebSocketError:
|
||||
break
|
||||
|
||||
|
||||
# Mute DeprecationWarning
|
||||
warnings.simplefilter("ignore", DeprecationWarning)
|
||||
server = WSGIServer((str(settings.general.ip), (int(args.port) if args.port else int(settings.general.port))), app, handler_class=WebSocketHandler)
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
from collections import deque
|
||||
|
||||
global q4ws
|
||||
global q4ws_updater
|
||||
q4ws = deque(maxlen=10)
|
||||
q4ws_updater = deque(maxlen=2)
|
||||
|
|
|
@ -225,14 +225,32 @@
|
|||
if (location.protocol != 'https:')
|
||||
{
|
||||
var ws = new WebSocket("ws://" + window.location.host + "{{base_url}}websocket");
|
||||
var wsupdater = new WebSocket("ws://" + window.location.host + "{{base_url}}websocket_updater");
|
||||
} else {
|
||||
var ws = new WebSocket("wss://" + window.location.host + "{{base_url}}websocket");
|
||||
var wsupdater = new WebSocket("wss://" + window.location.host + "{{base_url}}websocket_updater");
|
||||
}
|
||||
|
||||
ws.onmessage = function (evt) {
|
||||
new Noty({
|
||||
text: evt.data,
|
||||
timeout: 3000,
|
||||
text: evt.data,
|
||||
timeout: 3000,
|
||||
progressBar: false,
|
||||
animation: {
|
||||
open: null,
|
||||
close: null
|
||||
},
|
||||
killer: true,
|
||||
type: 'info',
|
||||
layout: 'bottomRight',
|
||||
theme: 'semanticui'
|
||||
}).show();
|
||||
};
|
||||
|
||||
wsupdater.onmessage = function (evt) {
|
||||
new Noty({
|
||||
text: evt.data,
|
||||
timeout: false,
|
||||
progressBar: false,
|
||||
animation: {
|
||||
open: null,
|
||||
|
@ -240,8 +258,9 @@
|
|||
},
|
||||
killer: true,
|
||||
type: 'info',
|
||||
layout: 'bottomRight',
|
||||
theme: 'semanticui'
|
||||
layout: 'bottomLeft',
|
||||
theme: 'semanticui',
|
||||
visibilityControl: true
|
||||
}).show();
|
||||
};
|
||||
</script>
|
||||
</script>
|
||||
|
|
Loading…
Reference in a new issue