Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use old method to get the redirect URL for Jackett. Fixes #6788 #6790

Merged
merged 2 commits into from
Jun 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions medusa/providers/torrent/torrent_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
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())

Expand Down Expand Up @@ -149,10 +151,18 @@ 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})

response = self.session.get(url, stream=True)
if response:
response.close()
return response.url
try:
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('Unable to retrieve redirect URL for {url}', {'url': url})
return url
Expand Down