Switched IPTorrents provider to the MultiProvider layout, few fixes to provider base for MultiProvider
This commit is contained in:
1 parent
5f427ec6ea
commit
d345a05b3c
5 files changed
+69
-40
No files matched your search
@@ -236,7 +236,7 @@ class Searcher(SearcherBase):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def correctWords(self, rel_name, media):
|
def correctWords(self, rel_name, media):
|
||||||
media_title = fireEvent('searcher.get_search_title', media)
|
media_title = fireEvent('searcher.get_search_title', media, single = True)
|
||||||
media_words = re.split('\W+', simplifyString(media_title))
|
media_words = re.split('\W+', simplifyString(media_title))
|
||||||
|
|
||||||
rel_name = simplifyString(rel_name)
|
rel_name = simplifyString(rel_name)
|
||||||
|
|||||||
@@ -270,6 +270,8 @@ class MovieSearcher(SearcherBase, MovieTypeBase):
|
|||||||
|
|
||||||
if media.get('type') != 'movie': return
|
if media.get('type') != 'movie': return
|
||||||
|
|
||||||
|
media_title = fireEvent('searcher.get_search_title', media, single = True)
|
||||||
|
|
||||||
imdb_results = kwargs.get('imdb_results', False)
|
imdb_results = kwargs.get('imdb_results', False)
|
||||||
retention = Env.setting('retention', section = 'nzb')
|
retention = Env.setting('retention', section = 'nzb')
|
||||||
|
|
||||||
@@ -330,7 +332,7 @@ class MovieSearcher(SearcherBase, MovieTypeBase):
|
|||||||
if len(movie_words) <= 2 and fireEvent('searcher.correct_year', nzb['name'], media['library']['year'], 0, single = True):
|
if len(movie_words) <= 2 and fireEvent('searcher.correct_year', nzb['name'], media['library']['year'], 0, single = True):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
log.info("Wrong: %s, undetermined naming. Looking for '%s (%s)'", (nzb['name'], movie_name, media['library']['year']))
|
log.info("Wrong: %s, undetermined naming. Looking for '%s (%s)'", (nzb['name'], media_title, media['library']['year']))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def couldBeReleased(self, is_pre_release, dates, year = None):
|
def couldBeReleased(self, is_pre_release, dates, year = None):
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import logging
|
|
||||||
from couchpotato.core.event import addEvent, fireEvent
|
from couchpotato.core.event import addEvent, fireEvent
|
||||||
from couchpotato.core.helpers.variable import tryFloat, mergeDicts, md5, \
|
from couchpotato.core.helpers.variable import tryFloat, mergeDicts, md5, \
|
||||||
possibleTitles, toIterable
|
possibleTitles, toIterable
|
||||||
@@ -115,9 +114,7 @@ class YarrProvider(Provider):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
addEvent('provider.enabled_protocols', self.getEnabledProtocol)
|
addEvent('provider.enabled_protocols', self.getEnabledProtocol)
|
||||||
addEvent('provider.belongs_to', self.belongsTo)
|
addEvent('provider.belongs_to', self.belongsTo)
|
||||||
|
addEvent('provider.search.%s.%s' % (self.protocol, self.type), self.search)
|
||||||
for type in toIterable(self.type):
|
|
||||||
addEvent('provider.search.%s.%s' % (self.protocol, type), self.search)
|
|
||||||
|
|
||||||
def getEnabledProtocol(self):
|
def getEnabledProtocol(self):
|
||||||
if self.isEnabled():
|
if self.isEnabled():
|
||||||
@@ -252,11 +249,11 @@ class YarrProvider(Provider):
|
|||||||
for group_name, group_cat_ids in self.cat_ids:
|
for group_name, group_cat_ids in self.cat_ids:
|
||||||
if len(group_cat_ids) > 0:
|
if len(group_cat_ids) > 0:
|
||||||
if type(group_cat_ids[0]) is tuple:
|
if type(group_cat_ids[0]) is tuple:
|
||||||
self.cat_ids_structure = 'groups'
|
self.cat_ids_structure = 'group'
|
||||||
if type(group_cat_ids[0]) is str:
|
if type(group_cat_ids[0]) is str:
|
||||||
self.cat_ids_structure = 'single'
|
self.cat_ids_structure = 'single'
|
||||||
|
|
||||||
def getCatId(self, identifier, media_type = 'movie'):
|
def getCatId(self, identifier, group = None):
|
||||||
|
|
||||||
cat_ids = self.cat_ids
|
cat_ids = self.cat_ids
|
||||||
|
|
||||||
@@ -264,9 +261,12 @@ class YarrProvider(Provider):
|
|||||||
self._discoverCatIdStructure()
|
self._discoverCatIdStructure()
|
||||||
|
|
||||||
# If cat_ids is in a 'groups' structure, locate the media group
|
# If cat_ids is in a 'groups' structure, locate the media group
|
||||||
if self.cat_ids_structure == 'groups':
|
if self.cat_ids_structure == 'group':
|
||||||
|
if not group:
|
||||||
|
raise ValueError("group is required on group cat_ids structure")
|
||||||
|
|
||||||
for group_type, group_cat_ids in cat_ids:
|
for group_type, group_cat_ids in cat_ids:
|
||||||
if media_type in toIterable(group_type):
|
if group in toIterable(group_type):
|
||||||
cat_ids = group_cat_ids
|
cat_ids = group_cat_ids
|
||||||
|
|
||||||
for cats in cat_ids:
|
for cats in cat_ids:
|
||||||
|
|||||||
@@ -2,44 +2,42 @@ from bs4 import BeautifulSoup
|
|||||||
from couchpotato.core.helpers.encoding import tryUrlencode
|
from couchpotato.core.helpers.encoding import tryUrlencode
|
||||||
from couchpotato.core.helpers.variable import tryInt
|
from couchpotato.core.helpers.variable import tryInt
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
|
from couchpotato.core.providers.base import MultiProvider
|
||||||
|
from couchpotato.core.providers.info.base import MovieProvider, ShowProvider
|
||||||
from couchpotato.core.providers.torrent.base import TorrentProvider
|
from couchpotato.core.providers.torrent.base import TorrentProvider
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
|
|
||||||
|
|
||||||
class IPTorrents(TorrentProvider):
|
class IPTorrents(MultiProvider):
|
||||||
|
|
||||||
type = ['movie', 'season', 'episode']
|
def getTypes(self):
|
||||||
|
return [Movie, Show]
|
||||||
|
|
||||||
|
|
||||||
|
class Base(TorrentProvider):
|
||||||
|
|
||||||
urls = {
|
urls = {
|
||||||
'test' : 'http://www.iptorrents.com/',
|
'test' : 'http://www.iptorrents.com/',
|
||||||
'base_url' : 'http://www.iptorrents.com',
|
'base_url' : 'http://www.iptorrents.com',
|
||||||
'login' : 'http://www.iptorrents.com/torrents/',
|
'login' : 'http://www.iptorrents.com/torrents/',
|
||||||
'login_check': 'http://www.iptorrents.com/inbox.php',
|
'login_check': 'http://www.iptorrents.com/inbox.php',
|
||||||
'search' : 'http://www.iptorrents.com/torrents/?l%d=1%s&q=%s&qf=ti&p=%d',
|
'search' : 'http://www.iptorrents.com/torrents/?l%d=1%%s&q=%s&qf=ti&p=%%d',
|
||||||
}
|
}
|
||||||
|
|
||||||
cat_ids = [
|
|
||||||
('movie', [
|
|
||||||
([48], ['720p', '1080p', 'bd50']),
|
|
||||||
([72], ['cam', 'ts', 'tc', 'r5', 'scr']),
|
|
||||||
([7], ['dvdrip', 'brrip']),
|
|
||||||
([6], ['dvdr']),
|
|
||||||
]),
|
|
||||||
('season', [
|
|
||||||
([65], ['hdtv', '480p', '720p', '1080p']),
|
|
||||||
]),
|
|
||||||
('episode', [
|
|
||||||
([5], ['720p', '1080p']),
|
|
||||||
([78], ['480p']),
|
|
||||||
([4, 79], ['hdtv'])
|
|
||||||
])
|
|
||||||
]
|
|
||||||
|
|
||||||
http_time_between_calls = 1 #seconds
|
http_time_between_calls = 1 #seconds
|
||||||
cat_backup_id = None
|
cat_backup_id = None
|
||||||
|
|
||||||
|
def _buildUrl(self, query, quality_identifier, cat_ids_group = None):
|
||||||
|
|
||||||
|
cat_id = self.getCatId(quality_identifier, cat_ids_group)[0]
|
||||||
|
if not cat_id:
|
||||||
|
log.warning('Unable to find category for quality %s', quality_identifier)
|
||||||
|
return
|
||||||
|
|
||||||
|
return self.urls['search'] % (cat_id, tryUrlencode(query))
|
||||||
|
|
||||||
def _searchOnTitle(self, title, media, quality, results):
|
def _searchOnTitle(self, title, media, quality, results):
|
||||||
|
|
||||||
freeleech = '' if not self.conf('freeleech') else '&free=on'
|
freeleech = '' if not self.conf('freeleech') else '&free=on'
|
||||||
@@ -47,17 +45,11 @@ class IPTorrents(TorrentProvider):
|
|||||||
pages = 1
|
pages = 1
|
||||||
current_page = 1
|
current_page = 1
|
||||||
while current_page <= pages and not self.shuttingDown():
|
while current_page <= pages and not self.shuttingDown():
|
||||||
|
url = self.buildUrl(title, media, quality)
|
||||||
|
if not url: return
|
||||||
|
|
||||||
query = title.replace(':', '')
|
url = url % (freeleech, current_page)
|
||||||
if media['type'] == 'movie':
|
|
||||||
query = '%s %s' % (title.replace(':', ''), media['library']['year'])
|
|
||||||
|
|
||||||
cat_id = self.getCatId(quality['identifier'], media['type'])[0]
|
|
||||||
if not cat_id:
|
|
||||||
log.warning('Unable to find category for quality %s and media type %s', (quality['identifier'], media['type']))
|
|
||||||
return
|
|
||||||
|
|
||||||
url = self.urls['search'] % (cat_id, freeleech, tryUrlencode(query), current_page)
|
|
||||||
data = self.getHTMLData(url, opener = self.login_opener)
|
data = self.getHTMLData(url, opener = self.login_opener)
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
@@ -122,3 +114,38 @@ class IPTorrents(TorrentProvider):
|
|||||||
|
|
||||||
def loginCheckSuccess(self, output):
|
def loginCheckSuccess(self, output):
|
||||||
return '/logout.php' in output.lower()
|
return '/logout.php' in output.lower()
|
||||||
|
|
||||||
|
|
||||||
|
class Movie(MovieProvider, Base):
|
||||||
|
|
||||||
|
cat_ids = [
|
||||||
|
([48], ['720p', '1080p', 'bd50']),
|
||||||
|
([72], ['cam', 'ts', 'tc', 'r5', 'scr']),
|
||||||
|
([7], ['dvdrip', 'brrip']),
|
||||||
|
([6], ['dvdr']),
|
||||||
|
]
|
||||||
|
|
||||||
|
def buildUrl(self, title, media, quality):
|
||||||
|
query = '%s %s' % (title.replace(':', ''), media['library']['year'])
|
||||||
|
|
||||||
|
return self._buildUrl(query, quality['identifier'])
|
||||||
|
|
||||||
|
|
||||||
|
class Show(ShowProvider, Base):
|
||||||
|
|
||||||
|
cat_ids = [
|
||||||
|
('season', [
|
||||||
|
([65], ['hdtv', '480p', '720p', '1080p']),
|
||||||
|
]),
|
||||||
|
('episode', [
|
||||||
|
([5], ['720p', '1080p']),
|
||||||
|
([78], ['480p']),
|
||||||
|
([4, 79], ['hdtv'])
|
||||||
|
])
|
||||||
|
]
|
||||||
|
|
||||||
|
def buildUrl(self, title, media, quality):
|
||||||
|
if media['type'] not in ['season', 'episode']:
|
||||||
|
return
|
||||||
|
|
||||||
|
return self._buildUrl(title.replace(':', ''), quality['identifier'], media['type'])
|
||||||
@@ -102,7 +102,7 @@ class Base(TorrentProvider):
|
|||||||
loginCheckSuccess = loginSuccess
|
loginCheckSuccess = loginSuccess
|
||||||
|
|
||||||
|
|
||||||
class Movie(Base, MovieProvider):
|
class Movie(MovieProvider, Base):
|
||||||
|
|
||||||
cat_ids = [
|
cat_ids = [
|
||||||
([22], ['720p', '1080p']),
|
([22], ['720p', '1080p']),
|
||||||
|
|||||||
Reference in new issue
Block a user