Repository: Flexget/Flexget

Issue:
Error in plugin torrent_files: 'ascii' codec can't decode byte
### Expected behaviour:
RSS feed torrent should be processed and sent to Deluge

### Actual behaviour:
An error message is in the log and the torrent is not sent do Deluge
"BUG: Unhandled error in plugin torrent_files: 'ascii' codec can't decode byte 0xab in position 0: ordinal not in range(128)"

### Steps to reproduce:
Provided config "issue-test" task will download only the torrent that generate the error

#### Config:
```
web_server: yes

templates:
  deluge:
    deluge:
      host: 192.168.1.3
      port: XXXXXXX
      username: XXXXXXX
      password: XXXXXXX
      path: /downloads/incoming/
      movedone: /downloads/completed/
      queuetotop: yes
      ratio: 6

tasks:
  issue-test:
    rss: https://
    accept_all: yes
    exists: "/downloads/completed/"
    set:
      movedone: "/downloads/completed/"
      label: issue
    template:
      - deluge
```
  
#### Log:
```
2017-11-26 20:06 INFO     manager                       Config change detected. Reloading.
2017-11-26 20:06 INFO     manager                       Config successfully reloaded!
2017-11-26 20:06 INFO     download      issue-test      Downloading: S-Cute 547 Kanon #1
2017-11-26 20:06 CRITICAL task          issue-test      BUG: Unhandled error in plugin torrent_files: 'ascii' codec can't decode byte 0xab in position 0: ordinal not in range(128)
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/flexget/task.py", line 486, in __run_plugin
    return method(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/flexget/event.py", line 23, in __call__
    return self.func(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/flexget/plugins/metainfo/torrent_files.py", line 20, in on_task_modify
    files = [posixpath.join(item['path'], item['name']) for item in entry['torrent'].get_filelist()]
  File "/usr/lib/python2.7/site-packages/flexget/utils/bittorrent.py", line 233, in get_filelist
    t = {'path': '/'.join(item['path'][:-1]),
UnicodeDecodeError: 'ascii' codec can't decode byte 0xab in position 0: ordinal not in range(128)
```

### Additional information:

- FlexGet version: 2.11.2  
- Python version: Python 2.7.13
- Installation method: Docker
- Using daemon (yes/no): yes
- OS and version: Linux  4.13.13
- Link to crash log:




Discussion:
It is related to the other issues about UTF8 that I missed earlier.

Resolving patch:
diff --git a/flexget/utils/bittorrent.py b/flexget/utils/bittorrent.py
--- a/flexget/utils/bittorrent.py
+++ b/flexget/utils/bittorrent.py
@@ -223,15 +223,23 @@ def get_filelist(self):
         files = []
         if 'length' in self.content['info']:
             # single file torrent
-            t = {'name': self.content['info']['name'],
+            if 'name.utf-8' in self.content['info']:
+                name = self.content['info']['name.utf-8']
+            else:
+                name = self.content['info']['name']
+            t = {'name': name,
                  'size': self.content['info']['length'],
                  'path': ''}
             files.append(t)
         else:
             # multifile torrent
             for item in self.content['info']['files']:
-                t = {'path': '/'.join(item['path'][:-1]),
-                     'name': item['path'][-1],
+                if 'path.utf-8' in item:
+                    path = item['path.utf-8']
+                else:
+                    path = item['path']
+                t = {'path': '/'.join(path[:-1]),
+                     'name': path[-1],
                      'size': item['length']}
                 files.append(t)
 


Test patch: