Repository: Flexget/Flexget

Issue:
Unhandled error in plugin from_transmission
<!---
Before opening an issue, verify:

- Is this a feature request? Post it on https://feathub.com/Flexget/Flexget
- Is this an issue with webui? Make an issue over on https://github.com/Flexget/webui
- Did you recently upgrade? Look at the Change Log and Upgrade Actions to make sure that you don't need to make any changes to your config https://flexget.com/ChangeLog https://flexget.com/UpgradeActions
- Are you running FlexGet as a daemon? Stop it completely and then start it again https://flexget.com/CLI/daemon
- Did you search to see if the issue already exists? https://github.com/Flexget/Flexget/issues
- Did you fill out the issue template as completely as possible?

The issue template is here because it helps to ensure you submitted all the necessary information the first time, and allows us to more quickly review issues. Please fill it out correctly and do not ignore it, no matter how irrelevant you think it may be. Thanks in advance for your help with this!
--->

### Expected behavior:

Get the list of entries from the transmission.

### Actual behavior:

Unhandled error in plugin from_transmission.

### Steps to reproduce:
- Step 1: Upgrade to 3.1.92
- Step 2: Install transmission-rpc
- Step 3: Use from_transmission in task

#### Config:
``` yaml 
  TRANS_CLN:
    no_entries_ok: yes
    from_transmission:
      <<: *transmission_settings
      only_complete: yes
    disable: [seen, seen_info_hash, notify]
    if:
      - transmission_progress == 100: accept
      - not transmission_seed_ratio_ok: reject
      - not transmission_idle_limit_ok: reject
    transmission:
      <<: *transmission_settings
      action: remove
```
  
#### Log:
<details>
 <summary>(click to expand)</summary>

```
2020-12-28 14:15:51 CRITICAL task          TRANS_CLN       BUG: Unhandled error in plugin from_transmission: 'Client' object has no attribute 'http_handler'
Traceback (most recent call last):

  File "/usr/lib/python3.6/threading.py", line 884, in _bootstrap
    self._bootstrap_inner()
    │    └ <function Thread._bootstrap_inner at 0xb6838c90>
    └ <Thread(task_queue, stopped daemon -1446013856)>
  File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
    │    └ <function Thread.run at 0xb6838b70>
    └ <Thread(task_queue, stopped daemon -1446013856)>
  File "/usr/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
    │    │        │    │        │    └ {}
    │    │        │    │        └ <Thread(task_queue, stopped daemon -1446013856)>
    │    │        │    └ ()
    │    │        └ <Thread(task_queue, stopped daemon -1446013856)>
    │    └ <bound method TaskQueue.run of <flexget.task_queue.TaskQueue object at 0xb16bfc10>>
    └ <Thread(task_queue, stopped daemon -1446013856)>

  File "/usr/local/lib/python3.6/dist-packages/flexget/task_queue.py", line 46, in run
    self.current_task.execute()
    │    │            └ <function Task.execute at 0xb5490738>
    │    └ <flexget.task.Task object at 0xaecb87f0>
    └ <flexget.task_queue.TaskQueue object at 0xb16bfc10>

  File "/usr/local/lib/python3.6/dist-packages/flexget/task.py", line 87, in wrapper
    return func(self, *args, **kw)
           │    │      │       └ {}
           │    │      └ ()
           │    └ <flexget.task.Task object at 0xaecb87f0>
           └ <function Task.execute at 0xb54906f0>

  File "/usr/local/lib/python3.6/dist-packages/flexget/task.py", line 722, in execute
    self._execute()
    │    └ <function Task._execute at 0xb54906a8>
    └ <flexget.task.Task object at 0xaecb87f0>

  File "/usr/local/lib/python3.6/dist-packages/flexget/task.py", line 688, in _execute
    self.__run_task_phase(phase)
    │                     └ 'input'
    └ <flexget.task.Task object at 0xaecb87f0>

  File "/usr/local/lib/python3.6/dist-packages/flexget/task.py", line 514, in __run_task_phase
    response = self.__run_plugin(plugin, phase, args)
               │                 │       │      └ (<flexget.task.Task object at 0xaecb87f0>, {'host': '192.168.0.250', 'port': 9091, 'username': 'tnt', 'password': 'fylhtq1973...
               │                 │       └ 'input'
               │                 └ <PluginInfo(name=from_transmission)>
               └ <flexget.task.Task object at 0xaecb87f0>

> File "/usr/local/lib/python3.6/dist-packages/flexget/task.py", line 547, in __run_plugin
    result = method(*args, **kwargs)
             │       │       └ {}
             │       └ (<flexget.task.Task object at 0xaecb87f0>, {'host': '192.168.0.250', 'port': 9091, 'username': 'tnt', 'password': 'fylhtq1973...
             └ <Event(name=plugin.from_transmission.input,func=on_task_input,priority=128)>

  File "/usr/local/lib/python3.6/dist-packages/flexget/event.py", line 20, in __call__
    return self.func(*args, **kwargs)
           │    │     │       └ {}
           │    │     └ (<flexget.task.Task object at 0xaecb87f0>, {'host': '192.168.0.250', 'port': 9091, 'username': 'tnt', 'password': 'fylhtq1973...
           │    └ <bound method PluginTransmissionInput.on_task_input of <flexget.plugins.clients.transmission.PluginTransmissionInput object a...
           └ <Event(name=plugin.from_transmission.input,func=on_task_input,priority=128)>

  File "/usr/local/lib/python3.6/dist-packages/flexget/plugins/clients/transmission.py", line 186, in on_task_input
    self.client.http_handler.set_authentication(
    │    └ <transmission_rpc.client.Client object at 0xae28ec50>
    └ <flexget.plugins.clients.transmission.PluginTransmissionInput object at 0xb16d38f0>

AttributeError: 'Client' object has no attribute 'http_handler'
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/flexget/task.py", line 547, in __run_plugin
    result = method(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/flexget/event.py", line 20, in __call__
    return self.func(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/flexget/plugins/clients/transmission.py", line 186, in on_task_input
    self.client.http_handler.set_authentication(
AttributeError: 'Client' object has no attribute 'http_handler'

```
</details>

