Repository: Flexget/Flexget

Issue:
Unhandled error in plugin argenteam
<!---
Before opening an issue, verify:

- Is this a feature request? Post it on https://feathub.com/Flexget/Flexget
- 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 list of shows from Trakt and download needed shows,
--->

### Actual behavior:
It gets the list of shows from Trakt and starts searching for each show using the plug-ins. It then crashes.
### Steps to reproduce:
- Step 1: It happens every time it runs.

#### Config:
```
variables: secrets.yml

templates:


  tv:
    configure_series:
      settings:
        quality: 720p+
        identified_by: ep
      from:
        trakt_list:
          account: "{? trakt.account ?}"
          list: "{? trakt.series ?}"
          type: shows



  reject:
    regexp:
      reject:
        - \b(s|d)ub(s|bed|lado|titulado)?\b
        - \bhc\b
        - \bdual\b
        - \b3d\b
        - \bfre(nch)?\b
        - \bita(lian)?\b
        - \bspa(nish)?\b
        - \bger(man)?\b
        - \bcastellano\b
        - \brus(sian)?\b
        - \btamil\b
        - \bhindi\b
        - \bh265\b
        - \bx265\b
    content_filter:
      reject:
        - '*.rar'
        - '*.zip'
        - '*.exe'



  place_torrent:
    utorrent:
      url: "{? utorrent.url ?}"
      username: "{? utorrent.user ?}"
      password: "{? utorrent.pass ?}"
      path: "{? utorrent.path ?}"



  pushbullet:
    notify:
      entries:
        title: "[flexget] Downloading"
        message: "{{title}}"
        via:
          - pushbullet:
              api_key: "{? pushbullet.api ?}"





tasks:


  follow show from ep:
    seen: local
    trakt_list:
      account: "{? trakt.account ?}"
      list: "{? trakt.series ?}"
      type: episodes
    accept_all: yes
    set_series_begin: yes
    list_remove:
      - trakt_list:
          account: "{? trakt.account ?}"
          list: "{? trakt.series ?}"
          type: episodes
    list_add:
      - trakt_list:
          account: "{? trakt.account ?}"
          list: "{? trakt.series ?}"
          type: shows



  get shows:
    template:
      - tv
      - reject
      - place_torrent
      - pushbullet
    discover:
      what:
        - next_series_episodes:
            from_start: yes
      from:
        - piratebay:
            category: highres tv
        - limetorrents:
            category: tv
        - rarbg:
            category: [1, 18, 41, 49]
        - argenteam:
            force_subtitles: no
```
  
#### Log:
<details>
 <summary>(click to expand)</summary>


Debug Log - https://pastebin.com/bTr4qX6a
```
2019-03-16 05:40 VERBOSE  trakt_list    get shows       Retrieving `shows` list `720p_list`
2019-03-16 05:40 VERBOSE  discover      get shows       Discovering 26 titles ...
2019-03-16 05:40 INFO     discover      get shows       Ignoring interval because of --discover-now
2019-03-16 05:40 INFO     task          get shows       Plugin next_series_episodes has requested task to be ran again after execution has completed. Reason: Look for next season
2019-03-16 05:40 VERBOSE  discover      get shows       The Big Bang Theory (2007) S12E18 hasn't been released yet (Expected: 2019-04-04 00:00:00)
2019-03-16 05:40 VERBOSE  discover      get shows       Modern Family (2009) S10E18 hasn't been released yet (Expected: 2019-03-20 00:00:00)
2019-03-16 05:40 VERBOSE  discover      get shows       Game of Thrones (2011) S08E01 hasn't been released yet (Expected: 2019-04-14 00:00:00)
2019-03-16 05:40 VERBOSE  discover      get shows       The Goldbergs (2013) S06E19 hasn't been released yet (Expected: 2019-03-20 00:00:00)
2019-03-16 05:40 VERBOSE  discover      get shows       Schooled (2019) S01E09 hasn't been released yet (Expected: 2019-03-20 00:00:00)
2019-03-16 05:41 VERBOSE  discover      get shows       Searching for `Shameless (2011) S04E04` with plugin `piratebay` (1 of 10)
2019-03-16 05:41 VERBOSE  discover      get shows       Searching for `Shameless (2011) S04E04` with plugin `limetorrents` (1 of 10)
2019-03-16 05:41 VERBOSE  discover      get shows       Searching for `Shameless (2011) S04E04` with plugin `rarbg` (1 of 10)
2019-03-16 05:41 VERBOSE  discover      get shows       Searching for `Shameless (2011) S04E04` with plugin `argenteam` (1 of 10)
2019-03-16 05:41 CRITICAL task          get shows       BUG: Unhandled error in plugin discover: list index out of range
2019-03-16 05:41 CRITICAL manager       get shows       An unexpected crash has occurred. Writing crash report to C:\Users\Amishman\flexget\crash_report.2019.03.16.054135803000.log. Please verify you are running the latest version of flexget by using "flexget -V" from CLI or by using version_checker plugin at http://flexget.com/wiki/Plugins/version_checker. You are currently using version 2.20.12
2019-03-16 05:41 WARNING  task          get shows       Aborting task (plugin: discover)
```
</details>

### Additional information:

- FlexGet version: 2.20.12
- Python version: 2.7.13
- Installation method: pip
- Using daemon (yes/no): no
- OS and version: Windows 7 Pro
- Link to crash log:
[crash_report.2019.03.16.054135803000.log](https://github.com/Flexget/Flexget/files/2973746/crash_report.2019.03.16.054135803000.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). Note that FlexGet is not supported for use with Python v3.0, 3.1, 3.2 or 3.6.
- 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:
Looks like plugin argenteam crashes, removing it should allow others to work fine.
Removing the argenteam plugin fixed the issue. It does work properly now. Thank you.

Resolving patch:
diff --git a/flexget/components/sites/sites/argenteam.py b/flexget/components/sites/sites/argenteam.py
--- a/flexget/components/sites/sites/argenteam.py
+++ b/flexget/components/sites/sites/argenteam.py
@@ -74,6 +74,7 @@ def search(self, task, entry, config):
                 log.error('Argenteam request failed: %s', e)
                 return
 
+            log.debug('%s releases found.', len(response['releases']))
             for release in response['releases']:
                 for torrent in release['torrents']:
                     if (
@@ -95,7 +96,7 @@ def search(self, task, entry, config):
                         e['url'] = torrent['uri']
 
                         # Save aRGENTeaM subtitle URL for this release
-                        if 'subtitles' in release:
+                        if 'subtitles' in release and len(release['subtitles']) > 0:
                             e['argenteam_subtitle'] = release['subtitles'][0]['uri']
                             log.debug('Argenteam subtitle found: %s', e['argenteam_subtitle'])
 


Test patch: