Commit a6a9cf9b authored by thuban's avatar thuban

various bugfixes. pages works now

parent f4d8b203
......@@ -68,19 +68,20 @@ def search2html(keywords, extrawords=' ', searchengine='alphareign', page=0, iss
html += '<td class="text-center"><a href="{}">{}</a></td>\n'.format(link, result['leechs'])
seeds = int(result['seeds'])
# color depending on seeds number
color = 'white'
if seeds <= 10:
color = 'red'
elif 40 >= seeds > 10:
color = 'orange'
elif 70 >= seeds > 40:
color = 'yellow'
elif 100 >= seeds > 70:
color = 'blue'
elif seeds > 100:
color = 'green'
if result['seeds'] != '?':
seeds = int(result['seeds'])
if seeds <= 10:
color = 'red'
elif 40 >= seeds > 10:
color = 'orange'
elif 70 >= seeds > 40:
color = 'yellow'
elif 100 >= seeds > 70:
color = 'blue'
elif seeds > 100:
color = 'green'
html += '<td class="text-center" style="background:{};"><a href="{}">{}</a></td>'.format(
color, link, result['seeds'])
......
......@@ -621,9 +621,9 @@ class TorrentSearch:
size : size
seed : number of seeds
"""
page += 1
page = int(page) + 1
url = 'https://alphareign.se/'
keys = {'query': sch}
keys = {'query': sch, 'page': page}
s = do_req_get(url, "text", keys)
soup = bs4.BeautifulSoup(s, "html.parser")
......@@ -637,7 +637,7 @@ class TorrentSearch:
results = soup.find('div', id='results')
for r in soup.find_all("div", class_="result"):
name = r['data-name']
size = r['data-size']
size = convb(int(r['data-size']))
seeds = r['data-seeders']
leechs = r['data-leechers']
link = r.find('a', alt='download torrent')
......@@ -668,7 +668,7 @@ class TorrentSearch:
size : size
seed : number of seeds
"""
page += 1
page = int(page) + 1
baseurl = 'https://btdb.in'
url = '{}/q/{}/{}'.format(baseurl, sch, page)
s = do_req_get(url, "text")
......@@ -677,8 +677,8 @@ class TorrentSearch:
name = str()
magnet = str()
size = str()
seeds = str()
leechs = str()
seeds = "?"
leechs = "?"
res = {}
for i in soup.find_all('h2', class_='item-title'):
......@@ -718,7 +718,7 @@ class TorrentSearch:
size : size
seed : number of seeds
"""
page += 1
page = int(page) + 1
baseurl = 'https://www.digbt.org'
url = '{}/search/{}-time-{}'.format(baseurl, sch, page)
s = do_req_get(url, "text")
......@@ -727,8 +727,8 @@ class TorrentSearch:
name = str()
magnet = str()
size = str()
seeds = str()
leechs = str()
seeds = '?'
leechs = '?'
res = {}
for r in soup.find_all('td', class_='x-item'):
......@@ -796,9 +796,10 @@ def isohunt_parse_results(z):
if __name__ == '__main__':
with TorrentSearch('alphareign') as ts:
s = ts.search('vikings vostfr', 0)
with TorrentSearch('btdb') as ts:
s = ts.search('vikings', 0)
print(s)
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
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