diff options
author | Adam Tauber <asciimoo@gmail.com> | 2018-04-28 22:42:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-28 22:42:35 +0200 |
commit | 1a1f9852f11429d3f8f47d5c0c8ef5176f202c27 (patch) | |
tree | 2e4f1357f1501b6f70067e92a70afb2b48126a0b /searx | |
parent | 819f022074edbd249a85bcdde100949bc4195777 (diff) | |
parent | a79c676f2766c00122695fe74ad42ff89cfdcd07 (diff) | |
download | searxng-1a1f9852f11429d3f8f47d5c0c8ef5176f202c27.tar.gz searxng-1a1f9852f11429d3f8f47d5c0c8ef5176f202c27.zip |
Merge pull request #1283 from rinpatch/acgsou-engine
[Feature] Acgsou as a searchable engine
Diffstat (limited to 'searx')
-rw-r--r-- | searx/engines/acgsou.py | 75 | ||||
-rw-r--r-- | searx/settings.yml | 6 |
2 files changed, 81 insertions, 0 deletions
diff --git a/searx/engines/acgsou.py b/searx/engines/acgsou.py new file mode 100644 index 000000000..9cedeeecf --- /dev/null +++ b/searx/engines/acgsou.py @@ -0,0 +1,75 @@ +""" + 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 +""" + +from lxml import html +from searx.engines.xpath import extract_text +from searx.url_utils import urlencode +from searx.utils import get_torrent_size, int_or_zero + +# engine dependent config +categories = ['files', 'images', 'videos', 'music'] +paging = True + +# search-url +base_url = 'https://www.acgsou.com/' +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()' + + +def request(query, params): + query = urlencode({'keyword': query}) + params['url'] = search_url.format(query=query, offset=params['pageno']) + return params + + +def response(resp): + results = [] + dom = html.fromstring(resp.text) + for result in dom.xpath(xpath_results): + # 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') + + 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) + except: + pass + # I didn't add download/seed/leech count since as I figured out they are generated randomly everytime + content = 'Category: "{category}".' + content = content.format(category=category) + + results.append({'url': href, + 'title': title, + 'content': content, + 'filesize': filesize, + 'magnetlink': magnet_link, + 'template': 'torrent.html'}) + return results diff --git a/searx/settings.yml b/searx/settings.yml index d72d01a54..988076f8a 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -433,6 +433,12 @@ engines: engine : nyaa shortcut : nt disabled : True + + - name : acgsou + engine : acgsou + shortcut : acg + disabled : True + timeout: 5.0 - name : openairedatasets engine : json_engine |