ILoveTorrents cleanup
This commit is contained in:
@@ -16,7 +16,7 @@ config = [{
|
|||||||
{
|
{
|
||||||
'name': 'enabled',
|
'name': 'enabled',
|
||||||
'type': 'enabler',
|
'type': 'enabler',
|
||||||
'default': True
|
'default': False
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'name': 'username',
|
'name': 'username',
|
||||||
|
|||||||
@@ -1,41 +1,34 @@
|
|||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from couchpotato.core.helpers.encoding import toUnicode, tryUrlencode
|
from couchpotato.core.helpers.encoding import toUnicode, tryUrlencode
|
||||||
from couchpotato.core.helpers.variable import tryInt, cleanHost
|
from couchpotato.core.helpers.variable import tryInt
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.providers.torrent.base import TorrentMagnetProvider
|
from couchpotato.core.providers.torrent.base import TorrentProvider
|
||||||
from couchpotato.environment import Env
|
|
||||||
import re
|
import re
|
||||||
import time
|
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
|
|
||||||
|
|
||||||
class ILoveTorrents(TorrentMagnetProvider):
|
class ILoveTorrents(TorrentProvider):
|
||||||
|
|
||||||
urls = {
|
urls = {
|
||||||
'domain': 'www.ilovetorrents.me',
|
|
||||||
'download': 'http://www.ilovetorrents.me/%s',
|
'download': 'http://www.ilovetorrents.me/%s',
|
||||||
'detail': '%s/torrent/%s',
|
'detail': 'http://www.ilovetorrents.me/%s',
|
||||||
'search': '%s/browse.php?search=%s&page=%s&cat=%s',
|
'search': 'http://www.ilovetorrents.me/browse.php?search=%s&page=%s&cat=%s',
|
||||||
'test' : 'http://www.ilovetorrents.me/',
|
'test' : 'http://www.ilovetorrents.me/',
|
||||||
'login' : 'http://www.ilovetorrents.me/takelogin.php',
|
'login' : 'http://www.ilovetorrents.me/takelogin.php',
|
||||||
'login_check' : 'http://www.ilovetorrents.me'
|
'login_check' : 'http://www.ilovetorrents.me'
|
||||||
}
|
}
|
||||||
|
|
||||||
cat_ids = [
|
cat_ids = [
|
||||||
(["41"], ['720p', '1080p', 'brrip']),
|
(['41'], ['720p', '1080p', 'brrip']),
|
||||||
(["19"], ['cam', 'ts', 'dvdrip', 'tc', 'r5', 'scr']),
|
(['19'], ['cam', 'ts', 'dvdrip', 'tc', 'r5', 'scr']),
|
||||||
(["20"], ['dvdr'])
|
(['20'], ['dvdr'])
|
||||||
]
|
]
|
||||||
|
|
||||||
cat_backup_id = 200
|
cat_backup_id = 200
|
||||||
disable_provider = False
|
disable_provider = False
|
||||||
http_time_between_calls = 0
|
http_time_between_calls = 1
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.domain = self.urls['domain']
|
|
||||||
super(ILoveTorrents, self).__init__()
|
|
||||||
|
|
||||||
def _searchOnTitle(self, title, movie, quality, results):
|
def _searchOnTitle(self, title, movie, quality, results):
|
||||||
|
|
||||||
@@ -44,69 +37,60 @@ class ILoveTorrents(TorrentMagnetProvider):
|
|||||||
cats = self.getCatId(quality['identifier'])
|
cats = self.getCatId(quality['identifier'])
|
||||||
|
|
||||||
while page < total_pages:
|
while page < total_pages:
|
||||||
|
|
||||||
movieTitle = tryUrlencode('"%s" %s' % (title, movie['library']['year']))
|
movieTitle = tryUrlencode('"%s" %s' % (title, movie['library']['year']))
|
||||||
search_url = self.urls['search'] % (self.getDomain(), movieTitle, page, cats[0])
|
search_url = self.urls['search'] % (movieTitle, page, cats[0])
|
||||||
page += 1
|
page += 1
|
||||||
|
|
||||||
data = self.getHTMLData(search_url, opener = self.login_opener)
|
data = self.getHTMLData(search_url, opener = self.login_opener)
|
||||||
if data:
|
if data:
|
||||||
try:
|
try:
|
||||||
soup = BeautifulSoup(data, "html5lib")
|
soup = BeautifulSoup(data)
|
||||||
|
|
||||||
results_table = soup.find('table', attrs = {'class': 'koptekst'})
|
results_table = soup.find('table', attrs = {'class': 'koptekst'})
|
||||||
if not results_table:
|
if not results_table:
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
pagelinks = soup.findAll(href=re.compile("page"))
|
pagelinks = soup.findAll(href = re.compile('page'))
|
||||||
pageNumbers = [int(re.search('page=(?P<pageNumber>.+'')', i["href"]).group('pageNumber')) for i in pagelinks]
|
pageNumbers = [int(re.search('page=(?P<pageNumber>.+'')', i['href']).group('pageNumber')) for i in pagelinks]
|
||||||
total_pages = max(pageNumbers)
|
total_pages = max(pageNumbers)
|
||||||
|
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
entries = results_table.find_all('tr')
|
entries = results_table.find_all('tr')
|
||||||
|
|
||||||
for result in entries[1:]:
|
for result in entries[1:]:
|
||||||
prelink = result.find(href = re.compile('details.php'))
|
prelink = result.find(href = re.compile('details.php'))
|
||||||
contents = prelink.find('b').contents
|
|
||||||
name = str(contents[0])
|
|
||||||
link = prelink['href']
|
link = prelink['href']
|
||||||
download = result.find('a', href = re.compile('download.php'))['href']
|
download = result.find('a', href = re.compile('download.php'))['href']
|
||||||
|
|
||||||
try:
|
|
||||||
matches = re.search('>(?P<size>.+)<br/>(?P<unit>.B)', unicode(result.select('td.rowhead')[5]))
|
|
||||||
size = matches.group('size') + " " + matches.group('unit')
|
|
||||||
|
|
||||||
except:
|
|
||||||
continue
|
|
||||||
|
|
||||||
if link and download:
|
if link and download:
|
||||||
|
|
||||||
def extra_score(item):
|
def extra_score(item):
|
||||||
trusted = (0, 10)[result.find('img', alt = re.compile('Trusted')) is not None]
|
trusted = (0, 10)[result.find('img', alt = re.compile('Trusted')) is not None]
|
||||||
vip = (0, 20)[result.find('img', alt = re.compile('VIP')) is not None]
|
vip = (0, 20)[result.find('img', alt = re.compile('VIP')) is not None]
|
||||||
confirmed = (0, 30)[result.find('img', alt = re.compile('Helpers')) is not None]
|
confirmed = (0, 30)[result.find('img', alt = re.compile('Helpers')) is not None]
|
||||||
moderated = (0, 50)[result.find('img', alt = re.compile('Moderator')) is not None]
|
moderated = (0, 50)[result.find('img', alt = re.compile('Moderator')) is not None]
|
||||||
|
|
||||||
return confirmed + trusted + vip + moderated
|
return confirmed + trusted + vip + moderated
|
||||||
|
|
||||||
id = re.search('id=(?P<id>\d+)&', link).group('id')
|
id = re.search('id=(?P<id>\d+)&', link).group('id')
|
||||||
url = self.urls['download'] % (download)
|
url = self.urls['download'] % (download)
|
||||||
|
|
||||||
detail_url = self.getDomain("/"+link)
|
fileSize = self.parseSize(result.select('td.rowhead')[5].text)
|
||||||
fileSize = self.parseSize(size)
|
|
||||||
results.append({
|
results.append({
|
||||||
'id': id,
|
'id': id,
|
||||||
'name': name,
|
'name': toUnicode(prelink.find('b').text),
|
||||||
'url': url,
|
'url': url,
|
||||||
'detail_url': detail_url,
|
'detail_url': self.urls['detail'] % link,
|
||||||
'size': fileSize,
|
'size': fileSize,
|
||||||
'seeders': tryInt(result.find_all('td')[2].string),
|
'seeders': tryInt(result.find_all('td')[2].string),
|
||||||
'leechers': tryInt(result.find_all('td')[3].string),
|
'leechers': tryInt(result.find_all('td')[3].string),
|
||||||
'extra_score': extra_score,
|
'extra_score': extra_score,
|
||||||
'get_more_info': self.getMoreInfo
|
'get_more_info': self.getMoreInfo
|
||||||
})
|
})
|
||||||
log.info(results)
|
|
||||||
|
|
||||||
except:
|
except:
|
||||||
log.error('Failed getting results from %s: %s', (self.getName(), traceback.format_exc()))
|
log.error('Failed getting results from %s: %s', (self.getName(), traceback.format_exc()))
|
||||||
@@ -118,21 +102,15 @@ class ILoveTorrents(TorrentMagnetProvider):
|
|||||||
'submit': 'Welcome to ILT',
|
'submit': 'Welcome to ILT',
|
||||||
})
|
})
|
||||||
|
|
||||||
def isEnabled(self):
|
def getMoreInfo(self, item):
|
||||||
return super(ILoveTorrents, self).isEnabled() and self.getDomain()
|
|
||||||
|
|
||||||
def getDomain(self, url = ''):
|
|
||||||
return cleanHost(self.domain).rstrip('/') + url
|
|
||||||
|
|
||||||
def getMoreInfo(self, item):
|
|
||||||
cache_key = 'ilt.%s' % item['id']
|
cache_key = 'ilt.%s' % item['id']
|
||||||
description = self.getCache(cache_key)
|
description = self.getCache(cache_key)
|
||||||
|
|
||||||
if not description:
|
if not description:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
full_description = self.getHTMLData(item['detail_url'], opener = self.login_opener)
|
full_description = self.getHTMLData(item['detail_url'], opener = self.login_opener)
|
||||||
html = BeautifulSoup(full_description, "html5lib")
|
html = BeautifulSoup(full_description)
|
||||||
nfo_pre = html.find('td', attrs = {'class':'main'}).findAll('table')[1]
|
nfo_pre = html.find('td', attrs = {'class':'main'}).findAll('table')[1]
|
||||||
description = toUnicode(nfo_pre.text) if nfo_pre else ''
|
description = toUnicode(nfo_pre.text) if nfo_pre else ''
|
||||||
except:
|
except:
|
||||||
@@ -143,8 +121,8 @@ class ILoveTorrents(TorrentMagnetProvider):
|
|||||||
|
|
||||||
item['description'] = description
|
item['description'] = description
|
||||||
return item
|
return item
|
||||||
|
|
||||||
def loginSuccess(self, output):
|
|
||||||
return 'logout.php' in output.lower()
|
|
||||||
|
|
||||||
loginCheckSuccess = loginSuccess
|
def loginSuccess(self, output):
|
||||||
|
return 'logout.php' in output.lower()
|
||||||
|
|
||||||
|
loginCheckSuccess = loginSuccess
|
||||||
|
|||||||
Reference in New Issue
Block a user