@@ -0,0 +1,85 @@
2+ Acgsou (Japanese Animation/Music/Comics Bittorrent tracker)
4+ @website https://www.acgsou.com/
8+ @stable no (HTML can change)
9+ @parse url, title, content, seed, leech, torrentfile
13+from searx.engines.xpath import extract_text
14+from searx.url_utils import urlencode
15+from searx.utils import get_torrent_size, int_or_zero
17+# engine dependent config
18+categories = ['files', 'images', 'videos', 'music']
22+base_url = 'https://www.acgsou.com/'
23+search_url = base_url + 'search.php?{query}&page={offset}'
25+xpath_results = '//table[contains(@class, "list_style table_fixed")]//tr[not(th)]'
26+xpath_category = './/td[2]/a[1]'
27+xpath_title = './/td[3]/a[last()]'
28+xpath_torrent_links = './/td[3]/a'
29+xpath_filesize = './/td[4]/text()'
32+def request(query, params):
33+ query = urlencode({'keyword': query})
34+ params['url'] = search_url.format(query=query, offset=params['pageno'])
38+# get response from search-request
41+ dom = html.fromstring(resp.text)
43+ for result in dom.xpath(xpath_results):
46+ magnet_link = "magnet:?xt=urn:btih:{}&tr=http://tracker.acgsou.com:2710/announce"
49+ # category in which our torrent belongs
51+ category = extract_text(result.xpath(xpath_category)[0])
56+ page_a = result.xpath(xpath_title)[0]
57+ title = extract_text(page_a)
60+ href = base_url + page_a.attrib.get('href')
63+ magnet_link = magnet_link.format(page_a.attrib.get('href')[5:-5])
65+ # let's try to calculate the torrent size
67+ filesize_info = result.xpath(xpath_filesize)[0]
68+ filesize = filesize_info[:-2]
69+ filesize_multiplier = filesize_info[-2:]
70+ filesize = get_torrent_size(filesize, filesize_multiplier)
74+ # content string contains all information not included into template
75+ content = 'Category: "{category}".'
76+ content = content.format(category=category)
78+ results.append({'url': href,
81+ 'filesize': filesize,
82+ 'magnetlink': magnet_link,
83+ 'template': 'torrent.html'})