Merge remote-tracking branch 'origin/develop' into feature/autopep8

* origin/develop:
  Fix more config saving options
This commit is contained in:
Jesse Mullan
2014-11-01 16:16:24 -07:00
4 changed files with 73 additions and 41 deletions

View File

@@ -86,7 +86,7 @@
<fieldset>
<legend>API</legend>
<div class="row checkbox">
<input type="checkbox" id="useapi" name="api_enabled" id="api_enabled" value="1" ${config['api_enabled']} />
<input type="checkbox" id="api_enabled" name="api_enabled" value="1" ${config['api_enabled']} />
<label title="Allow remote applications to interface with Headphones">
Enable API
</label>
@@ -414,7 +414,8 @@
<fieldset>
<legend>Headphones Indexer</legend>
<div class="row checkbox">
<input id="headphones_indexer" type="checkbox" name="headphones_indexer" onclick="initConfigCheckbox($(this));" value="1" ${config['headphones_indexer']} /><label>Use Headphones Indexer</label>
<input id="headphones_indexer" type="checkbox" name="headphones_indexer" onclick="initConfigCheckbox($(this));" value="1" ${config['headphones_indexer']} />
<label>Use Headphones Indexer</label>
</div>
<div class="config">
<div class="row">
@@ -434,7 +435,7 @@
<fieldset>
<legend>Custom Newznab Providers</legend>
<div class="row checkbox">
<input id="usenewznab" type="checkbox" name="newznab" onclick="initConfigCheckbox($(this));" value="1" ${config['use_newznab']} /><label>Use Newznab</label>
<input id="use_newznab" type="checkbox" name="use_newznab" onclick="initConfigCheckbox($(this));" value="1" ${config['use_newznab']} /><label>Use Newznab</label>
</div>
<div id="newznab_providers">
<div class="config" id="newznab1">
@@ -488,7 +489,7 @@
<fieldset>
<legend>NZBs.org</legend>
<div class="row checkbox">
<input id="usenzbsorg" type="checkbox" name="nzbsorg" onclick="initConfigCheckbox($(this));" value="1" ${config['use_nzbsorg']} /><label>Use NZBs.org</label>
<input id="use_nzbsorg" type="checkbox" name="use_nzbsorg" onclick="initConfigCheckbox($(this));" value="1" ${config['use_nzbsorg']} /><label>Use NZBs.org</label>
</div>
<div class="config">
<div class="row">
@@ -500,7 +501,7 @@
<fieldset>
<legend>omgwtfnzbs</legend>
<div class="row checkbox">
<input id="useomgwtfnzbs" type="checkbox" name="omgwtfnzbs" onclick="initConfigCheckbox($(this));" value="1" ${config['use_omgwtfnzbs']} /><label>Use omgwtfnzbs</label>
<input id="use_omgwtfnzbs" type="checkbox" name="use_omgwtfnzbs" onclick="initConfigCheckbox($(this));" value="1" ${config['use_omgwtfnzbs']} /><label>Use omgwtfnzbs</label>
</div>
<div class="config">
<div class="row">
@@ -521,7 +522,7 @@
<fieldset>
<legend>The Pirate Bay</legend>
<div class="row checkbox">
<input id="usepiratebay" type="checkbox" name="use_piratebay" value="1" ${config['use_piratebay']} /><label>Use The Pirate Bay</label>
<input id="use_piratebay" type="checkbox" name="use_piratebay" value="1" ${config['use_piratebay']} /><label>Use The Pirate Bay</label>
</div>
<div class="config">
<div class="row">
@@ -538,7 +539,7 @@
<fieldset>
<legend>Kick Ass Torrents</legend>
<div class="row checkbox">
<input id="usekat" type="checkbox" name="use_kat" value="1" ${config['use_kat']} /><label>Use Kick Ass Torrents</label>
<input id="use_kat" type="checkbox" name="use_kat" value="1" ${config['use_kat']} /><label>Use Kick Ass Torrents</label>
</div>
<div class="config">
<div class="row">
@@ -555,7 +556,7 @@
<fieldset>
<legend>Waffles.fm</legend>
<div class="row checkbox">
<input id="usewaffles" type="checkbox" name="waffles" onclick="initConfigCheckbox($(this));" value="1" ${config['use_waffles']} /><label>Use Waffles.fm</label>
<input id="use_waffles" type="checkbox" name="use_waffles" onclick="initConfigCheckbox($(this));" value="1" ${config['use_waffles']} /><label>Use Waffles.fm</label>
</div>
<div class="config">
<div class="row">
@@ -576,7 +577,7 @@
<fieldset>
<legend>rutracker.org</legend>
<div class="row checkbox">
<input id="userutracker" type="checkbox" name="rutracker" onclick="initConfigCheckbox($(this));" value="1" ${config['use_rutracker']} /><label>Use rutracker.org</label>
<input id="use_rutracker" type="checkbox" name="use_rutracker" onclick="initConfigCheckbox($(this));" value="1" ${config['use_rutracker']} /><label>Use rutracker.org</label>
</div>
<div class="config">
<div class="row">
@@ -597,7 +598,7 @@
<fieldset>
<legend>What.cd</legend>
<div class="row checkbox">
<input id="usewhatcd" type="checkbox" name="whatcd" onclick="initConfigCheckbox($(this));" value="1" ${config['use_whatcd']} /><label>Use What.cd</label>
<input id="use_whatcd" type="checkbox" name="use_whatcd" onclick="initConfigCheckbox($(this));" value="1" ${config['use_whatcd']} /><label>Use What.cd</label>
</div>
<div class="config">
<div class="row">
@@ -618,7 +619,7 @@
<fieldset>
<legend>Mininova</legend>
<div class="row checkbox">
<input id="usemininova" type="checkbox" name="use_mininova" value="1" ${config['use_mininova']} /><label>Use Mininova</label>
<input id="use_mininova" type="checkbox" name="use_mininova" value="1" ${config['use_mininova']} /><label>Use Mininova</label>
</div>
<div class="config">
<div class="row">
@@ -2031,16 +2032,16 @@
});
initActions();
initConfigCheckbox("#headphones_indexer");
initConfigCheckbox("#usenewznab");
initConfigCheckbox("#usenzbsorg");
initConfigCheckbox("#useomgwtfnzbs");
initConfigCheckbox("#usekat");
initConfigCheckbox("#usepiratebay");
initConfigCheckbox("#usemininova");
initConfigCheckbox("#usewaffles");
initConfigCheckbox("#userutracker");
initConfigCheckbox("#usewhatcd");
initConfigCheckbox("#useapi");
initConfigCheckbox("#use_newznab");
initConfigCheckbox("#use_nzbsorg");
initConfigCheckbox("#use_omgwtfnzbs");
initConfigCheckbox("#use_kat");
initConfigCheckbox("#use_piratebay");
initConfigCheckbox("#use_mininova");
initConfigCheckbox("#use_waffles");
initConfigCheckbox("#use_rutracker");
initConfigCheckbox("#use_whatcd");
initConfigCheckbox("#api_enabled");
initConfigCheckbox("#enable_https");

