From 7d9d3c04c782fa6f4865d7389a2c66bf55ff678c Mon Sep 17 00:00:00 2001 From: Dario Date: Thu, 13 Jun 2019 00:34:02 +0200 Subject: [PATCH 1/2] Use alternative method to get the redirect URL for Jackett. Fixes #6826 --- medusa/providers/torrent/torrent_provider.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/medusa/providers/torrent/torrent_provider.py b/medusa/providers/torrent/torrent_provider.py index 87a3495ec7..3e74e7d189 100644 --- a/medusa/providers/torrent/torrent_provider.py +++ b/medusa/providers/torrent/torrent_provider.py @@ -22,8 +22,6 @@ from medusa.logger.adapters.style import BraceAdapter from medusa.providers.generic_provider import GenericProvider -from requests.exceptions import InvalidSchema - log = BraceAdapter(logging.getLogger(__name__)) log.logger.addHandler(logging.NullHandler()) @@ -151,18 +149,17 @@ def get_redirect_url(self, url): """Get the final address that the provided URL redirects to.""" log.debug('Retrieving redirect URL for {url}', {'url': url}) - try: - response = self.session.get(url, stream=True) - if response: - response.close() - return response.url + response = self.session.get(url, stream=True) + if response: + response.close() + return response.url # Jackett redirects to a magnet causing InvalidSchema. # Use an alternative method to get the redirect URL. - except InvalidSchema: - response = self.session.get(url, allow_redirects=False) - if response and response.headers.get('Location'): - return response.headers['Location'] + log.debug('Using alternative method to retrieve redirect URL') + response = self.session.get(url, allow_redirects=False) + if response and response.headers.get('Location'): + return response.headers['Location'] log.debug('Unable to retrieve redirect URL for {url}', {'url': url}) return url From 5f7f6bb3c3c089181237a92db344cc87fe2fd86c Mon Sep 17 00:00:00 2001 From: Dario Date: Thu, 13 Jun 2019 00:37:25 +0200 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a0003f3458..d2476b7c04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ #### Improvements #### Fixes +- Fixed Jackett providers returning empty torrents on magnet redirect (2) ([#6827](https://github.com/pymedusa/Medusa/pull/6827)) -----