2018-12-09 20:23:51 +00:00
< html lang = " en " >
2017-12-22 00:49:39 +00:00
< head >
< ! DOCTYPE html >
2018-12-13 02:50:05 +00:00
< link href = " {{ base_url}}static/noty/noty.css " rel = " stylesheet " >
< script src = " {{ base_url}}static/noty/noty.min.js " type = " text/javascript " > < / script >
2017-12-22 00:49:39 +00:00
< style >
#divmenu {
2017-12-22 03:36:22 +00:00
background - color : #000000;
2017-12-22 00:49:39 +00:00
padding - top : 2 em ;
padding - bottom : 1 em ;
padding - left : 1 em ;
padding - right : 128 px ;
}
. prompt {
background - color : #333333 !important;
color : white ! important ;
border - radius : 3 px ! important ;
}
2017-12-23 04:16:50 +00:00
. searchicon {
2017-12-23 03:40:14 +00:00
color : white ! important ;
}
2019-02-25 04:05:58 +00:00
div . disabled { pointer - events : none ; }
button . disabled { pointer - events : none ; }
2017-12-22 00:49:39 +00:00
< / style >
< / head >
< body >
2018-11-29 19:09:34 +00:00
% from get_args import args
2019-03-21 15:32:58 +00:00
% from get_providers import update_throttled_provider
% update_throttled_provider ( )
2018-08-16 02:01:49 +00:00
2019-03-21 15:32:58 +00:00
% import ast
% import datetime
2017-12-23 03:56:04 +00:00
% import os
2017-12-23 03:40:14 +00:00
% import sqlite3
2018-12-15 00:36:28 +00:00
% from config import settings
2017-12-23 03:40:14 +00:00
2019-01-06 17:15:43 +00:00
% if settings . sonarr . getboolean ( ' only_monitored ' ) :
% monitored_only_query_string_sonarr = ' AND monitored = " True " '
2018-08-09 03:43:13 +00:00
% else :
2019-01-06 17:15:43 +00:00
% monitored_only_query_string_sonarr = " "
% end
% if settings . radarr . getboolean ( ' only_monitored ' ) :
% monitored_only_query_string_radarr = ' AND monitored = " True " '
% else :
% monitored_only_query_string_radarr = " "
2018-08-09 03:43:13 +00:00
% end
2018-11-29 19:09:34 +00:00
% conn = sqlite3 . connect ( os . path . join ( args . config_dir , ' db ' , ' bazarr.db ' ) , timeout = 30 )
2017-12-23 03:40:14 +00:00
% c = conn . cursor ( )
2019-01-06 17:15:43 +00:00
% wanted_series = c . execute ( " SELECT COUNT(*) FROM table_episodes WHERE missing_subtitles != ' [] ' " + monitored_only_query_string_sonarr ) . fetchone ( )
% wanted_movies = c . execute ( " SELECT COUNT(*) FROM table_movies WHERE missing_subtitles != ' [] ' " + monitored_only_query_string_radarr ) . fetchone ( )
2019-03-21 15:32:58 +00:00
% from get_providers import list_throttled_providers
% throttled_providers_count = len ( eval ( str ( settings . general . throtteled_providers ) ) )
2017-12-23 03:40:14 +00:00
< div id = " divmenu " class = " ui container " >
2017-12-22 00:49:39 +00:00
< div class = " ui grid " >
< div class = " middle aligned row " >
< div class = " three wide column " >
< a href = " {{ base_url}} " > < img class = " logo " src = " {{ base_url}}static/logo128.png " > < / a >
< / div >
< div class = " twelve wide column " >
< div class = " ui grid " >
< div class = " row " >
< div class = " sixteen wide column " >
2019-01-21 04:20:18 +00:00
< div class = " ui inverted borderless labeled icon massive menu seven item " >
2017-12-22 00:49:39 +00:00
< div class = " ui container " >
2018-12-27 19:19:59 +00:00
% if settings . general . getboolean ( ' use_sonarr ' ) :
2018-05-27 03:01:57 +00:00
< a class = " item " href = " {{ base_url}}series " >
2017-12-22 00:49:39 +00:00
< i class = " play icon " > < / i >
Series
< / a >
2018-05-27 03:01:57 +00:00
% end
2018-12-27 19:19:59 +00:00
% if settings . general . getboolean ( ' use_radarr ' ) :
2018-04-19 23:45:10 +00:00
< a class = " item " href = " {{ base_url}}movies " >
< i class = " film icon " > < / i >
Movies
< / a >
2018-05-27 03:01:57 +00:00
% end
2017-12-22 00:49:39 +00:00
< a class = " item " href = " {{ base_url}}history " >
< i class = " wait icon " > < / i >
History
< / a >
< a class = " item " href = " {{ base_url}}wanted " >
2018-01-03 19:25:49 +00:00
< i class = " warning sign icon " >
2018-12-27 19:19:59 +00:00
% if settings . general . getboolean ( ' use_sonarr ' ) :
2018-05-02 10:25:42 +00:00
< div class = " floating ui tiny yellow label " style = " left:90 % !important;top:0.5em !important; " >
{ { wanted_series [ 0 ] } }
< / div >
2018-05-27 03:01:57 +00:00
% end
2018-12-27 19:19:59 +00:00
% if settings . general . getboolean ( ' use_radarr ' ) :
2018-05-02 10:25:42 +00:00
< div class = " floating ui tiny green label " style = " left:90 % !important;top:3em !important; " >
{ { wanted_movies [ 0 ] } }
2017-12-23 03:40:14 +00:00
< / div >
2018-05-27 03:01:57 +00:00
% end
2018-01-03 19:25:49 +00:00
< / i >
2017-12-22 00:49:39 +00:00
Wanted
< / a >
< a class = " item " href = " {{ base_url}}settings " >
< i class = " settings icon " > < / i >
Settings
< / a >
< a class = " item " href = " {{ base_url}}system " >
2019-03-21 15:32:58 +00:00
< i class = " laptop icon " >
% if throttled_providers_count :
< div class = " floating ui tiny yellow label " style = " left:90 % !important;top:0.5em !important; " >
{ { throttled_providers_count } }
< / div >
% end
< / i >
2017-12-22 00:49:39 +00:00
System
< / a >
2019-01-21 11:41:31 +00:00
< a id = " donate " class = " item " href = " https://beerpay.io/morpheus65535/bazarr " >
2019-01-21 04:20:18 +00:00
< i class = " red heart icon " > < / i >
Donate
< / a >
2017-12-22 00:49:39 +00:00
< / div >
< / div >
< / div >
< / div >
2018-12-09 20:23:51 +00:00
< div style = ' padding-top:0; ' class = " row " >
2017-12-22 00:49:39 +00:00
< div class = " three wide column " > < / div >
< div class = " ten wide column " >
< div class = " ui search " >
< div class = " ui left icon fluid input " >
2018-09-24 22:04:33 +00:00
< input class = " prompt " type = " text " placeholder = " Search in your library " >
2017-12-23 04:16:50 +00:00
< i class = " searchicon search icon " > < / i >
2017-12-22 00:49:39 +00:00
< / div >
< / div >
< / div >
< div class = " three wide column " > < / div >
< / div >
< / div >
< / div >
< / div >
< / div >
2017-12-23 03:40:14 +00:00
2018-09-27 15:50:48 +00:00
% restart_required = c . execute ( " SELECT configured, updated FROM system " ) . fetchone ( )
% c . close ( )
2017-12-23 03:40:14 +00:00
2018-09-27 15:50:48 +00:00
% if restart_required [ 1 ] == ' 1 ' and restart_required [ 0 ] == ' 1 ' :
2018-10-14 13:32:16 +00:00
< div class = ' ui center aligned grid ' > < div class = ' fifteen wide column ' > < div class = " ui red message " > Bazarr need to be restarted to apply last update and changes to general settings . Click < a href = # id="restart_link">here</a> to restart.</div></div></div>
2018-09-27 15:50:48 +00:00
% elif restart_required [ 1 ] == ' 1 ' :
2018-10-14 13:32:16 +00:00
< div class = ' ui center aligned grid ' > < div class = ' fifteen wide column ' > < div class = " ui red message " > Bazarr need to be restarted to apply last update . Click < a href = # id="restart_link">here</a> to restart.</div></div></div>
2018-09-27 15:50:48 +00:00
% elif restart_required [ 0 ] == ' 1 ' :
2018-10-14 13:32:16 +00:00
< div class = ' ui center aligned grid ' > < div class = ' fifteen wide column ' > < div class = " ui red message " > Bazarr need to be restarted to apply changes to general settings . Click < a href = # id="restart_link">here</a> to restart.</div></div></div>
2018-09-27 15:50:48 +00:00
% end
< / div >
2017-12-22 00:49:39 +00:00
< / body >
< / html >
< script >
$ ( ' .ui.search ' )
. search ( {
apiSettings : {
2018-04-24 14:48:52 +00:00
url : ' {{ base_url}}search_json/ {query} ' ,
2017-12-22 00:49:39 +00:00
onResponse : function ( results ) {
2018-12-09 20:23:51 +00:00
const response = {
2017-12-22 00:49:39 +00:00
results : [ ]
} ;
$ . each ( results . items , function ( index , item ) {
response . results . push ( {
title : item . name ,
url : item . url
} ) ;
} ) ;
return response ;
}
} ,
minCharacters : 2
} )
;
2017-12-22 03:36:22 +00:00
if ( window . location . href . indexOf ( " episodes " ) > - 1 ) {
$ ( ' .menu ' ) . css ( ' background ' , ' #000000 ' ) ;
2018-09-28 14:40:36 +00:00
$ ( ' .menu ' ) . css ( ' opacity ' , ' 0.8 ' ) ;
2017-12-22 03:36:22 +00:00
$ ( ' #divmenu ' ) . css ( ' background ' , ' #000000 ' ) ;
2018-09-28 14:40:36 +00:00
$ ( ' #divmenu ' ) . css ( ' opacity ' , ' 0.8 ' ) ;
2018-12-09 20:23:51 +00:00
$ ( ' #divmenu ' ) . css ( ' box-shadow ' , ' 0 0 5px 5px #000000 ' ) ;
2018-09-28 14:40:36 +00:00
}
else if ( window . location . href . indexOf ( " movie/ " ) > - 1 ) {
$ ( ' .menu ' ) . css ( ' background ' , ' #000000 ' ) ;
$ ( ' .menu ' ) . css ( ' opacity ' , ' 0.8 ' ) ;
$ ( ' #divmenu ' ) . css ( ' background ' , ' #000000 ' ) ;
$ ( ' #divmenu ' ) . css ( ' opacity ' , ' 0.8 ' ) ;
2018-12-09 20:23:51 +00:00
$ ( ' #divmenu ' ) . css ( ' box-shadow ' , ' 0 0 5px 5px #000000 ' ) ;
2017-12-22 03:36:22 +00:00
}
else {
$ ( ' .menu ' ) . css ( ' background ' , ' #272727 ' ) ;
$ ( ' #divmenu ' ) . css ( ' background ' , ' #272727 ' ) ;
}
2018-10-14 13:32:16 +00:00
2018-12-09 20:23:51 +00:00
$ ( ' #restart_link ' ) . on ( ' click ' , function ( ) {
2018-10-14 13:32:16 +00:00
$ ( ' #loader_text ' ) . text ( " Bazarr is restarting, please wait... " ) ;
$ . ajax ( {
url : " {{ base_url}}restart " ,
async : true
} )
. done ( function ( ) {
setTimeout ( function ( ) { setInterval ( ping , 2000 ) ; } , 8000 ) ;
} ) ;
2018-12-09 20:23:51 +00:00
} ) ;
2018-10-14 13:32:16 +00:00
2018-12-15 00:36:28 +00:00
% from config import settings
2019-02-17 09:38:45 +00:00
% from get_args import args
2018-12-15 00:36:28 +00:00
% ip = settings . general . ip
2019-02-17 09:38:45 +00:00
% port = args . port if args . port else settings . general . port
2018-12-15 00:36:28 +00:00
% base_url = settings . general . base_url
2018-10-16 14:58:25 +00:00
2018-12-09 20:23:51 +00:00
if ( " {{ ip}} " == = " 0.0.0.0 " ) {
2018-10-16 14:58:25 +00:00
public_ip = window . location . hostname ;
} else {
public_ip = " {{ ip}} " ;
}
2018-10-17 01:15:42 +00:00
protocol = window . location . protocol ;
2018-12-09 20:23:51 +00:00
if ( window . location . port == = ' {{ current_port}} ' ) {
2018-10-17 03:25:04 +00:00
public_port = ' {{ port}} ' ;
} else {
public_port = window . location . port ;
}
2018-10-14 13:32:16 +00:00
function ping ( ) {
$ . ajax ( {
2018-10-17 03:25:04 +00:00
url : protocol + ' // ' + public_ip + ' : ' + public_port + ' {{ base_url}} ' ,
2018-10-14 13:32:16 +00:00
success : function ( result ) {
2018-10-17 03:25:04 +00:00
window . location . href = protocol + ' // ' + public_ip + ' : ' + public_port + ' {{ base_url}} ' ;
2018-10-14 13:32:16 +00:00
}
} ) ;
}
2018-11-30 02:24:48 +00:00
< / script >
< script type = " text/javascript " >
2019-02-25 04:05:58 +00:00
var url_notifications = location . protocol + " // " + window . location . host + " {{ base_url}}notifications " ;
var notificationTimeout ;
2019-02-21 04:30:25 +00:00
var timeout ;
var killer ;
2019-02-25 04:05:58 +00:00
function doNotificationsAjax ( ) {
2019-02-21 04:30:25 +00:00
$ . ajax ( {
2019-02-25 04:05:58 +00:00
url : url_notifications ,
2019-02-21 04:30:25 +00:00
success : function ( data ) {
if ( data != = " " ) {
data = JSON . parse ( data ) ;
var msg = data [ 0 ] ;
var type = data [ 1 ] ;
var duration = data [ 2 ] ;
var button = data [ 3 ] ;
2019-02-24 03:58:13 +00:00
var queue = data [ 4 ] ;
2019-02-21 04:30:25 +00:00
if ( duration == = ' temporary ' ) {
timeout = 3000 ;
2019-02-24 03:58:13 +00:00
killer = queue ;
2019-02-21 04:30:25 +00:00
} else {
timeout = false ;
killer = false ;
}
if ( button == = ' refresh ' ) {
button = [ Noty . button ( ' Refresh ' , ' ui tiny primary button ' , function ( ) { window . location . reload ( ) } ) ] ;
} else if ( button == = ' restart ' ) {
/ / to be completed
button = [ Noty . button ( ' Restart ' , ' ui tiny primary button ' , function ( ) { alert ( ' Restart not implemented yet! ' ) } ) ] ;
} else {
button = [ ] ;
}
2019-01-01 04:46:33 +00:00
2019-02-21 04:30:25 +00:00
new Noty ( {
text : msg ,
progressBar : false ,
animation : {
open : null ,
close : null
} ,
type : type ,
layout : ' bottomRight ' ,
theme : ' semanticui ' ,
2019-02-24 03:58:13 +00:00
queue : queue ,
2019-02-21 04:30:25 +00:00
timeout : timeout ,
killer : killer ,
buttons : button ,
force : true
} ) . show ( ) ;
}
} ,
complete : function ( data ) {
/ / Schedule the next
2019-02-25 04:05:58 +00:00
if ( data != = " " ) {
notificationTimeout = setTimeout ( doNotificationsAjax , 100 ) ;
2019-02-21 04:30:25 +00:00
} else {
2019-02-25 04:05:58 +00:00
notificationTimeout = setTimeout ( doNotificationsAjax , 1000 ) ;
2019-02-21 04:30:25 +00:00
}
}
} ) ;
}
2019-02-25 04:05:58 +00:00
notificationTimeout = setTimeout ( doNotificationsAjax , 1000 ) ;
2019-02-21 04:30:25 +00:00
$ ( window ) . bind ( ' beforeunload ' , function ( ) {
2019-02-25 04:05:58 +00:00
clearTimeout ( notificationTimeout ) ;
} ) ;
< / script >
< script type = " text/javascript " >
var url_tasks = location . protocol + " // " + window . location . host + " {{ base_url}}running_tasks " ;
var tasksTimeout ;
function doTasksAjax ( ) {
$ . ajax ( {
url : url_tasks ,
dataType : ' json ' ,
success : function ( data ) {
$ ( ' #tasks > tbody > tr ' ) . each ( function ( ) {
if ( $ . inArray ( $ ( this ) . attr ( ' id ' ) , data [ ' tasks ' ] ) > - 1 ) {
$ ( this ) . find ( ' td:last ' ) . find ( ' div:first ' ) . addClass ( ' disabled ' ) ;
$ ( this ) . find ( ' td:last ' ) . find ( ' div:first ' ) . find ( ' i:first ' ) . addClass ( ' loading ' ) ;
} else {
$ ( this ) . find ( ' td:last ' ) . find ( ' div:first ' ) . removeClass ( ' disabled ' ) ;
$ ( this ) . find ( ' td:last ' ) . find ( ' div:first ' ) . find ( ' i:first ' ) . removeClass ( ' loading ' ) ;
}
} ) ;
if ( $ . inArray ( ' wanted_search_missing_subtitles ' , data [ ' tasks ' ] ) > - 1 ) {
$ ( ' #wanted_search_missing_subtitles ' ) . addClass ( ' disabled ' ) ;
$ ( ' #wanted_search_missing_subtitles_movies ' ) . addClass ( ' disabled ' ) ;
$ ( ' #wanted_search_missing_subtitles ' ) . find ( ' i:first ' ) . addClass ( ' loading ' ) ;
$ ( ' #wanted_search_missing_subtitles_movies ' ) . find ( ' i:first ' ) . addClass ( ' loading ' ) ;
} else {
$ ( ' #wanted_search_missing_subtitles ' ) . removeClass ( ' disabled ' ) ;
$ ( ' #wanted_search_missing_subtitles_movies ' ) . removeClass ( ' disabled ' ) ;
$ ( ' #wanted_search_missing_subtitles ' ) . find ( ' i:first ' ) . removeClass ( ' loading ' ) ;
$ ( ' #wanted_search_missing_subtitles_movies ' ) . find ( ' i:first ' ) . removeClass ( ' loading ' ) ;
}
% if ' no ' in locals ( ) :
if ( $ . inArray ( ' search_missing_subtitles_ {{ no}} ' , data [ ' tasks ' ] ) > - 1 ) {
$ ( ' #search_missing_subtitles ' ) . addClass ( ' disabled ' ) ;
$ ( ' #search_missing_subtitles ' ) . find ( ' i:first ' ) . addClass ( ' loading ' ) ;
} else {
$ ( ' #search_missing_subtitles ' ) . removeClass ( ' disabled ' ) ;
$ ( ' #search_missing_subtitles ' ) . find ( ' i:first ' ) . removeClass ( ' loading ' ) ;
}
if ( $ . inArray ( ' search_missing_subtitles_movie_ {{ no}} ' , data [ ' tasks ' ] ) > - 1 ) {
$ ( ' #search_missing_subtitles_movie ' ) . addClass ( ' disabled ' ) ;
$ ( ' #search_missing_subtitles_movie ' ) . find ( ' i:first ' ) . addClass ( ' loading ' ) ;
} else {
$ ( ' #search_missing_subtitles_movie ' ) . removeClass ( ' disabled ' ) ;
$ ( ' #search_missing_subtitles_movie ' ) . find ( ' i:first ' ) . removeClass ( ' loading ' ) ;
}
% end
} ,
complete : function ( data ) {
/ / Schedule the next
tasksTimeout = setTimeout ( doTasksAjax , 5000 ) ;
}
} ) ;
}
tasksTimeout = setTimeout ( doTasksAjax , 500 ) ;
$ ( window ) . bind ( ' beforeunload ' , function ( ) {
clearTimeout ( tasksTimeout ) ;
2019-02-21 04:30:25 +00:00
} ) ;
2017-12-22 00:49:39 +00:00
< / script >