Allow IPTorrents provider to read results across multiple pages
Conflicts: couchpotato/core/providers/torrent/iptorrents/main.py
This commit is contained in:
1 parent
609805b84d
commit
a5b1c685e1
1 file changed
+16
-3
@@ -5,7 +5,6 @@ from couchpotato.core.logger import CPLog
|
|||||||
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__)
|
||||||
|
|
||||||
|
|
||||||
@@ -15,8 +14,8 @@ class IPTorrents(TorrentProvider):
|
|||||||
'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/',
|
||||||
'search' : 'http://www.iptorrents.com/torrents/?l%d=1%s&q=%s&qf=ti',
|
|
||||||
'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',
|
||||||
}
|
}
|
||||||
|
|
||||||
cat_ids = [
|
cat_ids = [
|
||||||
@@ -33,13 +32,24 @@ class IPTorrents(TorrentProvider):
|
|||||||
|
|
||||||
freeleech = '' if not self.conf('freeleech') else '&free=on'
|
freeleech = '' if not self.conf('freeleech') else '&free=on'
|
||||||
|
|
||||||
url = self.urls['search'] % (self.getCatId(quality['identifier'])[0], freeleech, tryUrlencode('%s %s' % (title.replace(':', ''), movie['library']['year'])))
|
pages = 1
|
||||||
|
current_page = 1
|
||||||
|
while current_page <= pages and not self.shuttingDown():
|
||||||
|
|
||||||
|
url = self.urls['search'] % (self.getCatId(quality['identifier'])[0], freeleech, tryUrlencode('%s %s' % (title.replace(':', ''), movie['library']['year'])), current_page)
|
||||||
data = self.getHTMLData(url, opener = self.login_opener)
|
data = self.getHTMLData(url, opener = self.login_opener)
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
html = BeautifulSoup(data)
|
html = BeautifulSoup(data)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
page_nav = html.find('span', attrs = {'class' : 'page_nav'})
|
||||||
|
if page_nav:
|
||||||
|
next_link = page_nav.find("a", text = "Next")
|
||||||
|
if next_link:
|
||||||
|
final_page_link = next_link.previous_sibling.previous_sibling
|
||||||
|
pages = int(final_page_link.string)
|
||||||
|
|
||||||
result_table = html.find('table', attrs = {'class' : 'torrents'})
|
result_table = html.find('table', attrs = {'class' : 'torrents'})
|
||||||
|
|
||||||
if not result_table or 'nothing found!' in data.lower():
|
if not result_table or 'nothing found!' in data.lower():
|
||||||
@@ -72,6 +82,9 @@ class IPTorrents(TorrentProvider):
|
|||||||
|
|
||||||
except:
|
except:
|
||||||
log.error('Failed to parsing %s: %s', (self.getName(), traceback.format_exc()))
|
log.error('Failed to parsing %s: %s', (self.getName(), traceback.format_exc()))
|
||||||
|
break
|
||||||
|
|
||||||
|
current_page += 1
|
||||||
|
|
||||||
def getLoginParams(self):
|
def getLoginParams(self):
|
||||||
return tryUrlencode({
|
return tryUrlencode({
|
||||||
|
|||||||
Reference in new issue
Block a user