View File

@@ -318,8 +318,10 @@ class Config(object):
def add_extra_newznab(self, newznab):
""" Add a new extra newznab """
extra_newznabs = self.EXTRA_NEWZNABS
for item in newznab:
self.EXTRA_NEWZNABS.append(item)
extra_newznabs.append(item)
self.EXTRA_NEWZNABS = extra_newznabs
def __getattr__(self, name):
"""

View File

@@ -153,17 +153,17 @@ def get_seed_ratio(provider):
"""
if provider == 'rutracker.org':
seed_ratio = headphones.RUTRACKER_RATIO
seed_ratio = headphones.CONFIG.RUTRACKER_RATIO
elif provider == 'Kick Ass Torrents':
seed_ratio = headphones.KAT_RATIO
seed_ratio = headphones.CONFIG.KAT_RATIO
elif provider == 'What.cd':
seed_ratio = headphones.WHATCD_RATIO
seed_ratio = headphones.CONFIG.WHATCD_RATIO
elif provider == 'The Pirate Bay':
seed_ratio = headphones.PIRATEBAY_RATIO
seed_ratio = headphones.CONFIG.PIRATEBAY_RATIO
elif provider == 'Waffles.fm':
seed_ratio = headphones.WAFFLES_RATIO
seed_ratio = headphones.CONFIG.WAFFLES_RATIO
elif provider == 'Mininova':
seed_ratio = headphones.MININOVA_RATIO
seed_ratio = headphones.CONFIG.MININOVA_RATIO
else:
seed_ratio = None

View File

@@ -1166,18 +1166,45 @@ class WebInterface(object):
def configUpdate(self, **kwargs):
# Handle the variable config options. Note - keys with False values aren't getting passed
headphones.CONFIG.clear_extra_newznabs()
for kwarg in kwargs:
if kwarg.startswith('newznab_host'):
newznab_number = kwarg[12:]
if len(newznab_number):
newznab_host = kwargs.get('newznab_host' + newznab_number)
newznab_api = kwargs.get('newznab_api' + newznab_number)
try:
newznab_enabled = int(kwargs.get('newznab_enabled' + newznab_number))
except KeyError:
newznab_enabled = 0
headphones.CONFIG.add_extra_newznab((newznab_host, newznab_api, newznab_enabled))
checked_configs = [
"launch_browser", "enable_https", "api_enabled", "use_blackhole", "headphones_indexer", "use_newznab", "newznab_enabled",
"use_nzbsorg", "use_omgwtfnzbs", "use_kat", "use_piratebay", "use_mininova", "use_waffles", "use_rutracker", "use_whatcd",
"preferred_bitrate_allow_lossless", "detect_bitrate", "freeze_db", "move_files", "rename_files", "correct_metadata",
"cleanup_files", "keep_nfo", "add_album_art", "embed_album_art", "embed_lyrics", "replace_existing_folders", "file_underscores",
"include_extras", "autowant_upcoming", "autowant_all", "autowant_manually_added", "keep_torrent_files", "music_encoder",
"encoderlossless", "encoder_multicore", "delete_lossless_files", "growl_enabled", "growl_onsnatch", "prowl_enabled",
"prowl_onsnatch", "xbmc_enabled", "xbmc_update", "xbmc_notify", "lms_enabled", "plex_enabled", "plex_update", "plex_notify",
"nma_enabled", "nma_onsnatch", "pushalot_enabled", "pushalot_onsnatch", "synoindex_enabled", "pushover_enabled",
"pushover_onsnatch", "pushbullet_enabled", "pushbullet_onsnatch", "subsonic_enabled", "twitter_enabled", "twitter_onsnatch",
"osx_notify_enabled", "osx_notify_onsnatch", "boxcar_enabled", "boxcar_onsnatch", "songkick_enabled", "songkick_filter_enabled",
"mpc_enabled"
]
for checked_config in checked_configs:
if checked_config not in kwargs:
# checked items should be zero or one. if they were not sent then the item was not checked
kwargs[checked_config] = 0
for plain_config, use_config in [(x[4:], x) for x in kwargs if x.startswith('use_')]:
# the use prefix is fairly nice in the html, but does not match the actual config
kwargs[plain_config] = kwargs[use_config]
del kwargs[use_config]
extra_newznabs = []
for kwarg in [x for x in kwargs if x.startswith('newznab_host')]:
newznab_host_key = kwarg
newznab_number = kwarg[12:]
if len(newznab_number):
newznab_api_key = 'newznab_api' + newznab_number
newznab_enabled_key = 'newznab_enabled' + newznab_number
newznab_host = kwargs.get(newznab_host_key, '')
newznab_api = kwargs.get(newznab_api_key, '')
newznab_enabled = int(kwargs.get(newznab_enabled_key, 0))
for key in [newznab_host_key, newznab_api_key, newznab_enabled_key]:
if key in kwargs:
del kwargs[key]
extra_newznabs.append((newznab_host, newznab_api, newznab_enabled))
# Convert the extras to list then string. Coming in as 0 or 1 (append new extras to the end)
temp_extras_list = []
@@ -1204,8 +1231,10 @@ class WebInterface(object):
del kwargs[extra]
headphones.CONFIG.EXTRAS = ','.join(str(n) for n in temp_extras_list)
headphones.CONFIG.clear_extra_newznabs()
headphones.CONFIG.process_kwargs(kwargs)
for extra_newznab in extra_newznabs:
headphones.CONFIG.add_extra_newznab(extra_newznab)
# Sanity checking
if headphones.CONFIG.SEARCH_INTERVAL < 360: