Magnet type for TPB and transmssion support
This commit is contained in:
@@ -167,7 +167,6 @@ class Transmission(Downloader):
|
|||||||
remote_torrent = tc.add_torrent_file(b64encode(filedata), arguments=params)
|
remote_torrent = tc.add_torrent_file(b64encode(filedata), arguments=params)
|
||||||
|
|
||||||
# Change settings of added torrents
|
# Change settings of added torrents
|
||||||
print remote_torrent
|
|
||||||
tc.set_torrent(remote_torrent['torrent-added']['hashString'
|
tc.set_torrent(remote_torrent['torrent-added']['hashString'
|
||||||
], torrent_params)
|
], torrent_params)
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ log = CPLog(__name__)
|
|||||||
|
|
||||||
class ThePirateBay(TorrentProvider):
|
class ThePirateBay(TorrentProvider):
|
||||||
|
|
||||||
urls = {'detail': '%s/torrent/%s', 'search': '%s/search/%s/0/7/%d'}
|
|
||||||
|
|
||||||
cat_ids = [([207], ['720p', '1080p']), ([201], [
|
cat_ids = [([207], ['720p', '1080p']), ([201], [
|
||||||
'cam',
|
'cam',
|
||||||
'ts',
|
'ts',
|
||||||
@@ -25,10 +23,15 @@ class ThePirateBay(TorrentProvider):
|
|||||||
'scr',
|
'scr',
|
||||||
'brrip',
|
'brrip',
|
||||||
]), ([202], ['dvdr'])]
|
]), ([202], ['dvdr'])]
|
||||||
|
|
||||||
cat_backup_id = 200
|
cat_backup_id = 200
|
||||||
|
|
||||||
def getAPIurl(self):
|
def __init__(self):
|
||||||
return ("http://thepiratebay.se", self.conf('domain_for_tpb'))[self.conf('domain_for_tpb') != None]
|
super(ThePirateBay, self).__init__()
|
||||||
|
self.urls = {"test": self.getAPIurl(), 'detail': '%s/torrent/%s', 'search': '%s/search/%s/0/7/%d'}
|
||||||
|
|
||||||
|
def getAPIurl(self, url=""):
|
||||||
|
return (("http://thepiratebay.se", self.conf('domain_for_tpb'))[self.conf('domain_for_tpb') != None]) + url
|
||||||
|
|
||||||
def search(self, movie, quality):
|
def search(self, movie, quality):
|
||||||
|
|
||||||
@@ -38,8 +41,10 @@ class ThePirateBay(TorrentProvider):
|
|||||||
|
|
||||||
movie_name = re.sub("\W", ' ', getTitle(movie['library']))
|
movie_name = re.sub("\W", ' ', getTitle(movie['library']))
|
||||||
movie_name = re.sub(' ', ' ', movie_name)
|
movie_name = re.sub(' ', ' ', movie_name)
|
||||||
|
|
||||||
log.info('API url: %s', self.getAPIurl())
|
log.info('API url: %s', self.getAPIurl())
|
||||||
log.info('Cleaned Name: %s', movie_name)
|
log.info('Cleaned Name: %s', movie_name)
|
||||||
|
|
||||||
cache_key = 'thepiratebay.%s.%s' % (movie['library'
|
cache_key = 'thepiratebay.%s.%s' % (movie['library'
|
||||||
]['identifier'], quality.get('identifier'))
|
]['identifier'], quality.get('identifier'))
|
||||||
searchUrl = self.urls['search'] % (self.getAPIurl(),
|
searchUrl = self.urls['search'] % (self.getAPIurl(),
|
||||||
@@ -64,19 +69,20 @@ class ThePirateBay(TorrentProvider):
|
|||||||
size = re.search('Size (?P<size>.+),', unicode(result.select("font.detDesc")[0])).group("size")
|
size = re.search('Size (?P<size>.+),', unicode(result.select("font.detDesc")[0])).group("size")
|
||||||
if link and download:
|
if link and download:
|
||||||
new = {
|
new = {
|
||||||
'type': 'torrent',
|
'type': 'magnet',
|
||||||
'check_nzb': False,
|
'check_nzb': False,
|
||||||
'description': '',
|
'description': '',
|
||||||
'provider': self.getName(),
|
'provider': self.getName(),
|
||||||
}
|
}
|
||||||
|
|
||||||
trusted = (0, 10)[result.find('img',
|
trusted = (0, 10)[result.find('img',
|
||||||
alt=re.compile('Trusted')) != None]
|
alt=re.compile('Trusted')) != None]
|
||||||
vip = (0, 20)[result.find('img',
|
vip = (0, 20)[result.find('img',
|
||||||
alt=re.compile('VIP')) != None]
|
alt=re.compile('VIP')) != None]
|
||||||
moderated = (0, 50)[result.find('img',
|
moderated = (0, 50)[result.find('img',
|
||||||
alt=re.compile('Moderator')) != None]
|
alt=re.compile('Moderator')) != None]
|
||||||
log.info('Name: %s', link.string)
|
|
||||||
|
|
||||||
|
log.info('Name: %s', link.string)
|
||||||
log.info('Seeders: %s', result.findAll('td'
|
log.info('Seeders: %s', result.findAll('td'
|
||||||
)[2].string)
|
)[2].string)
|
||||||
log.info('Leechers: %s', result.findAll('td'
|
log.info('Leechers: %s', result.findAll('td'
|
||||||
@@ -88,24 +94,26 @@ class ThePirateBay(TorrentProvider):
|
|||||||
new['name'] = link.string
|
new['name'] = link.string
|
||||||
new['id'] = re.search('/(?P<id>\d+)/', link['href'
|
new['id'] = re.search('/(?P<id>\d+)/', link['href'
|
||||||
]).group('id')
|
]).group('id')
|
||||||
new['url'] = link['href']
|
new['url'] = self.getAPIurl(link['href'])
|
||||||
new['download'] = self.getAPIurl() + download['href']
|
new['magnet'] = unicode(download['href']) # forcing of storing full magnet data
|
||||||
new['size'] = self.parseSize(size)
|
new['size'] = self.parseSize(size)
|
||||||
new['seeders'] = int(result.findAll('td')[2].string)
|
new['seeders'] = int(result.findAll('td')[2].string)
|
||||||
new['leechers'] = int(result.findAll('td'
|
new['leechers'] = int(result.findAll('td'
|
||||||
)[3].string)
|
)[3].string)
|
||||||
new['imdbid'] = movie['library']['identifier']
|
|
||||||
new['prtbscore'] = trusted + vip + moderated
|
|
||||||
|
|
||||||
|
new['TPB_score'] = trusted + vip + moderated
|
||||||
new['extra_score'] = self.extra_score
|
new['extra_score'] = self.extra_score
|
||||||
new['score'] = fireEvent('score.calculate', new,
|
new['score'] = fireEvent('score.calculate', new,
|
||||||
movie, single=True)
|
movie, single=True)
|
||||||
|
|
||||||
|
isImdb = self.imdbMatch(self.getAPIurl(link['href']), movie['library']['identifier'])
|
||||||
|
|
||||||
is_correct_movie = fireEvent(
|
is_correct_movie = fireEvent(
|
||||||
'searcher.correct_movie',
|
'searcher.correct_movie',
|
||||||
nzb=new,
|
nzb=new,
|
||||||
movie=movie,
|
movie=movie,
|
||||||
quality=quality,
|
quality=quality,
|
||||||
imdb_results=True,
|
imdb_results=isImdb,
|
||||||
single_category=False,
|
single_category=False,
|
||||||
single=True,
|
single=True,
|
||||||
)
|
)
|
||||||
@@ -122,10 +130,7 @@ class ThePirateBay(TorrentProvider):
|
|||||||
return results
|
return results
|
||||||
|
|
||||||
def extra_score(self, torrent):
|
def extra_score(self, torrent):
|
||||||
url = self.getAPIurl() + torrent['url']
|
return torrent["TPB_score"]
|
||||||
log.info('extra_score: %s', url)
|
|
||||||
imdbId = torrent['imdbid']
|
|
||||||
return self.imdbMatch(url, imdbId) + torrent['prtbscore']
|
|
||||||
|
|
||||||
def imdbMatch(self, url, imdbId):
|
def imdbMatch(self, url, imdbId):
|
||||||
log.info('imdbMatch: %s', url)
|
log.info('imdbMatch: %s', url)
|
||||||
@@ -134,10 +139,13 @@ class ThePirateBay(TorrentProvider):
|
|||||||
pass
|
pass
|
||||||
except:
|
except:
|
||||||
log.error('Failed to open %s.' % url)
|
log.error('Failed to open %s.' % url)
|
||||||
return 0
|
return False
|
||||||
imdbIdAlt = re.sub('tt[0]*', 'tt', imdbId)
|
imdbIdAlt = re.sub('tt[0]*', 'tt', imdbId)
|
||||||
data = unicode(data, errors='ignore')
|
data = unicode(data, errors='ignore')
|
||||||
if 'imdb.com/title/' + imdbId in data or 'imdb.com/title/' \
|
if 'imdb.com/title/' + imdbId in data or 'imdb.com/title/' \
|
||||||
+ imdbIdAlt in data:
|
+ imdbIdAlt in data:
|
||||||
return 50
|
return True
|
||||||
return 0
|
return False
|
||||||
|
|
||||||
|
def download(self, url='', nzb_id=''):
|
||||||
|
return url
|
||||||
|
|||||||
Reference in New Issue
Block a user