Commit 0dbf6822 authored by Thuban's avatar Thuban

add digbt engine

parent 578d535f
......@@ -87,7 +87,7 @@ def search2html(keywords, extrawords=' ', searchengine='kickasstorrents', page=0
html += '</tr>'
html += '</tbody>'
html += '</table>'
if searchengine in [ 'alphareign', 'btdb' ]:
if searchengine in [ 'alphareign', 'btdb', 'digbt' ]:
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", "btdb", "kickasstorrents", "piratebay", "isohunt", "torrent9", tpl_msg['tpl_all']]
list_search_engines = ["alphareign", "btdb", "digbt", "kickasstorrents", "piratebay", "isohunt", "torrent9", tpl_msg['tpl_all']]
list_html = str()
for search_engine in list_search_engines:
......
......@@ -275,9 +275,11 @@ class TorrentSearch:
elif self.searchengine == 'torrent9':
s = [res for res in self._torrent9(sch)]
elif self.searchengine == 'alphareign':
s = [res for res in self._alphareign(sch)]
s = [res for res in self._alphareign(sch, page)]
elif self.searchengine == 'btdb':
s = [res for res in self._btdb(sch)]
s = [res for res in self._btdb(sch, page)]
elif self.searchengine == 'digbt':
s = [res for res in self._digbt(sch, page)]
elif self.searchengine == '*':
s = self._search_all(sch)
else:
......@@ -290,7 +292,7 @@ class TorrentSearch:
def _search_all(self, sch):
s = []
searchengine_list = [self._piratebay, self._kickasstorrents, self._isohunt, self._torrent9, self._alphareign, self._btdb]
searchengine_list = [self._piratebay, self._kickasstorrents, self._isohunt, self._torrent9, self._alphareign, self._btdb, self._digbt]
if sys.version_info >= (3, 0):
with ThreadPoolExecutor(max_workers=5) as e:
for searchengine in searchengine_list:
......@@ -304,6 +306,7 @@ class TorrentSearch:
s += [res for res in self._torrent9(sch)]
s += [res for res in self._alphareign(sch)]
s += [res for res in self._btdb(sch)]
s += [res for res in self._digbt(sch)]
return s
......@@ -617,6 +620,7 @@ class TorrentSearch:
size : size
seed : number of seeds
"""
page += 1
url = 'https://alphareign.se/'
keys = {'query': sch}
s = do_req_get(url, "text", keys)
......@@ -663,6 +667,7 @@ class TorrentSearch:
size : size
seed : number of seeds
"""
page += 1
baseurl = 'https://btdb.in'
url = '{}/q/{}/{}'.format(baseurl, sch, page)
s = do_req_get(url, "text")
......@@ -703,6 +708,55 @@ class TorrentSearch:
yield res
def _digbt(self, sch, page=0):
"""
Return:
List of dictionnaries with keys :
name : torrent name
magnet : magnet link
size : size
seed : number of seeds
"""
page += 1
baseurl = 'https://www.digbt.org'
url = '{}/search/{}-time-{}'.format(baseurl, sch, page)
s = do_req_get(url, "text")
soup = bs4.BeautifulSoup(s, "html.parser")
name = str()
magnet = str()
size = str()
seeds = str()
leechs = str()
res = {}
for r in soup.find_all('td', class_='x-item'):
for a in r.find_all('a', class_='title'):
if a['href'].startswith('magnet:?'):
magnet = a['href']
else:
name = a.string
d = r.find('div', class_='tail').text
d = d.strip().split(' ') # ugly, FIXME
size = d[3]
if name and magnet and size :
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
......
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