### Additional information:

- FlexGet version: 3.1.92
- Python version: 3.6.9
- Installation method: pip
- Using daemon (yes/no): yes
- OS and version: Armbian Linux 4.19.62-sunxi
- Link to crash log: https://cdn.discordapp.com/attachments/536690097496784906/793099343199993886/crash_report.2020.12.28.141551281798.log

<!---
In config and debug/crash logs, remember to redact any personal or sensitive information such as passwords, API keys, private URLs and so on.

Please verify that the following data is present before submitting your issue:

- Link to a paste service or paste above the relevant config (preferably full config, including templates if present). Please make sure the paste does not expire, if possible.
- Link to a paste service or paste above debug-level logs of the relevant task/s (use `flexget -L debug execute --tasks <Task_name>`).
- FlexGet version (use `flexget -V` to get it).
- Full Python version, for example `2.7.11` (use `python -V` to get it). 
- Installation method (pip, git install, etc).
- Whether or not you're running FlexGet as a daemon.
- OS and version.
- Attach crash log if one was generated, in addition to the debug-level log. It can be found in the directory with your config file.
--->

Unhandled error in plugin from_transmission
<!---
Before opening an issue, verify:

- Is this a feature request? Post it on https://feathub.com/Flexget/Flexget
- Is this an issue with webui? Make an issue over on https://github.com/Flexget/webui
- Did you recently upgrade? Look at the Change Log and Upgrade Actions to make sure that you don't need to make any changes to your config https://flexget.com/ChangeLog https://flexget.com/UpgradeActions
- Are you running FlexGet as a daemon? Stop it completely and then start it again https://flexget.com/CLI/daemon
- Did you search to see if the issue already exists? https://github.com/Flexget/Flexget/issues
- Did you fill out the issue template as completely as possible?

The issue template is here because it helps to ensure you submitted all the necessary information the first time, and allows us to more quickly review issues. Please fill it out correctly and do not ignore it, no matter how irrelevant you think it may be. Thanks in advance for your help with this!
--->

### Expected behavior:

Get the list of entries from the transmission.

### Actual behavior:

Unhandled error in plugin from_transmission.

### Steps to reproduce:
- Step 1: Upgrade to 3.1.92
- Step 2: Install transmission-rpc
- Step 3: Use from_transmission in task

#### Config:
``` yaml 
  TRANS_CLN:
    no_entries_ok: yes
    from_transmission:
      <<: *transmission_settings
      only_complete: yes
    disable: [seen, seen_info_hash, notify]
    if:
      - transmission_progress == 100: accept
      - not transmission_seed_ratio_ok: reject
      - not transmission_idle_limit_ok: reject
    transmission:
      <<: *transmission_settings
      action: remove
```
  
#### Log:
<details>
 <summary>(click to expand)</summary>

