Add Feature Request #229

pull/292/head
Halali 6 years ago
parent 3ac4b75b88
commit 1cc7efa413

@ -31,7 +31,6 @@ defaults = {
'page_size': '25', 'page_size': '25',
'minimum_score_movie': '70', 'minimum_score_movie': '70',
'use_embedded_subs': 'True', 'use_embedded_subs': 'True',
'only_monitored': 'False',
'adaptive_searching': 'False', 'adaptive_searching': 'False',
'enabled_providers': '' 'enabled_providers': ''
}, },
@ -46,7 +45,8 @@ defaults = {
'base_url': '/', 'base_url': '/',
'ssl': 'False', 'ssl': 'False',
'apikey': '', 'apikey': '',
'full_update': 'Daily' 'full_update': 'Daily',
'only_monitored': 'False',
}, },
'radarr': { 'radarr': {
'ip': '127.0.0.1', 'ip': '127.0.0.1',
@ -54,7 +54,8 @@ defaults = {
'base_url': '/', 'base_url': '/',
'ssl': 'False', 'ssl': 'False',
'apikey': '', 'apikey': '',
'full_update': 'Daily' 'full_update': 'Daily',
'only_monitored': 'False',
}, },
'proxy': { 'proxy': {
'type': 'None', 'type': 'None',

@ -351,7 +351,7 @@ def manual_download_subtitle(path, language, hi, subtitle, provider, providers_a
def series_download_subtitles(no): def series_download_subtitles(no):
if settings.general.getboolean('only_monitored'): if settings.sonarr.getboolean('only_monitored'):
monitored_only_query_string = ' AND monitored = "True"' monitored_only_query_string = ' AND monitored = "True"'
else: else:
monitored_only_query_string = "" monitored_only_query_string = ""
@ -485,7 +485,7 @@ def wanted_search_missing_subtitles():
db.create_function("path_substitution_movie", 1, path_replace_movie) db.create_function("path_substitution_movie", 1, path_replace_movie)
c = db.cursor() c = db.cursor()
if settings.general.getboolean('only_monitored'): if settings.sonarr.getboolean('only_monitored'):
monitored_only_query_string = ' AND monitored = "True"' monitored_only_query_string = ' AND monitored = "True"'
else: else:
monitored_only_query_string = "" monitored_only_query_string = ""
@ -510,7 +510,7 @@ def wanted_search_missing_subtitles():
def search_active(timestamp): def search_active(timestamp):
if settings.general.getboolean('only_monitored'): if settings.general.getboolean('adaptive_searching'):
search_deadline = timedelta(weeks=3) search_deadline = timedelta(weeks=3)
search_delta = timedelta(weeks=1) search_delta = timedelta(weeks=1)
aa = datetime.fromtimestamp(float(timestamp)) aa = datetime.fromtimestamp(float(timestamp))

@ -85,6 +85,14 @@ if cfg.has_section('general'):
cfg.set('general', 'debug', 'False') cfg.set('general', 'debug', 'False')
with open(config_file, 'w+') as configfile: with open(config_file, 'w+') as configfile:
cfg.write(configfile) cfg.write(configfile)
if cfg.has_option('general', 'only_monitored'):
only_monitored = cfg.get('general', 'only_monitored')
cfg.set('sonarr', 'only_monitored', str(only_monitored))
cfg.set('radarr', 'only_monitored', str(only_monitored))
cfg.remove_option('general', 'only_monitored')
with open(config_file, 'w+') as configfile:
cfg.write(configfile)
# Move providers settings from DB to config file # Move providers settings from DB to config file
try: try:

@ -266,11 +266,6 @@ def save_wizard():
settings_general_single_language = 'False' settings_general_single_language = 'False'
else: else:
settings_general_single_language = 'True' settings_general_single_language = 'True'
settings_general_adaptive_searching = request.forms.get('settings_general_adaptive_searching')
if settings_general_adaptive_searching is None:
settings_general_adaptive_searching = 'False'
else:
settings_general_adaptive_searching = 'True'
settings_general_use_sonarr = request.forms.get('settings_general_use_sonarr') settings_general_use_sonarr = request.forms.get('settings_general_use_sonarr')
if settings_general_use_sonarr is None: if settings_general_use_sonarr is None:
settings_general_use_sonarr = 'False' settings_general_use_sonarr = 'False'
@ -290,7 +285,6 @@ def save_wizard():
settings.general.use_sonarr = text_type(settings_general_use_sonarr) settings.general.use_sonarr = text_type(settings_general_use_sonarr)
settings.general.use_radarr = text_type(settings_general_use_radarr) settings.general.use_radarr = text_type(settings_general_use_radarr)
settings.general.path_mappings_movie = text_type(settings_general_pathmapping_movie) settings.general.path_mappings_movie = text_type(settings_general_pathmapping_movie)
settings.general.adaptive_searching = text_type(settings_general_adaptive_searching)
settings_sonarr_ip = request.forms.get('settings_sonarr_ip') settings_sonarr_ip = request.forms.get('settings_sonarr_ip')
settings_sonarr_port = request.forms.get('settings_sonarr_port') settings_sonarr_port = request.forms.get('settings_sonarr_port')
@ -301,12 +295,18 @@ def save_wizard():
else: else:
settings_sonarr_ssl = 'True' settings_sonarr_ssl = 'True'
settings_sonarr_apikey = request.forms.get('settings_sonarr_apikey') settings_sonarr_apikey = request.forms.get('settings_sonarr_apikey')
settings_sonarr_only_monitored = request.forms.get('settings_sonarr_only_monitored')
if settings_sonarr_only_monitored is None:
settings_sonarr_only_monitored = 'False'
else:
settings_sonarr_only_monitored = 'True'
settings.sonarr.ip = text_type(settings_sonarr_ip) settings.sonarr.ip = text_type(settings_sonarr_ip)
settings.sonarr.port = text_type(settings_sonarr_port) settings.sonarr.port = text_type(settings_sonarr_port)
settings.sonarr.base_url = text_type(settings_sonarr_baseurl) settings.sonarr.base_url = text_type(settings_sonarr_baseurl)
settings.sonarr.ssl = text_type(settings_sonarr_ssl) settings.sonarr.ssl = text_type(settings_sonarr_ssl)
settings.sonarr.apikey = text_type(settings_sonarr_apikey) settings.sonarr.apikey = text_type(settings_sonarr_apikey)
settings.sonarr.only_monitored = text_type(settings_sonarr_only_monitored)
settings_radarr_ip = request.forms.get('settings_radarr_ip') settings_radarr_ip = request.forms.get('settings_radarr_ip')
settings_radarr_port = request.forms.get('settings_radarr_port') settings_radarr_port = request.forms.get('settings_radarr_port')
@ -317,16 +317,18 @@ def save_wizard():
else: else:
settings_radarr_ssl = 'True' settings_radarr_ssl = 'True'
settings_radarr_apikey = request.forms.get('settings_radarr_apikey') settings_radarr_apikey = request.forms.get('settings_radarr_apikey')
if settings_radarr_apikey != '': settings_radarr_only_monitored = request.forms.get('settings_radarr_only_monitored')
settings.general.use_radarr = 'True' if settings_radarr_only_monitored is None:
settings_radarr_only_monitored = 'False'
else: else:
settings.general.use_radarr = 'False' settings_radarr_only_monitored = 'True'
settings.radarr.ip = text_type(settings_radarr_ip) settings.radarr.ip = text_type(settings_radarr_ip)
settings.radarr.port = text_type(settings_radarr_port) settings.radarr.port = text_type(settings_radarr_port)
settings.radarr.base_url = text_type(settings_radarr_baseurl) settings.radarr.base_url = text_type(settings_radarr_baseurl)
settings.radarr.ssl = text_type(settings_radarr_ssl) settings.radarr.ssl = text_type(settings_radarr_ssl)
settings.radarr.apikey = text_type(settings_radarr_apikey) settings.radarr.apikey = text_type(settings_radarr_apikey)
settings.radarr.only_monitored = text_type(settings_radarr_only_monitored)
settings_subliminal_providers = request.forms.getall('settings_subliminal_providers') settings_subliminal_providers = request.forms.getall('settings_subliminal_providers')
settings.general.enabled_providers = u'' if not settings_subliminal_providers else ','.join(settings_subliminal_providers) settings.general.enabled_providers = u'' if not settings_subliminal_providers else ','.join(settings_subliminal_providers)
@ -477,7 +479,7 @@ def series():
offset = (int(page) - 1) * page_size offset = (int(page) - 1) * page_size
max_page = int(math.ceil(missing_count / (page_size + 0.0))) max_page = int(math.ceil(missing_count / (page_size + 0.0)))
if settings.general.getboolean('only_monitored'): if settings.sonarr.getboolean('only_monitored'):
monitored_only_query_string = ' AND monitored = "True"' monitored_only_query_string = ' AND monitored = "True"'
else: else:
monitored_only_query_string = "" monitored_only_query_string = ""
@ -927,7 +929,7 @@ def wantedseries():
db.create_function("path_substitution", 1, path_replace) db.create_function("path_substitution", 1, path_replace)
c = db.cursor() c = db.cursor()
if settings.general.getboolean('only_monitored'): if settings.sonarr.getboolean('only_monitored'):
monitored_only_query_string = ' AND monitored = "True"' monitored_only_query_string = ' AND monitored = "True"'
else: else:
monitored_only_query_string = "" monitored_only_query_string = ""
@ -956,7 +958,7 @@ def wantedmovies():
db.create_function("path_substitution", 1, path_replace_movie) db.create_function("path_substitution", 1, path_replace_movie)
c = db.cursor() c = db.cursor()
if settings.general.getboolean('only_monitored'): if settings.radarr.getboolean('only_monitored'):
monitored_only_query_string = ' AND monitored = "True"' monitored_only_query_string = ' AND monitored = "True"'
else: else:
monitored_only_query_string = "" monitored_only_query_string = ""
@ -1053,11 +1055,6 @@ def save_settings():
settings_general_embedded = 'False' settings_general_embedded = 'False'
else: else:
settings_general_embedded = 'True' settings_general_embedded = 'True'
settings_general_only_monitored = request.forms.get('settings_general_only_monitored')
if settings_general_only_monitored is None:
settings_general_only_monitored = 'False'
else:
settings_general_only_monitored = 'True'
settings_general_adaptive_searching = request.forms.get('settings_general_adaptive_searching') settings_general_adaptive_searching = request.forms.get('settings_general_adaptive_searching')
if settings_general_adaptive_searching is None: if settings_general_adaptive_searching is None:
settings_general_adaptive_searching = 'False' settings_general_adaptive_searching = 'False'
@ -1104,7 +1101,6 @@ def save_settings():
settings.general.page_size = text_type(settings_page_size) settings.general.page_size = text_type(settings_page_size)
settings.general.minimum_score_movie = text_type(settings_general_minimum_score_movies) settings.general.minimum_score_movie = text_type(settings_general_minimum_score_movies)
settings.general.use_embedded_subs = text_type(settings_general_embedded) settings.general.use_embedded_subs = text_type(settings_general_embedded)
settings.general.only_monitored = text_type(settings_general_only_monitored)
settings.general.adaptive_searching = text_type(settings_general_adaptive_searching) settings.general.adaptive_searching = text_type(settings_general_adaptive_searching)
if after != before: if after != before:
@ -1180,6 +1176,11 @@ def save_settings():
else: else:
settings_sonarr_ssl = 'True' settings_sonarr_ssl = 'True'
settings_sonarr_apikey = request.forms.get('settings_sonarr_apikey') settings_sonarr_apikey = request.forms.get('settings_sonarr_apikey')
settings_sonarr_only_monitored = request.forms.get('settings_sonarr_only_monitored')
if settings_sonarr_only_monitored is None:
settings_sonarr_only_monitored = 'False'
else:
settings_sonarr_only_monitored = 'True'
settings_sonarr_sync = request.forms.get('settings_sonarr_sync') settings_sonarr_sync = request.forms.get('settings_sonarr_sync')
settings.sonarr.ip = text_type(settings_sonarr_ip) settings.sonarr.ip = text_type(settings_sonarr_ip)
@ -1187,6 +1188,7 @@ def save_settings():
settings.sonarr.base_url = text_type(settings_sonarr_baseurl) settings.sonarr.base_url = text_type(settings_sonarr_baseurl)
settings.sonarr.ssl = text_type(settings_sonarr_ssl) settings.sonarr.ssl = text_type(settings_sonarr_ssl)
settings.sonarr.apikey = text_type(settings_sonarr_apikey) settings.sonarr.apikey = text_type(settings_sonarr_apikey)
settings.sonarr.only_monitored = text_type(settings_sonarr_only_monitored)
settings.sonarr.full_update = text_type(settings_sonarr_sync) settings.sonarr.full_update = text_type(settings_sonarr_sync)
settings_radarr_ip = request.forms.get('settings_radarr_ip') settings_radarr_ip = request.forms.get('settings_radarr_ip')
@ -1198,6 +1200,11 @@ def save_settings():
else: else:
settings_radarr_ssl = 'True' settings_radarr_ssl = 'True'
settings_radarr_apikey = request.forms.get('settings_radarr_apikey') settings_radarr_apikey = request.forms.get('settings_radarr_apikey')
settings_radarr_only_monitored = request.forms.get('settings_radarr_only_monitored')
if settings_radarr_only_monitored is None:
settings_radarr_only_monitored = 'False'
else:
settings_radarr_only_monitored = 'True'
settings_radarr_sync = request.forms.get('settings_radarr_sync') settings_radarr_sync = request.forms.get('settings_radarr_sync')
settings.radarr.ip = text_type(settings_radarr_ip) settings.radarr.ip = text_type(settings_radarr_ip)
@ -1205,6 +1212,7 @@ def save_settings():
settings.radarr.base_url = text_type(settings_radarr_baseurl) settings.radarr.base_url = text_type(settings_radarr_baseurl)
settings.radarr.ssl = text_type(settings_radarr_ssl) settings.radarr.ssl = text_type(settings_radarr_ssl)
settings.radarr.apikey = text_type(settings_radarr_apikey) settings.radarr.apikey = text_type(settings_radarr_apikey)
settings.radarr.only_monitored = text_type(settings_radarr_only_monitored)
settings.radarr.full_update = text_type(settings_radarr_sync) settings.radarr.full_update = text_type(settings_radarr_sync)
settings_subliminal_providers = request.forms.getall('settings_subliminal_providers') settings_subliminal_providers = request.forms.getall('settings_subliminal_providers')

@ -1,4 +0,0 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

@ -1,4 +0,0 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

@ -1,4 +0,0 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

@ -1,4 +0,0 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

@ -28,16 +28,22 @@
% import sqlite3 % import sqlite3
% from config import settings % from config import settings
%if settings.general.getboolean('only_monitored'): %if settings.sonarr.getboolean('only_monitored'):
% monitored_only_query_string = ' AND monitored = "True"' % monitored_only_query_string_sonarr = ' AND monitored = "True"'
%else: %else:
% monitored_only_query_string = "" % 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 = ""
%end %end
% conn = sqlite3.connect(os.path.join(config_dir, 'db', 'bazarr.db'), timeout=30) % conn = sqlite3.connect(os.path.join(config_dir, 'db', 'bazarr.db'), timeout=30)
% c = conn.cursor() % c = conn.cursor()
% wanted_series = c.execute("SELECT COUNT(*) FROM table_episodes WHERE missing_subtitles != '[]'" + monitored_only_query_string).fetchone() % 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).fetchone() % wanted_movies = c.execute("SELECT COUNT(*) FROM table_movies WHERE missing_subtitles != '[]'" + monitored_only_query_string_radarr).fetchone()
<div id="divmenu" class="ui container"> <div id="divmenu" class="ui container">
<div class="ui grid"> <div class="ui grid">

@ -780,6 +780,26 @@
</div> </div>
</div> </div>
</div> </div>
<div class="middle aligned row">
<div class="right aligned four wide column">
<label>Download only monitored</label>
</div>
<div class="one wide column">
<div id="settings_only_monitored_sonarr" class="ui toggle checkbox" data-monitored={{settings.sonarr.getboolean('only_monitored')}}>
<input name="settings_sonarr_only_monitored" type="checkbox">
<label></label>
</div>
</div>
<div class="collapsed column">
<div class="collapsed center aligned column">
<div class="ui basic icon" data-tooltip="Automatic download of subtitles will happen only for monitored episodes in Sonarr." data-inverted="">
<i class="help circle large icon"></i>
</div>
</div>
</div>
</div>
</div> </div>
</div> </div>
@ -906,6 +926,26 @@
</div> </div>
</div> </div>
</div> </div>
<div class="middle aligned row">
<div class="right aligned four wide column">
<label>Download only monitored</label>
</div>
<div class="one wide column">
<div id="settings_only_monitored_radarr" class="ui toggle checkbox" data-monitored={{settings.radarr.getboolean('only_monitored')}}>
<input name="settings_radarr_only_monitored" type="checkbox">
<label></label>
</div>
</div>
<div class="collapsed column">
<div class="collapsed center aligned column">
<div class="ui basic icon" data-tooltip="Automatic download of subtitles will happen only for monitored movies in Radarr." data-inverted="">
<i class="help circle large icon"></i>
</div>
</div>
</div>
</div>
</div> </div>
</div> </div>
@ -1018,25 +1058,6 @@
</div> </div>
</div> </div>
<div class="middle aligned row">
<div class="right aligned four wide column">
<label>Download only monitored</label>
</div>
<div class="one wide column">
<div id="settings_only_monitored" class="ui toggle checkbox" data-monitored={{settings.general.getboolean('only_monitored')}}>
<input name="settings_general_only_monitored" type="checkbox">
<label></label>
</div>
</div>
<div class="collapsed column">
<div class="collapsed center aligned column">
<div class="ui basic icon" data-tooltip="Automatic download of subtitles will happen only for monitored episodes/movies in Sonarr/Radarr." data-inverted="">
<i class="help circle large icon"></i>
</div>
</div>
</div>
</div>
<div class="middle aligned row"> <div class="middle aligned row">
<div class="right aligned four wide column"> <div class="right aligned four wide column">
<label>Adaptive searching</label> <label>Adaptive searching</label>
@ -1424,10 +1445,16 @@
$("#settings_embedded").checkbox('uncheck'); $("#settings_embedded").checkbox('uncheck');
} }
if ($('#settings_only_monitored').data("monitored") === "True") { if ($('#settings_only_monitored_sonarr').data("monitored") === "True") {
$("#settings_only_monitored").checkbox('check'); $("#settings_only_monitored_sonarr").checkbox('check');
} else {
$("#settings_only_monitored_sonarr").checkbox('uncheck');
}
if ($('#settings_only_monitored_radarr').data("monitored") === "True") {
$("#settings_only_monitored_radarr").checkbox('check');
} else { } else {
$("#settings_only_monitored").checkbox('uncheck'); $("#settings_only_monitored_radarr").checkbox('uncheck');
} }
if ($('#settings_adaptive_searching').data("adaptive") === "True") { if ($('#settings_adaptive_searching').data("adaptive") === "True") {

@ -38,16 +38,22 @@
% import sqlite3 % import sqlite3
% from config import settings % from config import settings
%if settings.general.getboolean('only_monitored'): %if settings.sonarr.getboolean('only_monitored'):
% monitored_only_query_string = ' AND monitored = "True"' % monitored_only_query_string_sonarr = ' AND monitored = "True"'
%else: %else:
% monitored_only_query_string = "" % 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 = ""
%end %end
% conn = sqlite3.connect(os.path.join(config_dir, 'db', 'bazarr.db'), timeout=30) % conn = sqlite3.connect(os.path.join(config_dir, 'db', 'bazarr.db'), timeout=30)
% c = conn.cursor() % c = conn.cursor()
% wanted_series = c.execute("SELECT COUNT(*) FROM table_episodes WHERE missing_subtitles != '[]'" + monitored_only_query_string).fetchone() % 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).fetchone() % wanted_movies = c.execute("SELECT COUNT(*) FROM table_movies WHERE missing_subtitles != '[]'" + monitored_only_query_string_radarr).fetchone()
% c.close() % c.close()
<div id='loader' class="ui page dimmer"> <div id='loader' class="ui page dimmer">

@ -648,6 +648,25 @@
</div> </div>
</div> </div>
</div> </div>
<div class="sonarr_hide middle aligned row">
<div class="right aligned four wide column">
<label>Download only monitored</label>
</div>
<div class="one wide column">
<div id="settings_only_monitored_sonarr" class="ui toggle checkbox" data-monitored={{settings.sonarr.getboolean('only_monitored')}}>
<input name="settings_sonarr_only_monitored" type="checkbox">
<label></label>
</div>
</div>
<div class="collapsed column">
<div class="collapsed center aligned column">
<div class="ui basic icon" data-tooltip="Automatic download of subtitles will happen only for monitored episodes in Sonarr." data-inverted="">
<i class="help circle large icon"></i>
</div>
</div>
</div>
</div>
</div> </div>
</div> </div>
@ -780,6 +799,25 @@
</div> </div>
</div> </div>
</div> </div>
<div class="radarr_hide middle aligned row">
<div class="right aligned four wide column">
<label>Download only monitored</label>
</div>
<div class="one wide column">
<div id="settings_only_monitored_radarr" class="ui toggle checkbox" data-monitored={{settings.radarr.getboolean('only_monitored')}}>
<input name="settings_radarr_only_monitored" type="checkbox">
<label></label>
</div>
</div>
<div class="collapsed column">
<div class="collapsed center aligned column">
<div class="ui basic icon" data-tooltip="Automatic download of subtitles will happen only for monitored movies in Radarr." data-inverted="">
<i class="help circle large icon"></i>
</div>
</div>
</div>
</div>
</div> </div>
</div> </div>
@ -967,6 +1005,18 @@ $(function() {
$("#settings_movie_default_hi_div").addClass('disabled'); $("#settings_movie_default_hi_div").addClass('disabled');
} }
if ($('#settings_only_monitored_sonarr').data("monitored") === "True") {
$("#settings_only_monitored_sonarr").checkbox('check');
} else {
$("#settings_only_monitored_sonarr").checkbox('uncheck');
}
if ($('#settings_only_monitored_radarr').data("monitored") === "True") {
$("#settings_only_monitored_radarr").checkbox('check');
} else {
$("#settings_only_monitored_radarr").checkbox('uncheck');
}
$('#settings_movie_default_enabled_div').checkbox({ $('#settings_movie_default_enabled_div').checkbox({
onChecked: function() { onChecked: function() {
$("#settings_movie_default_languages").parent().removeClass('disabled'); $("#settings_movie_default_languages").parent().removeClass('disabled');

Loading…
Cancel
Save