Repository: pymedusa/Medusa

Issue:
Seed ratio is set to unlimited for new torrents sent to Transmission
**Describe the bug**
Since around 3 weeks ago, new torrents added to Transmission don't have Transmission's default seed ratio of 8.0 set anymore, instead the seed ratio is set to unlimited. In the past, this worked without any problems.

I think this is because of a change introduced in #8485, but I don't know what exactly caused it.

**To Reproduce**
Steps to reproduce the behavior:
1. Set up Transmission as client
2. Configure a seed ratio in the Transmission settings
3. Let Medusa add a torrent
4. The seed ratio is unlimited

**Expected behavior**
The seed ratio should be the default one from Transmission.

**Medusa (please complete the following information):**
- OS: Docker container
- Branch: master
- Commit: 55cecb9e821fb15f20efe75b0f59d13e896e1d87
- Python version: Unknown
- Database version: Unknown

**Debug logs (at least 50 lines):**
General > Advanced Settings > Enable debug
<details>

```
2021-03-09 18:37:08 DEBUG	SNATCHQUEUE-SNATCH-352408 :: [55cecb9] Transmission: Response to POST request is {"arguments":{},"result":"success"}
2021-03-09 18:37:08 DEBUG	SNATCHQUEUE-SNATCH-352408 :: [55cecb9] POST URL: http://192.168.0.2:9091/transmission/rpc/rpc [Status: 200]
2021-03-09 18:37:08 DEBUG	SNATCHQUEUE-SNATCH-352408 :: [55cecb9] Transmission: Requested a POST connection to http://192.168.0.2:9091/transmission/rpc/rpc with params: None Data: {"arguments": {"ids": ["6c64a7b30bf34ce87d7f0fdfb03f119086ee3bad"], "priority-high": [], "queuePosi... Files: None
2021-03-09 18:37:08 DEBUG	SNATCHQUEUE-SNATCH-352408 :: [55cecb9] Transmission: Response to POST request is {"arguments":{},"result":"success"}
2021-03-09 18:37:08 DEBUG	SNATCHQUEUE-SNATCH-352408 :: [55cecb9] POST URL: http://192.168.0.2:9091/transmission/rpc/rpc [Status: 200]
2021-03-09 18:37:08 DEBUG	SNATCHQUEUE-SNATCH-352408 :: [55cecb9] Transmission: Requested a POST connection to http://192.168.0.2:9091/transmission/rpc/rpc with params: None Data: {"arguments": {"ids": ["6c64a7b30bf34ce87d7f0fdfb03f119086ee3bad"], "seedRatioLimit": 0, "seedRatio... Files: None
2021-03-09 18:37:08 DEBUG	SNATCHQUEUE-SNATCH-352408 :: [55cecb9] Transmission: Response to POST request is {"arguments":{"torrent-added":{"hashString":"6c64a7b30bf34ce87d7f0fdfb03f119086ee3bad","id":92,"name":"[DKB] Tensei shitara Slime Datta Ken 2nd Season - S02E09 [1080p][HEVC-265 10bit][Multi-Subs].mkv"}},"result":"success"}
2021-03-09 18:37:08 DEBUG	SNATCHQUEUE-SNATCH-352408 :: [55cecb9] POST URL: http://192.168.0.2:9091/transmission/rpc/rpc [Status: 200]
```
</details>


Discussion:
By debugging I found out that the Provider Options for my Search Providers had the default value of `-1`. `result.ratio` is set to the `provider.ratio` and is overwritten with `0` in

https://github.com/pymedusa/Medusa/blob/25b080ec12c328d176410fe3fe056deae4c1c0a6/medusa/clients/torrent/transmission.py#L138L140

I had to change the seed ratio to 8.0 for all of my search providers one by one. I'm pretty sure the logic was different in the past.
The ratio is purely to run an action in medusa. Its not supposed to set a ratio in transmission. Also it never has done that.
> The ratio is purely to run an action in medusa

It's logging a POST request to transmission containing the seedRatio. If I set the seed ratio to `7` in the provider options, I see the seed ratio set to `7` in transmission. You're definitely wrong.
I think that's some legacy behavior. I'll remove that

Resolving patch:
diff --git a/medusa/clients/torrent/transmission.py b/medusa/clients/torrent/transmission.py
--- a/medusa/clients/torrent/transmission.py
+++ b/medusa/clients/torrent/transmission.py
@@ -133,20 +133,22 @@ def _set_torrent_ratio(self, result):
         if result.ratio:
             ratio = result.ratio
 
-        mode = 0
+        arguments = {
+            'ids': [result.hash]
+        }
+
         if ratio:
+            # Use transmission global
             if float(ratio) == -1:
-                ratio = 0
-                mode = 2
+                arguments['seedRatioMode'] = 0
+            # Unlimited
+            elif float(ratio) == 0:
+                arguments['seedRatioLimit'] = 0
+                arguments['seedRatioMode'] = 2
+            # Set ratio
             elif float(ratio) >= 0:
-                ratio = float(ratio)
-                mode = 1  # Stop seeding at seedRatioLimit
-
-        arguments = {
-            'ids': [result.hash],
-            'seedRatioLimit': ratio,
-            'seedRatioMode': mode,
-        }
+                arguments['seedRatioLimit'] = float(ratio)
+                arguments['seedRatioMode'] = 1
 
         post_data = json.dumps({
             'arguments': arguments,


Test patch: