Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix allowed statusses for postprocessing. #10828

Merged
merged 6 commits into from
Jul 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#### Fixes
- Fixed borders in tables where diplay: flex is used on a table cell. ([10813](https://github.com/pymedusa/Medusa/pull/10813))
- Fix keys for caching recommended shows in recommended.dbm. ([10827](https://github.com/pymedusa/Medusa/pull/10827))
- Fix using download handler with deluge / deluged. ([10828](https://github.com/pymedusa/Medusa/pull/10828))

## 1.0.5 (06-07-2022)

Expand Down
6 changes: 4 additions & 2 deletions medusa/clients/torrent/deluge.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,11 @@ def _set_torrent_label(self, result):
def _set_torrent_ratio(self, result):

ratio = result.ratio
if not ratio:
return

# blank is default client ratio, so we also shouldn't set ratio
if ratio and float(ratio) >= 0:
if float(ratio) >= 0:
if self.version >= (2, 0):
post_data = json.dumps({
'method': 'core.set_torrent_options',
Expand Down Expand Up @@ -468,7 +470,7 @@ def _set_torrent_ratio(self, result):

return not self.response.json()['error']

elif ratio and float(ratio) == -1:
elif float(ratio) == -1:
# Disable stop at ratio to seed forever
if self.version >= (2, 0):
post_data = json.dumps({
Expand Down
29 changes: 21 additions & 8 deletions medusa/clients/torrent/deluged.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ def get_status(self, info_hash):
client_status.progress = int(torrent['progress'])

# Store destination
client_status.destination = torrent['download_location']
if torrent.get('download_location'):
client_status.destination = torrent['download_location']

# Store resource
client_status.resource = torrent['name']
Expand Down Expand Up @@ -480,14 +481,26 @@ def set_torrent_ratio(self, torrent_id, ratio):
:rtype: bool
"""
try:
# blank is default client ratio, so we also shouldn't set ratio
self.connect()
if self.get_version() >= (2, 0):
self.client.core.set_torrent_options(torrent_id, {'stop_at_ratio': True})
self.client.core.set_torrent_options(torrent_id, {'stop_ratio': ratio})
else:
self.client.core.set_torrent_stop_at_ratio(torrent_id, True)
self.client.core.set_torrent_stop_ratio(torrent_id, ratio)

version = self.get_version()
if float(ratio) >= 0:
if version >= (2, 0):
self.client.core.set_torrent_options(torrent_id, {'stop_at_ratio': True})
else:
self.client.core.set_torrent_stop_at_ratio(torrent_id, True)

if version >= (2, 0):
self.client.core.set_torrent_options(torrent_id, {'stop_ratio': ratio})
else:
self.client.core.set_torrent_stop_ratio(torrent_id, ratio)

elif float(ratio) == -1:
# Disable stop at ratio to seed forever
if version >= (2, 0):
self.client.core.set_torrent_options(torrent_id, {'stop_at_ratio': False})
else:
self.client.core.set_torrent_stop_at_ratio(torrent_id, False)
except Exception:
return False
else:
Expand Down
3 changes: 3 additions & 0 deletions medusa/schedulers/download_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ def _check_postprocess(self, client):
ClientStatusEnum.COMPLETED.value,
ClientStatusEnum.FAILED.value,
ClientStatusEnum.SEEDED.value,
ClientStatusEnum.COMPLETED.value | ClientStatusEnum.SEEDED.value,
ClientStatusEnum.COMPLETED.value | ClientStatusEnum.PAUSED.value,
ClientStatusEnum.COMPLETED.value | ClientStatusEnum.SEEDED.value | ClientStatusEnum.PAUSED.value,
],
):
try:
Expand Down