mirror of
https://github.com/correl/Transmission-XBMC.git
synced 2024-11-25 03:00:15 +00:00
2313c3981f
added a search in a PirateBay proxy, because the original site is blocked by many ISPs, the postfix /0/7/0 in url gives sorting by number of seeds could you verify if it works? and add it to official release that's the only thing my openelec misses
95 lines
3.2 KiB
Python
95 lines
3.2 KiB
Python
import re
|
|
import socket
|
|
from urllib2 import urlopen
|
|
from BeautifulSoup import BeautifulSoup, BeautifulStoneSoup
|
|
|
|
socket.setdefaulttimeout(15)
|
|
|
|
class Search:
|
|
def __init__(self):
|
|
return NotImplemented
|
|
def search(terms):
|
|
return NotImplemented
|
|
|
|
class Mininova(Search):
|
|
def __init__(self):
|
|
self.search_uri = 'http://www.mininova.org/rss/%s'
|
|
def search(self, terms):
|
|
torrents = []
|
|
url = self.search_uri % '+'.join(terms.split(' '))
|
|
f = urlopen(url)
|
|
soup = BeautifulStoneSoup(f.read())
|
|
for item in soup.findAll('item'):
|
|
(seeds, leechers) = re.findall('Ratio: (\d+) seeds, (\d+) leechers', item.description.text)[0]
|
|
torrents.append({
|
|
'url': item.enclosure['url'],
|
|
'name': item.title.text,
|
|
'seeds': int(seeds),
|
|
'leechers': int(leechers),
|
|
})
|
|
return torrents
|
|
class TPB(Search):
|
|
def __init__(self):
|
|
self.search_uri = 'http://thepiratebay.se/search/%s/'
|
|
def search(self, terms):
|
|
torrents = []
|
|
url = self.search_uri % '+'.join(terms.split(' '))
|
|
f = urlopen(url)
|
|
soup = BeautifulSoup(f.read())
|
|
for details in soup.findAll('a', {'class': 'detLink'}):
|
|
name = details.text
|
|
url = details.findNext('a', {'href': re.compile('^magnet:')})['href']
|
|
td = details.findNext('td')
|
|
seeds = int(td.text)
|
|
td = td.findNext('td')
|
|
leechers = int(td.text)
|
|
torrents.append({
|
|
'url': url,
|
|
'name': name,
|
|
'seeds': seeds,
|
|
'leechers': leechers,
|
|
})
|
|
return torrents
|
|
class TPBproxy(Search):
|
|
def __init__(self):
|
|
self.search_uri = 'http://pirateproxy.net/search/%s/0/7/0'
|
|
def search(self, terms):
|
|
torrents = []
|
|
url = self.search_uri % '+'.join(terms.split(' '))
|
|
f = urlopen(url)
|
|
soup = BeautifulSoup(f.read())
|
|
for details in soup.findAll('a', {'class': 'detLink'}):
|
|
name = details.text
|
|
url = details.findNext('a', {'href': re.compile('^magnet:')})['href']
|
|
td = details.findNext('td')
|
|
seeds = int(td.text)
|
|
td = td.findNext('td')
|
|
leechers = int(td.text)
|
|
torrents.append({
|
|
'url': url,
|
|
'name': name,
|
|
'seeds': seeds,
|
|
'leechers': leechers,
|
|
})
|
|
return torrents
|
|
class TorrentReactor(Search):
|
|
def __init__(self):
|
|
self.search_uri = 'http://www.torrentreactor.net/rss.php?search=%s'
|
|
def search(self, terms):
|
|
torrents = []
|
|
url = self.search_uri % '+'.join(terms.split(' '))
|
|
f = urlopen(url)
|
|
soup = BeautifulStoneSoup(f.read())
|
|
for item in soup.findAll('item'):
|
|
(seeds, leechers) = re.findall('Status: (\d+) seeders, (\d+) leecher', item.description.text)[0]
|
|
torrents.append({
|
|
'url': item.enclosure['url'],
|
|
'name': item.title.text,
|
|
'seeds': int(seeds),
|
|
'leechers': int(leechers),
|
|
})
|
|
return torrents
|
|
|
|
if __name__ == '__main__':
|
|
s = TPB()
|
|
results = s.search('zettai')
|