Repository: Flexget/Flexget

Issue:
Error searching with alpharatio: invalid literal for int() with base 10
<!---
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 behaviour:

Alpharatio plugin conducts search without errors, handling invalid results

### Actual behaviour:

Some results seem to produce errors. E.g.

```
2021-01-19 23:26:21 ERROR discover search-movies Error searching with alpharatio: invalid literal for int() with base 10: '1,136'
2021-01-19 23:26:16 ERROR discover search-movies Error searching with alpharatio: invalid literal for int() with base 10: '1,609'
2021-01-19 23:26:16 ERROR alpharatio search-movies No size found! Please create a Github issue. Size received: 80.00 B
```

### Steps to reproduce:
- Step 1: ...

#### Config:
```yaml
--- config from task: search-movies
cfscraper: true
content_size:
  max: 80000
  min: 8000
  strict: false
discover:
  from:
    - alpharatio:
        category:
          - moviehd
          - movieuhd
        leechstatus: normal
        order_by: time
        order_desc: true
        password: xxx
        username: xxx
  interval: 6 hours
  release_estimations:
    optimistic: 4 weeks
  what:
    - movie_list: Movies
free_space:
  allotment: -1
  path: /storage
  port: 22
  space: 20000
if:
  - trakt_collected: reject
  - trakt_watched: reject
imdb_lookup: true
include: reject.yml
list_match:
  action: accept
  from:
    - movie_list: Movies
  remove_on_match: true
  single_match: true
pathscrub: windows
priority: 20
proper_movies: false
quality: 2160p webdl+ dts+
regexp:
  reject:
    - \bR5\b:
        from: title
    - \bWEBSCR\b:
        from: title
    - \bscreener\b:
        from: title
    - \bTS\b:
        from: title
    - \bCam\b:
        from: title
    - \bITA\b:
        from: title
    - \bGERMAN\b:
        from: title
    - \bFRENCH\b:
        from: title
    - \bRUS\b:
        from: title
    - \bHC\b:
        from: title
    - \bREMUX\b:
        from: title
    - \bBDRiP\b:
        from: title
    - \bSUBFRENCH\b:
        from: title
sort_by:
  field: quality
  reverse: true
template:
  - global-settings
  - movie-settings
tmdb_lookup: true
trakt_lookup:
  account: xxx
  username: xxx
transmission:
  host: transmission
  password: xxx
  port: 9091
  username: xxx
```
  
#### Log:
<details>
 <summary>(click to expand)</summary>