```
2020-12-28 14:15:51 CRITICAL task          TRANS_CLN       BUG: Unhandled error in plugin from_transmission: 'Client' object has no attribute 'http_handler'
Traceback (most recent call last):

  File "/usr/lib/python3.6/threading.py", line 884, in _bootstrap
    self._bootstrap_inner()
    │    └ <function Thread._bootstrap_inner at 0xb6838c90>
    └ <Thread(task_queue, stopped daemon -1446013856)>
  File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
    │    └ <function Thread.run at 0xb6838b70>
    └ <Thread(task_queue, stopped daemon -1446013856)>
  File "/usr/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
    │    │        │    │        │    └ {}
    │    │        │    │        └ <Thread(task_queue, stopped daemon -1446013856)>
    │    │        │    └ ()
    │    │        └ <Thread(task_queue, stopped daemon -1446013856)>
    │    └ <bound method TaskQueue.run of <flexget.task_queue.TaskQueue object at 0xb16bfc10>>
    └ <Thread(task_queue, stopped daemon -1446013856)>

  File "/usr/local/lib/python3.6/dist-packages/flexget/task_queue.py", line 46, in run
    self.current_task.execute()
    │    │            └ <function Task.execute at 0xb5490738>
    │    └ <flexget.task.Task object at 0xaecb87f0>
    └ <flexget.task_queue.TaskQueue object at 0xb16bfc10>

  File "/usr/local/lib/python3.6/dist-packages/flexget/task.py", line 87, in wrapper
    return func(self, *args, **kw)
           │    │      │       └ {}
           │    │      └ ()
           │    └ <flexget.task.Task object at 0xaecb87f0>
           └ <function Task.execute at 0xb54906f0>

  File "/usr/local/lib/python3.6/dist-packages/flexget/task.py", line 722, in execute
    self._execute()
    │    └ <function Task._execute at 0xb54906a8>
    └ <flexget.task.Task object at 0xaecb87f0>

  File "/usr/local/lib/python3.6/dist-packages/flexget/task.py", line 688, in _execute
    self.__run_task_phase(phase)
    │                     └ 'input'
    └ <flexget.task.Task object at 0xaecb87f0>

  File "/usr/local/lib/python3.6/dist-packages/flexget/task.py", line 514, in __run_task_phase
    response = self.__run_plugin(plugin, phase, args)
               │                 │       │      └ (<flexget.task.Task object at 0xaecb87f0>, {'host': '192.168.0.250', 'port': 9091, 'username': 'tnt', 'password': 'fylhtq1973...
               │                 │       └ 'input'
               │                 └ <PluginInfo(name=from_transmission)>
               └ <flexget.task.Task object at 0xaecb87f0>

> File "/usr/local/lib/python3.6/dist-packages/flexget/task.py", line 547, in __run_plugin
    result = method(*args, **kwargs)
             │       │       └ {}
             │       └ (<flexget.task.Task object at 0xaecb87f0>, {'host': '192.168.0.250', 'port': 9091, 'username': 'tnt', 'password': 'fylhtq1973...
             └ <Event(name=plugin.from_transmission.input,func=on_task_input,priority=128)>

  File "/usr/local/lib/python3.6/dist-packages/flexget/event.py", line 20, in __call__
    return self.func(*args, **kwargs)
           │    │     │       └ {}
           │    │     └ (<flexget.task.Task object at 0xaecb87f0>, {'host': '192.168.0.250', 'port': 9091, 'username': 'tnt', 'password': 'fylhtq1973...
           │    └ <bound method PluginTransmissionInput.on_task_input of <flexget.plugins.clients.transmission.PluginTransmissionInput object a...
           └ <Event(name=plugin.from_transmission.input,func=on_task_input,priority=128)>

  File "/usr/local/lib/python3.6/dist-packages/flexget/plugins/clients/transmission.py", line 186, in on_task_input
    self.client.http_handler.set_authentication(
    │    └ <transmission_rpc.client.Client object at 0xae28ec50>
    └ <flexget.plugins.clients.transmission.PluginTransmissionInput object at 0xb16d38f0>

AttributeError: 'Client' object has no attribute 'http_handler'
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/flexget/task.py", line 547, in __run_plugin
    result = method(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/flexget/event.py", line 20, in __call__
    return self.func(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/flexget/plugins/clients/transmission.py", line 186, in on_task_input
    self.client.http_handler.set_authentication(
AttributeError: 'Client' object has no attribute 'http_handler'

```
</details>

### Additional information:

- FlexGet version: 3.1.92
- Python version: 3.6.9
- Installation method: pip
- Using daemon (yes/no): yes
- OS and version: Armbian Linux 4.19.62-sunxi
- Link to crash log: https://cdn.discordapp.com/attachments/536690097496784906/793099343199993886/crash_report.2020.12.28.141551281798.log

<!---
In config and debug/crash logs, remember to redact any personal or sensitive information such as passwords, API keys, private URLs and so on.

Please verify that the following data is present before submitting your issue:

- Link to a paste service or paste above the relevant config (preferably full config, including templates if present). Please make sure the paste does not expire, if possible.
- Link to a paste service or paste above debug-level logs of the relevant task/s (use `flexget -L debug execute --tasks <Task_name>`).
- FlexGet version (use `flexget -V` to get it).
- Full Python version, for example `2.7.11` (use `python -V` to get it). 
- Installation method (pip, git install, etc).
- Whether or not you're running FlexGet as a daemon.
- OS and version.
- Attach crash log if one was generated, in addition to the debug-level log. It can be found in the directory with your config file.
--->



Discussion:
Also I think that the breaking change in https://github.com/Trim21/transmission-rpc/releases/tag/v3.0.0a4 breaks the client plugin `transmission` in FlexGet.
I had to downgrade FlexGet to 3.1.91 to keep transmission working.

E.g. this does not work in Flexget 3.1.92: https://github.com/Flexget/Flexget/blob/v3.1.92/flexget/plugins/clients/transmission.py#L492
👋 I'm seeing the exact same behaviour for my setup.


I run flexget using the [docker-flexget](https://github.com/cpoppema/docker-flexget) container, and opened an issue there for this: 

https://github.com/cpoppema/docker-flexget/issues/85

In that issue, the author has written a small patch to simply comment out the offending lines which is working:

```
--- transmission.py.org
+++ transmission.py
@@ -182,10 +182,10 @@
 
         # Hack/Workaround for http://flexget.com/ticket/2002
         # TODO: Proper fix
-        if 'username' in config and 'password' in config:
-            self.client.http_handler.set_authentication(
-                self.client.url, config['username'], config['password']
-            )
+#        if 'username' in config and 'password' in config:
+#            self.client.http_handler.set_authentication(
+#                self.client.url, config['username'], config['password']
+#            )
 
         session = self.client.get_session()
```




> Also I think that the breaking change in https://github.com/Trim21/transmission-rpc/releases/tag/v3.0.0a4 breaks the client plugin `transmission` in FlexGet.
> I had to downgrade FlexGet to 3.1.91 to keep transmission working.
> 
> E.g. this does not work in Flexget 3.1.92: https://github.com/Flexget/Flexget/blob/v3.1.92/flexget/plugins/clients/transmission.py#L492

Yep, that'll break things too. We should start requiring >=3.0 and switch to that new interface.
> In that issue, the author has written a small patch to simply comment out the offending lines which is working

Looks like the offending code is a workaround that's probably obviated by moving to the new module; should be safe to remove.


This issue has been mentioned on **Forum - FlexGet**. There might be relevant details there:

https://discuss.flexget.com/t/unhandled-error-in-plugin-transmission-list-indices-must-be-integers-or-slices-not-file/5352/4

> This issue has been mentioned on **Forum - FlexGet**. There might be relevant details there:
> 
> https://discuss.flexget.com/t/unhandled-error-in-plugin-transmission-list-indices-must-be-integers-or-slices-not-file/5352/4

I think this is related to the "skip_files" and not this issue. I think it is another issue.
I have exactly the same issue. Flexget daemon is closed each time when I try to use **from_transmission** plugin.
``` log
flexget[694]: 2021-01-08 13:15:07 CRITICAL task          clean-torr      BUG: Unhandled error in plugin from_transmission: 'Client' object has no attribute 'http_handler'
....
flexget[694]: 2021-01-08 13:15:07 CRITICAL task_queue                    BUG: Unhandled exception during task queue run loop.
flexget[694]: Exception in thread task_queue:
flexget[694]: Traceback (most recent call last):
flexget[694]:   File "/usr/local/lib/python3.8/dist-packages/flexget/task.py", line 547, in __run_plugin
flexget[694]:     result = method(*args, **kwargs)
flexget[694]:   File "/usr/local/lib/python3.8/dist-packages/flexget/event.py", line 20, in __call__
flexget[694]:     return self.func(*args, **kwargs)
flexget[694]:   File "/usr/local/lib/python3.8/dist-packages/flexget/plugins/clients/transmission.py", line 198, in on_task_input
flexget[694]:     self.client.http_handler.set_authentication(
flexget[694]: AttributeError: 'Client' object has no attribute 'http_handler'
````
This makes flexget unusable for me.
Also I think that the breaking change in https://github.com/Trim21/transmission-rpc/releases/tag/v3.0.0a4 breaks the client plugin `transmission` in FlexGet.
I had to downgrade FlexGet to 3.1.91 to keep transmission working.

E.g. this does not work in Flexget 3.1.92: https://github.com/Flexget/Flexget/blob/v3.1.92/flexget/plugins/clients/transmission.py#L492
👋 I'm seeing the exact same behaviour for my setup.


I run flexget using the [docker-flexget](https://github.com/cpoppema/docker-flexget) container, and opened an issue there for this: 

https://github.com/cpoppema/docker-flexget/issues/85

In that issue, the author has written a small patch to simply comment out the offending lines which is working:

```
--- transmission.py.org
+++ transmission.py
@@ -182,10 +182,10 @@
 
         # Hack/Workaround for http://flexget.com/ticket/2002
         # TODO: Proper fix
-        if 'username' in config and 'password' in config:
-            self.client.http_handler.set_authentication(
-                self.client.url, config['username'], config['password']
-            )
+#        if 'username' in config and 'password' in config:
+#            self.client.http_handler.set_authentication(
+#                self.client.url, config['username'], config['password']
+#            )
 
         session = self.client.get_session()
```




> Also I think that the breaking change in https://github.com/Trim21/transmission-rpc/releases/tag/v3.0.0a4 breaks the client plugin `transmission` in FlexGet.
> I had to downgrade FlexGet to 3.1.91 to keep transmission working.
> 
> E.g. this does not work in Flexget 3.1.92: https://github.com/Flexget/Flexget/blob/v3.1.92/flexget/plugins/clients/transmission.py#L492

Yep, that'll break things too. We should start requiring >=3.0 and switch to that new interface.
> In that issue, the author has written a small patch to simply comment out the offending lines which is working

Looks like the offending code is a workaround that's probably obviated by moving to the new module; should be safe to remove.


This issue has been mentioned on **Forum - FlexGet**. There might be relevant details there:

https://discuss.flexget.com/t/unhandled-error-in-plugin-transmission-list-indices-must-be-integers-or-slices-not-file/5352/4

> This issue has been mentioned on **Forum - FlexGet**. There might be relevant details there:
> 
> https://discuss.flexget.com/t/unhandled-error-in-plugin-transmission-list-indices-must-be-integers-or-slices-not-file/5352/4

I think this is related to the "skip_files" and not this issue. I think it is another issue.
I have exactly the same issue. Flexget daemon is closed each time when I try to use **from_transmission** plugin.
``` log
flexget[694]: 2021-01-08 13:15:07 CRITICAL task          clean-torr      BUG: Unhandled error in plugin from_transmission: 'Client' object has no attribute 'http_handler'
....
flexget[694]: 2021-01-08 13:15:07 CRITICAL task_queue                    BUG: Unhandled exception during task queue run loop.
flexget[694]: Exception in thread task_queue:
flexget[694]: Traceback (most recent call last):
flexget[694]:   File "/usr/local/lib/python3.8/dist-packages/flexget/task.py", line 547, in __run_plugin
flexget[694]:     result = method(*args, **kwargs)
flexget[694]:   File "/usr/local/lib/python3.8/dist-packages/flexget/event.py", line 20, in __call__
flexget[694]:     return self.func(*args, **kwargs)
flexget[694]:   File "/usr/local/lib/python3.8/dist-packages/flexget/plugins/clients/transmission.py", line 198, in on_task_input
flexget[694]:     self.client.http_handler.set_authentication(
flexget[694]: AttributeError: 'Client' object has no attribute 'http_handler'
````
This makes flexget unusable for me.

Resolving patch:
diff --git a/flexget/plugins/clients/transmission.py b/flexget/plugins/clients/transmission.py
--- a/flexget/plugins/clients/transmission.py
+++ b/flexget/plugins/clients/transmission.py
@@ -192,13 +192,6 @@ def on_task_input(self, task, config):
             self.client = self.create_rpc_client(config)
         entries = []
 
-        # Hack/Workaround for http://flexget.com/ticket/2002
-        # TODO: Proper fix
-        if 'username' in config and 'password' in config:
-            self.client.http_handler.set_authentication(
-                self.client.url, config['username'], config['password']
-            )
-
         session = self.client.get_session()
 
         for torrent in self.client.get_torrents():


Test patch: