Commit c0f1698d authored by echel0n's avatar echel0n
Browse files

Added custom url setting to torrent9 provider

parent 774a2536
# Changelog
- * 49c2bfe - 2017-12-15: Release v9.2.64
- * 3ddd4d7 - 2017-12-15: Added custom url setting to torrent9 provider
- * 032e9ed - 2017-12-15: Release v9.2.64
- * 92337a7 - 2017-12-15: Added code to cleanup cached provider results with UNKNOWN quality Added code to prevent parsed search results with UNKNOWN quality from being cached
- * 9d35ea1 - 2017-12-14: Release v9.2.63
- * 22c5664 - 2017-12-14: Fixed issue "Unable to contact theTVDB: [0]: Series result returned zero"
......
......@@ -25,7 +25,7 @@ from urlparse import urljoin
import sickrage
from sickrage.core.caches.tv_cache import TVCache
from sickrage.core.helpers import bs4_parser, try_int, convert_size
from sickrage.core.helpers import bs4_parser, try_int, convert_size, validate_url
from sickrage.providers import TorrentProvider
......@@ -41,6 +41,8 @@ class Torrent9Provider(TorrentProvider):
self.minseed = None
self.minleech = None
self.custom_url = ""
self.proper_strings = ['PROPER', 'REPACK']
self.cache = TVCache(self)
......@@ -65,6 +67,12 @@ class Torrent9Provider(TorrentProvider):
else:
search_url = self.urls['rss']
if self.custom_url:
if not validate_url(self.custom_url):
sickrage.app.log.warning("Invalid custom url: {0}".format(self.custom_url))
return results
search_url = urljoin(self.custom_url, search_url.split(self.urls['base_url'])[1])
try:
data = self.session.get(search_url).text
results += self.parse(data, mode)
......@@ -90,7 +98,8 @@ class Torrent9Provider(TorrentProvider):
title = result.find('a').get_text(strip=False).replace("HDTV", "HDTV x264-Torrent9")
title = re.sub(r' Saison', ' Season', title, flags=re.I)
tmp = result.find("a")['href'].split('/')[-1].replace('.html', '.torrent').strip()
download_url = (self.urls['base_url'] + '/get_torrent/{0}'.format(tmp) + ".torrent")
download_url = urljoin(self.custom_url or self.urls['base_url'],
'/get_torrent/{0}'.format(tmp) + ".torrent")
if not all([title, download_url]):
continue
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment