Repository: Flexget/Flexget

Issue:
Unhandled error with Blu-Ray.com
<!---
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 behaviour:
Gracefully handling of the error so the task isn't aborted.

### Actual behaviour:
Task aborts when plugin can't connect to `m.bluray.com`


#### Config:
```yaml
--- config from task: download-movies-720p-discover
imdb_lookup: true
tmdb_lookup: true
convert_magnet: false
no_entries_ok: true
quality: 720p webdl+
disable:
  - seen
  - seen_info_hash
  - retry_failed
discover:
  from:
    - search_rss: https://yts.am/rss/{{search_term}}/720p/all/0
  interval: 15 minutes
  release_estimations:
    optimistic: 30 days
  what:
    - movie_list:
        list_name: trakt-movies
        strip_year: true
if:
  - tmdb_year > 2013: reject
list_match:
  action: accept
  from:
    - movie_list: trakt-movies
  remove_on_match: true
  single_match: true
magnets: true
movie_list: trakt-movies

---
```
  
#### Log:
<details>
 <summary>(click to expand)</summary>

```
2019-10-20 13:18 VERBOSE  discover      download-movies-720p-discover Discovering 23 titles ...
2019-10-20 13:18 INFO     discover      download-movies-720p-discover Ignoring interval because of --discover-now
2019-10-20 13:18 WARNING  urllib3.connectionpool                 Retrying (Retry(total=0, connect=None, read=None, redirect=0, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x07DC7EF0>: Failed to establish a new connection: [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond',)': /countries.json.php?_=1571588308706
2019-10-20 13:19 CRITICAL task          download-movies-720p-discover BUG: Unhandled error in plugin discover: HTTPSConnectionPool(host='m.blu-ray.com', port=443): Max retries exceeded with url: /movies/X-Men-Apocalypse-Blu-ray/206030/ (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x082EF470>: Failed to establish a new connection: [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond',))
Traceback (most recent call last):
  File "c:\python27\lib\site-packages\flexget\task.py", line 522, in __run_plugin
    return method(*args, **kwargs)
  File "c:\python27\lib\site-packages\flexget\event.py", line 23, in __call__
    return self.func(*args, **kwargs)
  File "c:\python27\lib\site-packages\flexget\plugins\input\discover.py", line 292, in on_task_input
    entries = self.estimated(entries, estimation_mode)
  File "c:\python27\lib\site-packages\flexget\plugins\input\discover.py", line 183, in estimated
    est_date = estimator.estimate(entry)
  File "c:\python27\lib\site-packages\flexget\components\estimate_release\estimate_release.py", line 30, in estimate
    estimate = estimator(entry)
  File "c:\python27\lib\site-packages\flexget\components\estimate_release\estimators\est_movies_bluray.py", line 36, in estimate
    movie = lookup(title=movie_name, year=movie_year, session=session)
  File "c:\python27\lib\site-packages\flexget\plugins\internal\api_bluray.py", line 238, in lookup
    updated_movie = BlurayMovie(title=title, year=year)
  File "<string>", line 4, in __init__
  File "c:\python27\lib\site-packages\sqlalchemy\orm\state.py", line 441, in _initialize_instance
    manager.dispatch.init_failure(self, args, kwargs)
  File "c:\python27\lib\site-packages\sqlalchemy\util\langhelpers.py", line 68, in __exit__
    compat.reraise(exc_type, exc_value, exc_tb)
  File "c:\python27\lib\site-packages\sqlalchemy\orm\state.py", line 438, in _initialize_instance
    return manager.original_init(*mixed[1:], **kwargs)
  File "c:\python27\lib\site-packages\flexget\plugins\internal\api_bluray.py", line 129, in __init__
    movie_info_response = requests.get(self.url).content
  File "c:\python27\lib\site-packages\flexget\utils\requests.py", line 287, in get
    return request('get', url, **kwargs)
  File "c:\python27\lib\site-packages\flexget\utils\requests.py", line 267, in request
    return s.request(method=method, url=url, **kwargs)
  File "c:\python27\lib\site-packages\flexget\utils\requests.py", line 252, in request
    result = super(Session, self).request(method, url, *args, **kwargs)
  File "c:\python27\lib\site-packages\requests\sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "c:\python27\lib\site-packages\requests\sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "c:\python27\lib\site-packages\requests\adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
ConnectionError: HTTPSConnectionPool(host='m.blu-ray.com', port=443): Max retries exceeded with url: /movies/X-Men-Apocalypse-Blu-ray/206030/ (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x082EF470>: Failed to establish a new connection: [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond',))
```
</details>

### Additional information:

- FlexGet version: 2.21.28
- Python version: 2.7.16
- Installation method: pip
- Using daemon (yes/no): yes
- OS and version: Windows 10 1903
- Link to crash log: ---


Discussion:

Resolving patch:
diff --git a/flexget/plugins/internal/api_bluray.py b/flexget/plugins/internal/api_bluray.py
--- a/flexget/plugins/internal/api_bluray.py
+++ b/flexget/plugins/internal/api_bluray.py
@@ -126,7 +126,10 @@ def __init__(self, title, year):
             # Used for parsing some more data, sadly with soup
             self.url = result['url']
 
-            movie_info_response = requests.get(self.url).content
+            try:
+                movie_info_response = requests.get(self.url).content
+            except (requests.RequestException, ConnectionError) as e:
+                raise LookupError("Couldn't connect to blu-ray.com. %s" % self.url)
 
             movie_info = get_soup(movie_info_response)
 


Test patch: