Commit 578d535f authored by prx's avatar prx

support btdb

parent b362c56c
......@@ -87,7 +87,7 @@ def search2html(keywords, extrawords=' ', searchengine='kickasstorrents', page=0
html += '</tr>'
html += '</tbody>'
html += '</table>'
if searchengine == 'alphareign':
if searchengine in [ 'alphareign', 'btdb' ]:
html += '<a href="/moreresults/{}/{}/{}/{}/{}">{}</a>'.format(
keywords, int(page) + 1, searchengine, extrawords, isserie, _('More results'))
else: # If there is no result
......@@ -288,7 +288,7 @@ def watchlist(user):
def create_select_search_engine(selected):
#list_search_engines = ["btdigg", "kickasstorrents", "piratebay", "torrentproject", tpl_msg['tpl_all']]
list_search_engines = ["alphareign", "kickasstorrents", "piratebay", "isohunt", "torrent9", tpl_msg['tpl_all']]
list_search_engines = ["alphareign", "btdb", "kickasstorrents", "piratebay", "isohunt", "torrent9", tpl_msg['tpl_all']]
list_html = str()
for search_engine in list_search_engines:
......
......@@ -290,7 +290,7 @@ class TorrentSearch:
def _search_all(self, sch):
s = []
searchengine_list = [self._piratebay, self._kickasstorrents, self._isohunt, self._torrent9, self._alphareign]
searchengine_list = [self._piratebay, self._kickasstorrents, self._isohunt, self._torrent9, self._alphareign, self._btdb]
if sys.version_info >= (3, 0):
with ThreadPoolExecutor(max_workers=5) as e:
for searchengine in searchengine_list:
......@@ -303,6 +303,7 @@ class TorrentSearch:
s += [res for res in self._isohunt(sch)]
s += [res for res in self._torrent9(sch)]
s += [res for res in self._alphareign(sch)]
s += [res for res in self._btdb(sch)]
return s
......@@ -617,7 +618,7 @@ class TorrentSearch:
seed : number of seeds
"""
url = 'https://alphareign.se/'
keys = {'query': sch, 'page':page}
keys = {'query': sch}
s = do_req_get(url, "text", keys)
soup = bs4.BeautifulSoup(s, "html.parser")
......@@ -628,6 +629,7 @@ class TorrentSearch:
leechs = str()
res = {}
results = soup.find('div', id='results')
for r in soup.find_all("div", class_="result"):
name = r['data-name']
size = r['data-size']
......@@ -652,7 +654,6 @@ class TorrentSearch:
yield res
def _btdb(self, sch, page=0):
"""
Return:
......@@ -662,7 +663,7 @@ class TorrentSearch:
size : size
seed : number of seeds
"""
baseurl = 'https://btdb.in/q'
baseurl = 'https://btdb.in'
url = '{}/q/{}/{}'.format(baseurl, sch, page)
s = do_req_get(url, "text")
soup = bs4.BeautifulSoup(s, "html.parser")
......@@ -674,30 +675,32 @@ class TorrentSearch:
leechs = str()
res = {}
<div class="item-meta-info">
for r in soup.find_all("div", class_="result"):
name = r['data-name']
size = r['data-size']
seeds = r['data-seeders']
leechs = r['data-leechers']
link = r.find('a', alt='download torrent')
magnet = link['href']
for i in soup.find_all('h2', class_='item-title'):
name = i.a['title']
if name and magnet and size and seeds and leechs :
for r in soup.find_all('div', class_='item-meta-info'):
size = r.find('span', class_='item-meta-info-value').string
magnet = r.find('a', class_='magnet')['href']
if sys.version_info < (3, 0):
magnet = magnet.encode('utf-8')
name = name.encode('utf-8')
size = size.encode('utf-8')
"""
size = r['data-size']
seeds = r['data-seeders']
leechs = r['data-leechers']
"""
res = {'name': name, 'magnet': magnet, 'size': size, 'seeds': seeds, "leechs": leechs}
name = str()
magnet = str()
size = str()
seeds = str()
leechs = str()
if name and magnet and size :
yield res
if sys.version_info < (3, 0):
magnet = magnet.encode('utf-8')
name = name.encode('utf-8')
size = size.encode('utf-8')
res = {'name': name, 'magnet': magnet, 'size': size, 'seeds': seeds, "leechs": leechs}
name = str()
magnet = str()
size = str()
yield res
......@@ -739,7 +742,7 @@ def isohunt_parse_results(z):
if __name__ == '__main__':
with TorrentSearch('alphareign') as ts:
s = ts.search('vikings', 0)
s = ts.search('vikings vostfr', 0)
print(s)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment