|
|
@ -1,16 +1,15 @@ |
|
|
|
from bs4 import BeautifulSoup |
|
|
|
from couchpotato.core.event import fireEvent |
|
|
|
from couchpotato.core.helpers.encoding import simplifyString |
|
|
|
from couchpotato.core.helpers.variable import tryInt, getTitle |
|
|
|
from couchpotato.core.helpers.variable import tryInt |
|
|
|
from couchpotato.core.logger import CPLog |
|
|
|
from couchpotato.core.providers.torrent.base import TorrentProvider |
|
|
|
from couchpotato.core.providers.base import ResultList |
|
|
|
from couchpotato.core.providers.torrent.base import TorrentMagnetProvider |
|
|
|
import re |
|
|
|
import traceback |
|
|
|
|
|
|
|
log = CPLog(__name__) |
|
|
|
|
|
|
|
|
|
|
|
class KickAssTorrents(TorrentProvider): |
|
|
|
class KickAssTorrents(TorrentMagnetProvider): |
|
|
|
|
|
|
|
urls = { |
|
|
|
'test': 'https://kat.ph/', |
|
|
@ -32,14 +31,13 @@ class KickAssTorrents(TorrentProvider): |
|
|
|
|
|
|
|
def search(self, movie, quality): |
|
|
|
|
|
|
|
results = [] |
|
|
|
if self.isDisabled(): |
|
|
|
return results |
|
|
|
return [] |
|
|
|
|
|
|
|
title = simplifyString(getTitle(movie['library'])).replace(' ', '-') |
|
|
|
results = ResultList(self, movie, quality, imdb_results = True) |
|
|
|
|
|
|
|
data = self.getHTMLData(self.urls['search'] % ('m', movie['library']['identifier'].replace('tt', ''))) |
|
|
|
|
|
|
|
cache_key = 'kickasstorrents.%s.%s' % (movie['library']['identifier'], quality.get('identifier')) |
|
|
|
data = self.getCache(cache_key, self.urls['search'] % (title, movie['library']['identifier'].replace('tt', ''))) |
|
|
|
if data: |
|
|
|
|
|
|
|
cat_ids = self.getCatId(quality['identifier']) |
|
|
@ -53,57 +51,39 @@ class KickAssTorrents(TorrentProvider): |
|
|
|
continue |
|
|
|
|
|
|
|
try: |
|
|
|
|
|
|
|
try: |
|
|
|
for temp in result.find_all('tr'): |
|
|
|
if temp['class'] is 'firstr' or not temp.get('id'): |
|
|
|
continue |
|
|
|
|
|
|
|
new = { |
|
|
|
'type': 'torrent_magnet', |
|
|
|
'check_nzb': False, |
|
|
|
'description': '', |
|
|
|
'provider': self.getName(), |
|
|
|
'score': 0, |
|
|
|
} |
|
|
|
|
|
|
|
nr = 0 |
|
|
|
for td in temp.find_all('td'): |
|
|
|
column_name = table_order[nr] |
|
|
|
if column_name: |
|
|
|
|
|
|
|
if column_name is 'name': |
|
|
|
link = td.find('div', {'class': 'torrentname'}).find_all('a')[1] |
|
|
|
new['id'] = temp.get('id')[-8:] |
|
|
|
new['name'] = link.text |
|
|
|
new['url'] = td.find('a', 'imagnet')['href'] |
|
|
|
new['detail_url'] = self.urls['detail'] % link['href'][1:] |
|
|
|
new['score'] = 20 if td.find('a', 'iverif') else 0 |
|
|
|
elif column_name is 'size': |
|
|
|
new['size'] = self.parseSize(td.text) |
|
|
|
elif column_name is 'age': |
|
|
|
new['age'] = self.ageToDays(td.text) |
|
|
|
elif column_name is 'seeds': |
|
|
|
new['seeders'] = tryInt(td.text) |
|
|
|
elif column_name is 'leechers': |
|
|
|
new['leechers'] = tryInt(td.text) |
|
|
|
|
|
|
|
nr += 1 |
|
|
|
|
|
|
|
new['score'] += fireEvent('score.calculate', new, movie, single = True) |
|
|
|
is_correct_movie = fireEvent('searcher.correct_movie', |
|
|
|
nzb = new, movie = movie, quality = quality, |
|
|
|
imdb_results = True, single = True) |
|
|
|
|
|
|
|
if is_correct_movie: |
|
|
|
results.append(new) |
|
|
|
self.found(new) |
|
|
|
except: |
|
|
|
log.error('Failed parsing KickAssTorrents: %s', traceback.format_exc()) |
|
|
|
for temp in result.find_all('tr'): |
|
|
|
if temp['class'] is 'firstr' or not temp.get('id'): |
|
|
|
continue |
|
|
|
|
|
|
|
new = {} |
|
|
|
|
|
|
|
nr = 0 |
|
|
|
for td in temp.find_all('td'): |
|
|
|
column_name = table_order[nr] |
|
|
|
if column_name: |
|
|
|
|
|
|
|
if column_name is 'name': |
|
|
|
link = td.find('div', {'class': 'torrentname'}).find_all('a')[1] |
|
|
|
new['id'] = temp.get('id')[-8:] |
|
|
|
new['name'] = link.text |
|
|
|
new['url'] = td.find('a', 'imagnet')['href'] |
|
|
|
new['detail_url'] = self.urls['detail'] % link['href'][1:] |
|
|
|
new['score'] = 20 if td.find('a', 'iverif') else 0 |
|
|
|
elif column_name is 'size': |
|
|
|
new['size'] = self.parseSize(td.text) |
|
|
|
elif column_name is 'age': |
|
|
|
new['age'] = self.ageToDays(td.text) |
|
|
|
elif column_name is 'seeds': |
|
|
|
new['seeders'] = tryInt(td.text) |
|
|
|
elif column_name is 'leechers': |
|
|
|
new['leechers'] = tryInt(td.text) |
|
|
|
|
|
|
|
nr += 1 |
|
|
|
|
|
|
|
results.append(new) |
|
|
|
except: |
|
|
|
pass |
|
|
|
log.error('Failed parsing KickAssTorrents: %s', traceback.format_exc()) |
|
|
|
|
|
|
|
return results |
|
|
|
except AttributeError: |
|
|
|
log.debug('No search results found.') |
|
|
|
|
|
|
|