Fixed issues with per-provider torrent ratio settings, now can be left blank to default to client ratio setting.

This commit is contained in:
echel0n 2014-05-22 23:42:11 -07:00
parent 753be64090
commit b499e4b6db
6 changed files with 63 additions and 71 deletions

View file

@ -366,7 +366,13 @@ var show_nzb_providers = #if $sickbeard.USE_NZBS then "true" else "false"#;
<div class="field-pair">
<label class="clearfix">
<span class="component-title" id="${curTorrentProvider.getID()}_ratio_desc">Seed Ratio:</span>
<input type="text" name="${curTorrentProvider.getID()}_ratio" id="${curTorrentProvider.getID()}_ratio" value="$curTorrentProvider.ratio" size="40" />
<input type="number" step="0.1" name="${curTorrentProvider.getID()}_ratio" id="${curTorrentProvider.getID()}_ratio" value="$curTorrentProvider.ratio" size="2" />
</label>
<label class="clearfix">
<span class="component-title">&nbsp;</span>
<span class="component-desc">
Stop transfer when reaching ratio<br>
(blank for default)</span>
</label>
</div>
#end if
@ -375,7 +381,7 @@ var show_nzb_providers = #if $sickbeard.USE_NZBS then "true" else "false"#;
<div class="field-pair">
<label class="clearfix">
<span class="component-title" id="${curTorrentProvider.getID()}_minseed_desc">Min Seeders:</span>
<input type="text" name="${curTorrentProvider.getID()}_minseed" id="${curTorrentProvider.getID()}_minseed" value="$curTorrentProvider.minseed" size="40" />
<input type="number" name="${curTorrentProvider.getID()}_minseed" id="${curTorrentProvider.getID()}_minseed" value="$curTorrentProvider.minseed" size="40" />
</label>
</div>
#end if
@ -384,7 +390,7 @@ var show_nzb_providers = #if $sickbeard.USE_NZBS then "true" else "false"#;
<div class="field-pair">
<label class="clearfix">
<span class="component-title" id="${curTorrentProvider.getID()}_minleech_desc">Min Leechers:</span>
<input type="text" name="${curTorrentProvider.getID()}_minleech" id="${curTorrentProvider.getID()}_minleech" value="$curTorrentProvider.minleech" size="40" />
<input type="number" name="${curTorrentProvider.getID()}_minleech" id="${curTorrentProvider.getID()}_minleech" value="$curTorrentProvider.minleech" size="40" />
</label>
</div>
#end if

View file

@ -944,7 +944,8 @@ def initialize(consoleLogging=True):
properFinderScheduler.silent = True
autoPostProcesserScheduler = scheduler.Scheduler(autoPostProcesser.PostProcesser(),
cycleTime=datetime.timedelta(minutes=AUTOPOSTPROCESSER_FREQUENCY),
cycleTime=datetime.timedelta(
minutes=AUTOPOSTPROCESSER_FREQUENCY),
threadName="POSTPROCESSER",
runImmediately=True)
if not PROCESS_AUTOMATICALLY:
@ -1018,8 +1019,8 @@ def initialize(consoleLogging=True):
curTorrentProvider.options = check_setting_str(CFG, curTorrentProvider.getID().upper(),
curTorrentProvider.getID() + '_options', '')
if hasattr(curTorrentProvider, 'ratio'):
curTorrentProvider.ratio = float(check_setting_float(CFG, curTorrentProvider.getID().upper(),
curTorrentProvider.getID() + '_ratio', 0))
curTorrentProvider.ratio = check_setting_str(CFG, curTorrentProvider.getID().upper(),
curTorrentProvider.getID() + '_ratio', '')
if hasattr(curTorrentProvider, 'minseed'):
curTorrentProvider.minseed = check_setting_int(CFG, curTorrentProvider.getID().upper(),
curTorrentProvider.getID() + '_minseed', 0)
@ -1436,8 +1437,8 @@ def save_config():
new_config[curTorrentProvider.getID().upper()][curTorrentProvider.getID() + '_confirmed'] = int(
curTorrentProvider.confirmed)
if hasattr(curTorrentProvider, 'ratio'):
new_config[curTorrentProvider.getID().upper()][curTorrentProvider.getID() + '_ratio'] = float(
curTorrentProvider.ratio)
new_config[curTorrentProvider.getID().upper()][
curTorrentProvider.getID() + '_ratio'] = curTorrentProvider.ratio
if hasattr(curTorrentProvider, 'minseed'):
new_config[curTorrentProvider.getID().upper()][curTorrentProvider.getID() + '_minseed'] = int(
curTorrentProvider.minseed)

View file

@ -164,18 +164,11 @@ class DelugeAPI(GenericClient):
def _set_torrent_ratio(self, result):
ratio = ''
ratio = None
if result.ratio:
ratio = result.ratio
else:
return True
try:
float(ratio)
except ValueError:
logger.log(self.name + u': Invalid Ratio. "' + ratio + u'" is not a number', logger.ERROR)
return False
if ratio:
post_data = json.dumps({"method": "core.set_torrent_stop_at_ratio",
"params": [result.hash, True],
"id": 5

View file

@ -80,7 +80,7 @@ class TransmissionAPI(GenericClient):
def _set_torrent_ratio(self, result):
ratio = ''
ratio = None
if result.ratio:
ratio = result.ratio
if ratio:
@ -92,11 +92,9 @@ class TransmissionAPI(GenericClient):
torrent_id = self._get_torrent_hash(result)
if ratio == '':
# Use global settings
ratio = None
mode = 0
elif float(ratio) == 0:
if ratio:
if float(ratio) == 0:
ratio = 0
mode = 2
elif float(ratio) > 0:

View file

@ -67,19 +67,11 @@ class uTorrentAPI(GenericClient):
def _set_torrent_ratio(self, result):
ratio = ''
ratio = None
if result.ratio:
ratio = result.ratio
else:
return True
try:
float(ratio)
except ValueError:
logger.log(self.name + u': Invalid Ratio. "' + ratio + u'" is not a number', logger.ERROR)
return False
ratio = 10 * float(ratio)
if ratio:
params = {'action': 'setprops',
'hash': result.hash,
's': 'seed_override',
@ -89,12 +81,14 @@ class uTorrentAPI(GenericClient):
params = {'action': 'setprops',
'hash': result.hash,
's': 'seed_ratio',
'v': ratio
'v': float(ratio) * 10
}
return self._request(params=params)
else:
return False
return True
def _set_torrent_seed_time(self, result):
if sickbeard.TORRENT_SEED_TIME:

View file

@ -1593,9 +1593,9 @@ class ConfigProviders:
if hasattr(curTorrentProvider, 'ratio'):
try:
curTorrentProvider.ratio = float(str(kwargs[curTorrentProvider.getID() + '_ratio']).strip())
curTorrentProvider.ratio = str(kwargs[curTorrentProvider.getID() + '_ratio']).strip()
except:
curTorrentProvider.ratio = 0
curTorrentProvider.ratio = None
if hasattr(curTorrentProvider, 'digest'):
try: