Repository: Flexget/Flexget

Issue:
torrentday pluging winth uid secret gets error expecting string
### Expected behaviour:

Setting uid from secrets file should work and update config

### Actual behaviour:

When setting the uid from a secret file, since uid is a number, it's converted to integer on the config, this makes a error in the config compilation of:

/tasks/xTV_TorrentDay/discover/from/0/torrentday/uid] Got `1234567`, expected: string

### Steps to reproduce:
- Step 1: Add config and run flexget check

#### Config:
```yaml
  TV_TorrentDay:
    discover:
      what:
        - next_series_episodes: yes
      from:
        - torrentday:
            uid: "{? torrentday.uid ?}"
            passkey: '{? torrentday.passkey ?}'
            cfduid: '{? torrentday.cfduid ?}'
            rss_key: '{? torrentday.rss_key ?}'
            category: 'tvBRD'
```
secrets.yaml
```yaml
torrentday:
  uid: "1234567"
  passkey: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  cfduid: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  rss_key: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
```
  
#### Log:
<details>
 <summary>(click to expand)</summary>

```
2021-02-16 01:29:54 CRITICAL manager                       [/tasks/xTV_TorrentDay/discover/from/0/torrentday/uid] Got `1234567`, expected: string
2021-02-16 01:29:54 CRITICAL manager                       Failed to load config file: Did not pass schema validation.

```
</details>

### Additional information:

- FlexGet version: 3.1.102
- Python version: 3.7.3
- Installation method: venv
- Using daemon (yes/no): yes
- OS and version: debian 10


Discussion:
Hmm. That's a bit disappointing. Unfortunately I'm not sure there is much we can do and still have secrets plugin work for things that _should_ be a number (or any other non-string thing.) Possible workarounds to try:
- Using quotes either in the config or secrets file. e.g. `uid: '"{? torrentday.uid ?}"'` (or similar in the secrets file)
- Updating torrentday plugin to allow either numbers or a string for this field. (this sounds sensible anyway, as just writing the number in this field without quotes would cause the same issue)
Can't this option be a number? Or number and string (one of both)? I don't know if some users can contain any type of string.
somting like:

`'uid': 'oneOf': [{'type': 'integer'}, {'type': 'string'}]`

would not solve it?
Another thing that I noticed in this plugin is that category is not allowing multiple entries in the schema, but the code clearly expects a list:

```
        # Make sure categories is a list
        if not isinstance(categories, list):
            categories = [categories]
```

This makes that I only can use one categorie in the discover.

Somting like this would solve it?:

```
'category': one_or_more(
                {'oneOf': [{'type': 'integer'}, {'type': 'string', 'enum': list(CATEGORIES)}]}
            ),
```
Yep, both of those seem good. Want to send a PR? 😃 
Yes I'll do it! :)

Resolving patch:
diff --git a/flexget/components/sites/sites/torrentday.py b/flexget/components/sites/sites/torrentday.py
--- a/flexget/components/sites/sites/torrentday.py
+++ b/flexget/components/sites/sites/torrentday.py
@@ -6,6 +6,7 @@
 from flexget import plugin
 from flexget.components.sites.urlrewriting import UrlRewritingError
 from flexget.components.sites.utils import normalize_unicode, torrent_availability
+from flexget.config_schema import one_or_more
 from flexget.entry import Entry
 from flexget.event import event
 from flexget.plugin import PluginError
@@ -69,12 +70,12 @@ class UrlRewriteTorrentday:
         'type': 'object',
         'properties': {
             'rss_key': {'type': 'string'},
-            'uid': {'type': 'string'},
+            'uid': {'oneOf': [{'type': 'integer'}, {'type': 'string'}]},
             'passkey': {'type': 'string'},
             'cfduid': {'type': 'string'},
-            'category': {
-                'oneOf': [{'type': 'integer'}, {'type': 'string', 'enum': list(CATEGORIES)}]
-            },
+            'category': one_or_more(
+                {'oneOf': [{'type': 'integer'}, {'type': 'string', 'enum': list(CATEGORIES)}]}
+            ),
         },
         'required': ['rss_key', 'uid', 'passkey', 'cfduid'],
         'additionalProperties': False,
@@ -125,7 +126,7 @@ def search(self, task, entry, config=None):
             url = 'https://www.torrentday.com/t'
             params['q'] = normalize_unicode(search_string).replace(':', '')
             cookies = {
-                'uid': config['uid'],
+                'uid': str(config['uid']),
                 'pass': config['passkey'],
                 '__cfduid': config['cfduid'],
             }


Test patch: