mirror of
https://github.com/correl/Transmission-XBMC.git
synced 2024-11-24 11:09:58 +00:00
Add proxy fail-over to Pirate Bay search
This commit is contained in:
parent
6d6d8d88b4
commit
092f53d26a
4 changed files with 15 additions and 7 deletions
|
@ -21,7 +21,7 @@
|
|||
|
||||
<!-- Adding / Search -->
|
||||
<string id="200">Browse for torrent file</string>
|
||||
<string id="202">Search ThePirateBay.org</string>
|
||||
<string id="202">Search ThePirateBay</string>
|
||||
<string id="203">Search Mininova.org</string>
|
||||
<string id="204">Search KickassTorrents</string>
|
||||
<string id="290">Searching...</string>
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
<!-- Adding / Search -->
|
||||
<string id="200">Выбрать торрент-файл</string>
|
||||
<string id="202">Искать на ThePirateBay.org</string>
|
||||
<string id="202">Искать на ThePirateBay</string>
|
||||
<string id="203">Искать на Mininova.org</string>
|
||||
<string id="204">Искать на KickassTorrents</string>
|
||||
<string id="290">Поиск...</string>
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
<!-- Adding / Search -->
|
||||
<string id="200">Buscar un archivo torrent</string>
|
||||
<string id="202">Buscar en ThePirateBay.org</string>
|
||||
<string id="202">Buscar en ThePirateBay</string>
|
||||
<string id="203">Buscar en Mininova.org</string>
|
||||
<string id="204">Buscar en KickassTorrents</string>
|
||||
<string id="290">Buscando...</string>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import re
|
||||
import socket
|
||||
from urllib2 import urlopen
|
||||
from urllib2 import urlopen, URLError
|
||||
from BeautifulSoup import BeautifulSoup, BeautifulStoneSoup
|
||||
|
||||
socket.setdefaulttimeout(15)
|
||||
|
@ -30,11 +30,19 @@ class Mininova(Search):
|
|||
return torrents
|
||||
class TPB(Search):
|
||||
def __init__(self):
|
||||
self.search_uri = 'http://thepiratebay.se/search/%s/'
|
||||
self.search_uris = ['http://thepiratebay.se/search/%s/',
|
||||
'http://pirateproxy.net/search/%s/']
|
||||
def search(self, terms):
|
||||
torrents = []
|
||||
url = self.search_uri % '+'.join(terms.split(' '))
|
||||
f = urlopen(url)
|
||||
f = None
|
||||
for url in [u % '+'.join(terms.split(' ')) for u in self.search_uris]:
|
||||
try:
|
||||
f = urlopen(url)
|
||||
break
|
||||
except URLError:
|
||||
continue
|
||||
if not f:
|
||||
raise Exception('Out of pirate bay proxies')
|
||||
soup = BeautifulSoup(f.read())
|
||||
for details in soup.findAll('a', {'class': 'detLink'}):
|
||||
name = details.text
|
||||
|
|
Loading…
Reference in a new issue