Browse Source

Update torrentpotato.py

refactoring
pull/7325/head
mrlt8 4 years ago
committed by GitHub
parent
commit
3d653f3e2b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      couchpotato/core/media/_base/providers/torrent/torrentpotato.py

8
couchpotato/core/media/_base/providers/torrent/torrentpotato.py

@ -47,15 +47,9 @@ class Base(TorrentProvider):
req = requests.get(torrent.get('download_url'), allow_redirects = False) req = requests.get(torrent.get('download_url'), allow_redirects = False)
if req.status_code == 302 and re.match('^magnet:.*$', req.headers["Location"]): if req.status_code == 302 and re.match('^magnet:.*$', req.headers["Location"]):
torrent['download_url'] = req.headers["Location"] torrent['download_url'] = req.headers["Location"]
proto = "torrent_magnet"
else:
proto = "transmission"
else:
proto = "torrent_magnet"
results.append({ results.append({
'id': torrent.get('torrent_id'), 'id': torrent.get('torrent_id'),
'protocol' : proto, 'protocol': 'torrent' if re.match('^(http|https|ftp)://.*$', torrent.get('download_url')) else 'torrent_magnet',
'provider_extra': urlparse(host['host']).hostname or host['host'], 'provider_extra': urlparse(host['host']).hostname or host['host'],
'name': toUnicode(torrent.get('release_name')), 'name': toUnicode(torrent.get('release_name')),
'url': torrent.get('download_url'), 'url': torrent.get('download_url'),

Loading…
Cancel
Save