2018-04-26 19:42:31 +00:00
|
|
|
"""
|
|
|
|
Acgsou (Japanese Animation/Music/Comics Bittorrent tracker)
|
|
|
|
|
|
|
|
@website https://www.acgsou.com/
|
|
|
|
@provide-api no
|
|
|
|
@using-api no
|
|
|
|
@results HTML
|
|
|
|
@stable no (HTML can change)
|
|
|
|
@parse url, title, content, seed, leech, torrentfile
|
|
|
|
"""
|
|
|
|
|
2020-08-06 15:42:46 +00:00
|
|
|
from urllib.parse import urlencode
|
2018-04-26 19:42:31 +00:00
|
|
|
from lxml import html
|
2020-10-02 16:13:56 +00:00
|
|
|
from searx.utils import extract_text, get_torrent_size, int_or_zero
|
2018-04-26 19:42:31 +00:00
|
|
|
|
|
|
|
# engine dependent config
|
|
|
|
categories = ['files', 'images', 'videos', 'music']
|
|
|
|
paging = True
|
|
|
|
|
|
|
|
# search-url
|
2018-05-03 05:34:21 +00:00
|
|
|
base_url = 'http://www.acgsou.com/'
|
2018-04-26 19:42:31 +00:00
|
|
|
search_url = base_url + 'search.php?{query}&page={offset}'
|
|
|
|
# xpath queries
|
|
|
|
xpath_results = '//table[contains(@class, "list_style table_fixed")]//tr[not(th)]'
|
|
|
|
xpath_category = './/td[2]/a[1]'
|
|
|
|
xpath_title = './/td[3]/a[last()]'
|
|
|
|
xpath_torrent_links = './/td[3]/a'
|
|
|
|
xpath_filesize = './/td[4]/text()'
|
|
|
|
|
2018-04-27 05:29:17 +00:00
|
|
|
|
2018-04-26 19:42:31 +00:00
|
|
|
def request(query, params):
|
|
|
|
query = urlencode({'keyword': query})
|
|
|
|
params['url'] = search_url.format(query=query, offset=params['pageno'])
|
|
|
|
return params
|
|
|
|
|
2018-04-27 05:29:17 +00:00
|
|
|
|
2018-04-26 19:42:31 +00:00
|
|
|
def response(resp):
|
2018-04-27 05:36:11 +00:00
|
|
|
results = []
|
2018-04-26 19:42:31 +00:00
|
|
|
dom = html.fromstring(resp.text)
|
2018-04-27 05:29:17 +00:00
|
|
|
for result in dom.xpath(xpath_results):
|
2018-04-26 19:42:31 +00:00
|
|
|
# defaults
|
|
|
|
filesize = 0
|
|
|
|
magnet_link = "magnet:?xt=urn:btih:{}&tr=http://tracker.acgsou.com:2710/announce"
|
|
|
|
torrent_link = ""
|
|
|
|
|
|
|
|
try:
|
|
|
|
category = extract_text(result.xpath(xpath_category)[0])
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
|
|
|
page_a = result.xpath(xpath_title)[0]
|
|
|
|
title = extract_text(page_a)
|
|
|
|
href = base_url + page_a.attrib.get('href')
|
2018-04-27 05:23:58 +00:00
|
|
|
|
2018-04-26 19:42:31 +00:00
|
|
|
magnet_link = magnet_link.format(page_a.attrib.get('href')[5:-5])
|
|
|
|
|
|
|
|
try:
|
|
|
|
filesize_info = result.xpath(xpath_filesize)[0]
|
|
|
|
filesize = filesize_info[:-2]
|
|
|
|
filesize_multiplier = filesize_info[-2:]
|
|
|
|
filesize = get_torrent_size(filesize, filesize_multiplier)
|
2018-04-27 05:29:17 +00:00
|
|
|
except:
|
2018-04-26 19:42:31 +00:00
|
|
|
pass
|
2018-04-27 12:36:15 +00:00
|
|
|
# I didn't add download/seed/leech count since as I figured out they are generated randomly everytime
|
2020-08-06 15:42:46 +00:00
|
|
|
content = 'Category: "{category}".'
|
2018-04-26 19:42:31 +00:00
|
|
|
content = content.format(category=category)
|
2018-04-27 05:29:17 +00:00
|
|
|
|
2018-04-26 19:42:31 +00:00
|
|
|
results.append({'url': href,
|
|
|
|
'title': title,
|
|
|
|
'content': content,
|
|
|
|
'filesize': filesize,
|
|
|
|
'magnetlink': magnet_link,
|
|
|
|
'template': 'torrent.html'})
|
|
|
|
return results
|