on master help sign in
Hopefully fix code style errors
fb364ffrinpatch
searx/engines/acgsou.py+3−14
@@ -28,14 +28,11 @@ xpath_title = './/td[3]/a[last()]'
28xpath_torrent_links = './/td[3]/a'
28xpath_torrent_links = './/td[3]/a'
29xpath_filesize = './/td[4]/text()'
29xpath_filesize = './/td[4]/text()'
30
30
31−# do search-request
32def request(query, params):
31def request(query, params):
33 query = urlencode({'keyword': query})
32 query = urlencode({'keyword': query})
34 params['url'] = search_url.format(query=query, offset=params['pageno'])
33 params['url'] = search_url.format(query=query, offset=params['pageno'])
35 return params
34 return params
36
35
37−
38−# get response from search-request
39def response(resp):
36def response(resp):
40 results = []
37 results = []
41 dom = html.fromstring(resp.text)
38 dom = html.fromstring(resp.text)
@@ -46,23 +43,17 @@ def response(resp):
46 magnet_link = "magnet:?xt=urn:btih:{}&tr=http://tracker.acgsou.com:2710/announce"
43 magnet_link = "magnet:?xt=urn:btih:{}&tr=http://tracker.acgsou.com:2710/announce"
47 torrent_link = ""
44 torrent_link = ""
48
45
49− # category in which our torrent belongs
50 try:
46 try:
51 category = extract_text(result.xpath(xpath_category)[0])
47 category = extract_text(result.xpath(xpath_category)[0])
52 except:
48 except:
53 pass
49 pass
54
50
55− # torrent title
56 page_a = result.xpath(xpath_title)[0]
51 page_a = result.xpath(xpath_title)[0]
57 title = extract_text(page_a)
52 title = extract_text(page_a)
58−
59− # link to the page
60 href = base_url + page_a.attrib.get('href')
53 href = base_url + page_a.attrib.get('href')
61−
54+
62− #magnet link
63 magnet_link = magnet_link.format(page_a.attrib.get('href')[5:-5])
55 magnet_link = magnet_link.format(page_a.attrib.get('href')[5:-5])
64
56
65− # let's try to calculate the torrent size
66 try:
57 try:
67 filesize_info = result.xpath(xpath_filesize)[0]
58 filesize_info = result.xpath(xpath_filesize)[0]
68 filesize = filesize_info[:-2]
59 filesize = filesize_info[:-2]
@@ -70,16 +61,14 @@ def response(resp):
70 filesize = get_torrent_size(filesize, filesize_multiplier)
61 filesize = get_torrent_size(filesize, filesize_multiplier)
71 except :
62 except :
72 pass
63 pass
73−
64+ #I didn't add download/seed/leech count since as I figured out they are generated randowmly everytime
74− # content string contains all information not included into template
75 content = 'Category: "{category}".'
65 content = 'Category: "{category}".'
76 content = content.format(category=category)
66 content = content.format(category=category)
77−
67+
78 results.append({'url': href,
68 results.append({'url': href,
79 'title': title,
69 'title': title,
80 'content': content,
70 'content': content,
81 'filesize': filesize,
71 'filesize': filesize,
82 'magnetlink': magnet_link,
72 'magnetlink': magnet_link,
83 'template': 'torrent.html'})
73 'template': 'torrent.html'})
84−
85 return results
74 return results