pull/997/head
Louis Vézina 5 years ago
parent c1c7ba5dc3
commit 961fae8aed

@ -8,6 +8,7 @@ import time
from get_args import args from get_args import args
from config import settings from config import settings
from websocket_handler import event_stream
from subliminal_patch.exceptions import TooManyRequests, APIThrottled, ParseResponseError from subliminal_patch.exceptions import TooManyRequests, APIThrottled, ParseResponseError
from subliminal.exceptions import DownloadLimitExceeded, ServiceUnavailable from subliminal.exceptions import DownloadLimitExceeded, ServiceUnavailable
from subliminal import region as subliminal_cache_region from subliminal import region as subliminal_cache_region
@ -235,6 +236,8 @@ def update_throttled_provider():
with open(os.path.join(args.config_dir, 'config', 'config.ini'), 'w+') as handle: with open(os.path.join(args.config_dir, 'config', 'config.ini'), 'w+') as handle:
settings.write(handle) settings.write(handle)
event_stream.write(type='badges')
def list_throttled_providers(): def list_throttled_providers():
update_throttled_provider() update_throttled_provider()

@ -237,6 +237,7 @@ def list_missing_subtitles(no=None, epno=None):
event_stream.write(type='episode', action='update', series=missing_subtitles_item[2], event_stream.write(type='episode', action='update', series=missing_subtitles_item[2],
episode=missing_subtitles_item[1]) episode=missing_subtitles_item[1])
event_stream.write(type='badges')
def list_missing_subtitles_movies(no=None): def list_missing_subtitles_movies(no=None):
@ -296,6 +297,7 @@ def list_missing_subtitles_movies(no=None):
(missing_subtitles_item[0], missing_subtitles_item[1])) (missing_subtitles_item[0], missing_subtitles_item[1]))
event_stream.write(type='movie', action='update', movie=missing_subtitles_item[1]) event_stream.write(type='movie', action='update', movie=missing_subtitles_item[1])
event_stream.write(type='badges')
def series_full_scan_subtitles(): def series_full_scan_subtitles():

@ -194,10 +194,12 @@
class="hide-menu"> Wanted</span></a> class="hide-menu"> Wanted</span></a>
<ul aria-expanded="false" class="collapse"> <ul aria-expanded="false" class="collapse">
{% if settings.general.getboolean('use_sonarr') %} {% if settings.general.getboolean('use_sonarr') %}
<li><a href="{{ url_for('wantedseries') }}"> Series</a></li> <li>
<a href="{{ url_for('wantedseries') }}"> Series <span id="wanted_series_badge"></span></a>
</li>
{% endif %} {% endif %}
{% if settings.general.getboolean('use_radarr') %} {% if settings.general.getboolean('use_radarr') %}
<li><a href="{{ url_for('wantedmovies') }}"> Movies</a></li> <li><a href="{{ url_for('wantedmovies') }}"> Movies <span id="wanted_movies_badge"></span></a></li>
{% endif %} {% endif %}
</ul> </ul>
</li> </li>
@ -221,7 +223,7 @@
<ul aria-expanded="false" class="collapse"> <ul aria-expanded="false" class="collapse">
<li><a href="{{ url_for('systemtasks') }}"> Tasks</a></li> <li><a href="{{ url_for('systemtasks') }}"> Tasks</a></li>
<li><a href="{{ url_for('systemlogs') }}"> Logs</a></li> <li><a href="{{ url_for('systemlogs') }}"> Logs</a></li>
<li><a href="{{ url_for('systemproviders') }}"> Providers</a></li> <li><a href="{{ url_for('systemproviders') }}"> Providers <span id="throttled_providers_count"></span></a></li>
<li><a href="{{ url_for('systemstatus') }}"> Status</a></li> <li><a href="{{ url_for('systemstatus') }}"> Status</a></li>
<li><a href="{{ url_for('systemreleases') }}"> Releases</a></li> <li><a href="{{ url_for('systemreleases') }}"> Releases</a></li>
</ul> </ul>
@ -328,19 +330,32 @@
$('#reconnect_overlay').show(); $('#reconnect_overlay').show();
}); });
events.on('event', function (event) {
var event_json_badges = JSON.parse(event);
if (event_json_badges.type === 'badges') {
BadgesAjax();
}
});
function BadgesAjax() { function BadgesAjax() {
$.ajax({ $.ajax({
url: "{{url_for('api.badges')}}", url: "{{url_for('api.badges')}}",
async: true, async: true,
success: function (data) { success: function (data) {
if (data['throttled_providers']) { if (data['throttled_providers']) {
$('#throttled_providers_count').append('<div class="floating ui tiny yellow label" style="left:90% !important;top:0.5em !important;">' + data['throttled_providers'] + '</div>'); $('#throttled_providers_count').html('<span class="badge badge-secondary">' + data['throttled_providers'] + '</span>');
} else {
$('#throttled_providers_count').html('');
} }
if (data['missing_episodes']) { if (data['missing_episodes']) {
$('#wanted').append('<div class="floating ui tiny yellow label" style="left:90% !important;top:0.5em !important;">' + data['missing_episodes'] + '</div>'); $('#wanted_series_badge').html('<span class="badge badge-secondary">' + data['missing_episodes'] + '</span>');
} else {
$('#wanted_series_badge').html('');
} }
if (data['missing_movies']) { if (data['missing_movies']) {
$('#wanted').append('<div id="wanted_movies" class="floating ui tiny green label" style="left:90% !important;top:3em !important;">' + data['missing_movies'] + '</div>'); $('#wanted_movies_badge').html('<span class="badge badge-secondary">' + data['missing_movies'] + '</span>');
} else {
$('#wanted_movies_badge').html('');
} }
}, },

Loading…
Cancel
Save