Commit da0192c3 authored by Thuban's avatar Thuban

add page support for alphareign

parent b0de61ec
......@@ -87,7 +87,7 @@ def search2html(keywords, extrawords=' ', searchengine='kickasstorrents', page=0
html += '</tr>'
html += '</tbody>'
html += '</table>'
if searchengine == 'btdigg':
if searchengine == 'alphareign':
html += '<a href="/moreresults/{}/{}/{}/{}/{}">{}</a>'.format(
keywords, int(page) + 1, searchengine, extrawords, isserie, _('More results'))
else: # If there is no result
......
......@@ -276,10 +276,12 @@ class TorrentSearch:
s = [res for res in self._torrent9(sch)]
elif self.searchengine == 'alphareign':
s = [res for res in self._alphareign(sch)]
elif self.searchengine == 'btdb':
s = [res for res in self._btdb(sch)]
elif self.searchengine == '*':
s = self._search_all(sch)
else:
s = [res for res in self._piratebay(sch, 0)]
s = [res for res in self._alphareign(sch, 0)]
except Exception as e:
print(e)
s = []
......@@ -288,7 +290,7 @@ class TorrentSearch:
def _search_all(self, sch):
s = []
searchengine_list = [self._piratebay, self._kickasstorrents, self._isohunt, self._torrent9]
searchengine_list = [self._piratebay, self._kickasstorrents, self._isohunt, self._torrent9, self._alphareign]
if sys.version_info >= (3, 0):
with ThreadPoolExecutor(max_workers=5) as e:
for searchengine in searchengine_list:
......@@ -300,6 +302,7 @@ class TorrentSearch:
s += [res for res in self._kickasstorrents(sch)]
s += [res for res in self._isohunt(sch)]
s += [res for res in self._torrent9(sch)]
s += [res for res in self._alphareign(sch)]
return s
......@@ -605,6 +608,53 @@ class TorrentSearch:
yield res
def _alphareign(self, sch, page=0):
"""
Return:
List of dictionnaries with keys :
name : torrent name
magnet : magnet link
size : size
seed : number of seeds
"""
url = 'https://alphareign.se/'
keys = {'query': sch, 'page':page}
s = do_req_get(url, "text", keys)
soup = bs4.BeautifulSoup(s, "html.parser")
name = str()
magnet = str()
size = str()
seeds = str()
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']
seeds = r['data-seeders']
leechs = r['data-leechers']
link = r.find('a', alt='download torrent')
magnet = link['href']
if name and magnet and size and seeds and leechs :
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()
seeds = str()
leechs = str()
yield res
def _btdb(self, sch, page=0):
"""
Return:
List of dictionnaries with keys :
......@@ -653,6 +703,8 @@ class TorrentSearch:
def isohunt_parse_results(z):
"""
parse isohunt results
......
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