@ -136,6 +136,16 @@ def check_credentials(user, pw):
return False
@app.context_processor
def restart_processor ( ) :
def restart_required ( ) :
db = database . execute ( " SELECT configured, updated FROM system " )
for i in db :
restart_required = i
return restart_required
return dict ( restart_required = restart_required ( ) [ ' configured ' ] , update_required = restart_required ( ) [ ' updated ' ] , ast = ast , settings = settings )
def api_authorize ( ) :
if ' apikey ' in request . GET . dict :
if request . GET . dict [ ' apikey ' ] [ 0 ] == settings . auth . apikey :
@ -153,7 +163,7 @@ def post_get(name, default=''):
@app.route ( base_url + ' login/ ' )
def login_form ( ) :
msg = request . query . get ( ' msg ' , ' ' )
return render_template ( ' login ' , base_url = base_url , msg = msg )
return render_template ( ' login .html ' , base_url = base_url , msg = msg )
@app.route ( base_url + ' login/ ' , methods = [ ' POST ' ] )
@ -174,7 +184,6 @@ def logout():
@app.route ( base_url + ' shutdown/ ' )
# @custom_auth_basic(check_credentials)
def shutdown ( ) :
try :
server . stop ( )
except :
@ -194,7 +203,6 @@ def shutdown():
@app.route ( base_url + ' restart/ ' )
# @custom_auth_basic(check_credentials)
def restart ( ) :
try :
server . stop ( )
except :
@ -215,8 +223,6 @@ def restart():
@app.route ( base_url + ' wizard/ ' )
@custom_auth_basic ( check_credentials )
def wizard ( ) :
# Get languages list
settings_languages = database . execute ( " SELECT * FROM table_settings_languages ORDER BY name " )
# Get providers list
@ -230,8 +236,6 @@ def wizard():
@app.route ( base_url + ' save_wizard ' , methods = [ ' POST ' ] )
# @custom_auth_basic(check_credentials)
def save_wizard ( ) :
settings_general_ip = request . form . get ( ' settings_general_ip ' )
settings_general_port = request . form . get ( ' settings_general_port ' )
settings_general_baseurl = request . form . get ( ' settings_general_baseurl ' )
@ -446,7 +450,6 @@ def save_wizard():
@app.route ( base_url + ' emptylog ' )
# @custom_auth_basic(check_credentials)
def emptylog ( ) :
ref = request . environ [ ' HTTP_REFERER ' ]
empty_log ( )
@ -458,14 +461,12 @@ def emptylog():
@app.route ( base_url + ' bazarr.log ' )
# @custom_auth_basic(check_credentials)
def download_log ( ) :
return static_file ( ' bazarr.log ' , root = os . path . join ( args . config_dir , ' log/ ' ) , download = ' bazarr.log ' )
@app.route ( base_url + ' image_proxy/<path:url> ' , methods = [ ' GET ' ] )
# @custom_auth_basic(check_credentials)
def image_proxy ( url ) :
apikey = settings . sonarr . apikey
url_image = url_sonarr_short ( ) + ' / ' + url + ' ?apikey= ' + apikey
try :
@ -483,7 +484,6 @@ def image_proxy(url):
@app.route ( base_url + ' image_proxy_movies/<path:url> ' , methods = [ ' GET ' ] )
# @custom_auth_basic(check_credentials)
def image_proxy_movies ( url ) :
apikey = settings . radarr . apikey
try :
url_image = ( url_radarr_short ( ) + ' / ' + url + ' ?apikey= ' + apikey ) . replace ( ' /fanart.jpg ' , ' /banner.jpg ' )
@ -503,7 +503,6 @@ def image_proxy_movies(url):
@app.route ( base_url )
# @custom_auth_basic(check_credentials)
def redirect_root ( ) :
if settings . general . getboolean ( ' use_sonarr ' ) :
return redirect ( base_url + ' series ' )
elif settings . general . getboolean ( ' use_radarr ' ) :
@ -517,8 +516,6 @@ def redirect_root():
@app.route ( base_url + ' series/ ' )
# @custom_auth_basic(check_credentials)
def series ( ) :
series_count = database . execute ( " SELECT COUNT(*) as count FROM table_shows " , only_one = True ) [ ' count ' ]
page = request . data
if not page :
@ -564,7 +561,7 @@ def series():
" table_episodes.sonarrSeriesId WHERE table_shows.languages IS NOT ' None ' "
+ total_subtitles_clause + " GROUP BY table_shows.sonarrSeriesId " )
return render_template ( ' series ' , bazarr_version = bazarr_version , rows = data , missing_subtitles_list = missing_subtitles_list ,
return render_template ( ' series .html ' , bazarr_version = bazarr_version , rows = data , missing_subtitles_list = missing_subtitles_list ,
total_subtitles_list = total_subtitles_list , languages = languages , missing_count = series_count ,
page = page , max_page = max_page , base_url = base_url ,
single_language = settings . general . getboolean ( ' single_language ' ) , page_size = page_size ,
@ -575,7 +572,6 @@ def series():
# @custom_auth_basic(check_credentials)
def serieseditor ( ) :
# Get missing count
missing_count = database . execute ( " SELECT COUNT(*) as count FROM table_shows " , only_one = True ) [ ' count ' ]
@ -588,7 +584,7 @@ def serieseditor():
# Get languages list
languages = database . execute ( " SELECT code2, name FROM table_settings_languages WHERE enabled=1 " )
return render_template ( ' serieseditor ' , bazarr_version = bazarr_version , rows = data , languages = languages ,
return render_template ( ' serieseditor .html ' , bazarr_version = bazarr_version , rows = data , languages = languages ,
missing_count = missing_count , base_url = base_url ,
single_language = settings . general . getboolean ( ' single_language ' ) , current_port = settings . general . port )
@ -716,7 +712,7 @@ def episodes(no):
for key , season in itertools . groupby ( episodes , lambda x : x [ ' season ' ] ) :
seasons_list . append ( list ( season ) )
return render_template ( ' episodes ' , bazarr_version = bazarr_version , no = no , details = series_details ,
return render_template ( ' episodes .html ' , bazarr_version = bazarr_version , no = no , details = series_details ,
languages = languages , seasons = seasons_list , url_sonarr_short = url_sonarr_short ( ) , base_url = base_url ,
tvdbid = tvdbid , number = number , current_port = settings . general . port )
@ -742,7 +738,7 @@ def movies():
languages = database . execute ( " SELECT code2, name FROM table_settings_languages WHERE enabled=1 " )
return render_template ( ' movies ' , bazarr_version = bazarr_version , rows = data , languages = languages ,
return render_template ( ' movies .html ' , bazarr_version = bazarr_version , rows = data , languages = languages ,
missing_count = missing_count , page = page , max_page = max_page , base_url = base_url ,
single_language = settings . general . getboolean ( ' single_language ' ) , page_size = page_size ,
current_port = settings . general . port )
@ -762,7 +758,7 @@ def movieseditor():
languages = database . execute ( " SELECT code2, name FROM table_settings_languages WHERE enabled=1 " )
return render_template ( ' movieseditor ' , bazarr_version = bazarr_version , rows = data , languages = languages ,
return render_template ( ' movieseditor .html ' , bazarr_version = bazarr_version , rows = data , languages = languages ,
missing_count = missing_count , base_url = base_url , single_language =
settings . general . getboolean ( ' single_language ' ) , current_port = settings . general . port )
@ -851,7 +847,7 @@ def movie(no):
languages = database . execute ( " SELECT code2, name FROM table_settings_languages WHERE enabled=1 " )
return render_template ( ' movie ' , bazarr_version = bazarr_version , no = no , details = movies_details ,
return render_template ( ' movie .html ' , bazarr_version = bazarr_version , no = no , details = movies_details ,
languages = languages , url_radarr_short = url_radarr_short ( ) , base_url = base_url , tmdbid = tmdbid ,
current_port = settings . general . port )
@ -915,7 +911,7 @@ def historyseries():
row_count = database . execute ( " SELECT COUNT(*) as count FROM table_history LEFT JOIN table_shows on "
" table_history.sonarrSeriesId = table_shows.sonarrSeriesId WHERE "
" table_shows.title is not NULL " , only_one = True ) [ ' count ' ]
page = request . args. page
page = request . data
if page == " " :
page = " 1 "
page_size = int ( settings . general . page_size )
@ -981,7 +977,7 @@ def historyseries():
if int ( upgradable_episode [ ' score ' ] ) < 360 :
upgradable_episodes_not_perfect . append ( upgradable_episode )
return render_template ( ' historyseries ' , bazarr_version = bazarr_version , rows = data , row_count = row_count ,
return render_template ( ' historyseries .html ' , bazarr_version = bazarr_version , rows = data , row_count = row_count ,
page = page , max_page = max_page , stats = stats , base_url = base_url , page_size = page_size ,
current_port = settings . general . port , upgradable_episodes = upgradable_episodes_not_perfect )
@ -994,7 +990,7 @@ def historymovies():
row_count = database . execute ( " SELECT COUNT(*) as count FROM table_history_movie LEFT JOIN table_movies ON "
" table_history_movie.radarrId=table_movies.radarrId "
" WHERE table_movies.title is not NULL " , only_one = True ) [ ' count ' ]
page = request . args. page
page = request . data
if page == " " :
page = " 1 "
page_size = int ( settings . general . page_size )
@ -1058,7 +1054,7 @@ def historymovies():
if int ( upgradable_movie [ ' score ' ] ) < 120 :
upgradable_movies_not_perfect . append ( upgradable_movie )
return render_template ( ' historymovies ' , bazarr_version = bazarr_version , rows = data , row_count = row_count ,
return render_template ( ' historymovies .html ' , bazarr_version = bazarr_version , rows = data , row_count = row_count ,
page = page , max_page = max_page , stats = stats , base_url = base_url , page_size = page_size ,
current_port = settings . general . port , upgradable_movies = upgradable_movies_not_perfect )
@ -1067,7 +1063,7 @@ def historymovies():
# @custom_auth_basic(check_credentials)
def wanted ( ) :
return render_template ( ' wanted ' , bazarr_version = bazarr_version , base_url = base_url , current_port = settings . general . port )
return render_template ( ' wanted .html ' , bazarr_version = bazarr_version , base_url = base_url , current_port = settings . general . port )
@app.route ( base_url + ' wantedseries ' )
@ -1082,7 +1078,7 @@ def wantedseries():
missing_count = database . execute ( " SELECT COUNT(*) as count FROM table_episodes WHERE missing_subtitles != ' [] ' " +
monitored_only_query_string , only_one = True ) [ ' count ' ]
page = request . args. page
page = request . data
if page == " " :
page = " 1 "
page_size = int ( settings . general . page_size )
@ -1100,7 +1096,7 @@ def wantedseries():
# path_replace
dict_mapper . path_replace ( data )
return render_template ( ' wantedseries ' , bazarr_version = bazarr_version , rows = data , missing_count = missing_count , page = page ,
return render_template ( ' wantedseries .html ' , bazarr_version = bazarr_version , rows = data , missing_count = missing_count , page = page ,
max_page = max_page , base_url = base_url , page_size = page_size , current_port = settings . general . port )
@ -1130,7 +1126,7 @@ def wantedmovies():
# path_replace
dict_mapper . path_replace_movie ( data )
return render_template ( ' wantedmovies ' , bazarr_version = bazarr_version , rows = data ,
return render_template ( ' wantedmovies .html ' , bazarr_version = bazarr_version , rows = data ,
missing_count = missing_count , page = page , max_page = max_page , base_url = base_url , page_size = page_size ,
current_port = settings . general . port )
@ -1381,29 +1377,6 @@ def save_settings():
settings . auth . type = text_type ( settings_auth_type )
settings . auth . username = text_type ( settings_auth_username )
settings . auth . password = hashlib . md5 ( settings_auth_password . encode ( ' utf-8 ' ) ) . hexdigest ( )
if settings_auth_username not in aaa . _store . users :
cork = Cork ( os . path . normpath ( os . path . join ( args . config_dir , ' config ' ) ) , initialize = True )
cork . _store . roles [ ' ' ] = 100
cork . _store . save_roles ( )
cork . _store . users [ settings_auth_username ] = {
' role ' : ' ' ,
' hash ' : cork . _hash ( settings_auth_username , settings_auth_password ) ,
' email_addr ' : ' ' ,
' desc ' : ' ' ,
' creation_date ' : time . time ( )
}
cork . _store . save_users ( )
if settings_auth_type == ' basic ' or settings_auth_type == ' None ' :
pass
else :
aaa . _beaker_session . delete ( )
else :
if settings . auth . password != settings_auth_password :
aaa . user ( settings_auth_username ) . update ( role = ' ' , pwd = settings_auth_password )
if settings_auth_type == ' basic ' or settings_auth_type == ' None ' :
pass
else :
aaa . _beaker_session . delete ( )
settings . auth . apikey = request . form . get ( ' settings_auth_apikey ' )
settings_sonarr_ip = request . form . get ( ' settings_sonarr_ip ' )
@ -1678,7 +1651,7 @@ def system():
page_size = int ( settings . general . page_size )
return render_template ( ' system ' , bazarr_version = bazarr_version ,
return render_template ( ' system .html ' , bazarr_version = bazarr_version ,
sonarr_version = sonarr_version , radarr_version = radarr_version ,
operating_system = platform . platform ( ) , python_version = platform . python_version ( ) ,
config_dir = args . config_dir , bazarr_dir = os . path . normcase ( os . path . dirname ( os . path . dirname ( __file__ ) ) ) ,