Commit b0de61ec authored by prx's avatar prx

add alphareign engine

parent 785d040f
......@@ -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 = ["kickasstorrents", "piratebay", "isohunt", "torrent9", tpl_msg['tpl_all']]
list_search_engines = ["alphareign", "kickasstorrents", "piratebay", "isohunt", "torrent9", tpl_msg['tpl_all']]
list_html = str()
for search_engine in list_search_engines:
......
......@@ -274,6 +274,8 @@ class TorrentSearch:
s = [res for res in self._isohunt(sch)]
elif self.searchengine == 'torrent9':
s = [res for res in self._torrent9(sch)]
elif self.searchengine == 'alphareign':
s = [res for res in self._alphareign(sch)]
elif self.searchengine == '*':
s = self._search_all(sch)
else:
......@@ -540,6 +542,7 @@ class TorrentSearch:
for z in zip(row, seeds_results, size_results):
yield(isohunt_parse_results(z))
def _torrent9(self, sch, page=0):
"""
Return:
......@@ -601,6 +604,55 @@ 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}
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 isohunt_parse_results(z):
"""
parse isohunt results
......@@ -635,7 +687,7 @@ def isohunt_parse_results(z):
if __name__ == '__main__':
with TorrentSearch('torrentproject') as ts:
with TorrentSearch('alphareign') as ts:
s = ts.search('vikings', 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