```
2021-01-19 23:34:45 VERBOSE  discover      search-movies   Searching for `Blade` with plugin `alpharatio` (31 of 45)
2021-01-19 23:34:45 DEBUG    alpharatio    search-movies   Using search params: {'filter_cat[9]': 1, 'filter_cat[10]': 1, 'order_by': 'time', 'search_submit': 1, 'action': 'basic', 'order_way': 'desc', 'freeleech': 0, 'searchstr': 'Blade'}
2021-01-19 23:34:45 DEBUG    alpharatio    search-movies   Found valid login cookie
2021-01-19 23:34:45 VERBOSE  utils.requests search-movies   Waiting 4.36 seconds until next request to alpharatio.cc
2021-01-19 23:34:50 DEBUG    utils.requests search-movies   GETing URL https://alpharatio.cc/torrents.php with args () and kwargs {'params': {'filter_cat[9]': 1, 'filter_cat[10]': 1, 'order_by': 'time', 'search_submit': 1, 'action': 'basic', 'order_way': 'desc', 'freeleech': 0, 'searchstr': 'Blade'}, 'cookies': {'__cfduid': 'xxx', 'session': 'xxx'}, 'allow_redirects': True, 'timeout': 30}
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   requesting: https://alpharatio.cc/torrents.php?filter_cat%5B9%5D=1&filter_cat%5B10%5D=1&order_by=time&search_submit=1&action=basic&order_way=desc&freeleech=0&searchstr=Blade
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 48.94 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 2.06 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 1.57 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 2.09 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 22.35 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 21.61 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 10.65 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 3.50 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 4.86 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 6.01 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 8.36 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 8.74 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 2.67 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 10.34 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 5.31 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 5.07 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 6.97 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 62.84 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 45.20 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 14.72 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 80.00 B
2021-01-19 23:34:50 ERROR    alpharatio    search-movies   No size found! Please create a Github issue. Size received: 80.00 B
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 8.02 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 8.02 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 31.03 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 1.09 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 639.40 MB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 15.31 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 45.67 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 12.03 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 16.98 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 8.74 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 2.33 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 9.32 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 16.29 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 16.63 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 3.52 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 5.20 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 17.86 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 15.73 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 1.97 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 28.16 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 7.64 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 12.03 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 5.25 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 1.90 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 5.65 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 3.10 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 5.09 GB
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   AlphaRatio size: 5.65 GB
2021-01-19 23:34:50 DEBUG    plugin        search-movies   decorator caught ValueError. handled traceback:
ValueError: invalid literal for int() with base 10: '1,609'
2021-01-19 23:34:50 ERROR    discover      search-movies   Error searching with alpharatio: invalid literal for int() with base 10: '1,609'
2021-01-19 23:34:50 VERBOSE  discover      search-movies   No search results for `Blade`
2021-01-19 23:34:50 VERBOSE  discover      search-movies   Searching for `Deadpool 3` with plugin `alpharatio` (32 of 45)
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   Using search params: {'filter_cat[9]': 1, 'filter_cat[10]': 1, 'order_by': 'time', 'search_submit': 1, 'action': 'basic', 'order_way': 'desc', 'freeleech': 0, 'searchstr': 'Deadpool 3'}
2021-01-19 23:34:50 DEBUG    alpharatio    search-movies   Found valid login cookie
2021-01-19 23:34:50 VERBOSE  utils.requests search-movies   Waiting 4.20 seconds until next request to alpharatio.cc
2021-01-19 23:34:55 DEBUG    utils.requests search-movies   GETing URL https://alpharatio.cc/torrents.php with args () and kwargs {'params': {'filter_cat[9]': 1, 'filter_cat[10]': 1, 'order_by': 'time', 'search_submit': 1, 'action': 'basic', 'order_way': 'desc', 'freeleech': 0, 'searchstr': 'Deadpool 3'}, 'cookies': {'__cfduid': 'xxxx', 'session': 'xxx'}, 'allow_redirects': True, 'timeout': 30}
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   requesting: https://alpharatio.cc/torrents.php?filter_cat%5B9%5D=1&filter_cat%5B10%5D=1&order_by=time&search_submit=1&action=basic&order_way=desc&freeleech=0&searchstr=Deadpool+3
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 2.70 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 19.29 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 9.52 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 3.28 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 1.01 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 537.06 MB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 564.96 MB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 1.05 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 4.87 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 5.50 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 8.82 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 11.84 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 3.24 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 4.07 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 41.79 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 13.71 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 10.36 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 16.66 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 7.50 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 50.58 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 4.98 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 5.83 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 10.25 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 5.81 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 6.12 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 32.62 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 24.48 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 17.20 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 6.60 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 10.98 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 5.23 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 19.49 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 7.79 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 6.43 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 4.18 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 3.75 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 2.87 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 17.99 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 4.08 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 3.68 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 4.69 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 16.59 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 39.82 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 3.09 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 3.04 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 33.76 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 11.36 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 2.79 GB
2021-01-19 23:34:55 DEBUG    alpharatio    search-movies   AlphaRatio size: 7.73 GB
2021-01-19 23:34:55 DEBUG    plugin        search-movies   decorator caught ValueError. handled traceback:
ValueError: invalid literal for int() with base 10: '1,136'
2021-01-19 23:34:55 ERROR    discover      search-movies   Error searching with alpharatio: invalid literal for int() with base 10: '1,136'
2021-01-19 23:34:55 VERBOSE  discover      search-movies   No search results for `Deadpool 3`
```
</details>

### Additional information:

- FlexGet version: 3.1.98
- Python version:
- Installation method:
- Using daemon (yes/no):
- OS and version:
- Link to crash 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:
Yes I agree, all the errors are result of sizes that don't match the regex, probably was there in the beginning  to enforce users to report issue and fine tune the regex! Probably it could be changed to a debug message.

Resolving patch:
diff --git a/flexget/components/sites/sites/alpharatio.py b/flexget/components/sites/sites/alpharatio.py
--- a/flexget/components/sites/sites/alpharatio.py
+++ b/flexget/components/sites/sites/alpharatio.py
@@ -295,14 +295,30 @@ def search(self, task, entry, config):
                 e['url'] = url
                 e['torrent_tags'] = torrent_tags
                 if not size:
-                    logger.error(
+                    logger.debug(
                         'No size found! Please create a Github issue. Size received: {}', size_col
                     )
                 else:
                     e['content_size'] = parse_filesize(size.group(0))
-                e['torrent_snatches'] = int(torrent_info[snatches_idx].text)
-                e['torrent_seeds'] = int(torrent_info[seeds_idx].text)
-                e['torrent_leeches'] = int(torrent_info[leeches_idx].text)
+
+                mappings_int = {
+                    'torrent_snatches': snatches_idx,
+                    'torrent_seeds': seeds_idx,
+                    'torrent_leeches': leeches_idx,
+                }
+
+                for dest, src in mappings_int.items():
+                    if not src in torrent_info:
+                        continue
+
+                    # Some values are tagged with a ',' insted of a '.', replace them
+                    value = torrent_info[src].text.replace(',', '.')
+
+                    try:
+                        e[dest] = int(value)
+                    except ValueError as e:
+                        logger.debug('Invalid \'{}\' with \'{}\'', dest, value)
+                        continue
 
                 entries.add(e)
 


Test patch: