Browse Source

Hopefully fix code style errors

rinpatch 6 years ago
parent
commit
fb364ffae7
No account linked to committer's email
1 changed files with 3 additions and 14 deletions
  1. 3
    14
      searx/engines/acgsou.py

+ 3
- 14
searx/engines/acgsou.py View File

28
 xpath_torrent_links = './/td[3]/a'
28
 xpath_torrent_links = './/td[3]/a'
29
 xpath_filesize = './/td[4]/text()'
29
 xpath_filesize = './/td[4]/text()'
30
 
30
 
31
-# do search-request
32
 def request(query, params):
31
 def 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
39
 def response(resp):
36
 def response(resp):
40
     results = [] 
37
     results = [] 
41
     dom = html.fromstring(resp.text)
38
     dom = html.fromstring(resp.text)
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
-        
62
-        #magnet link
54
+
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
             filesize = get_torrent_size(filesize, filesize_multiplier)
61
             filesize = get_torrent_size(filesize, filesize_multiplier)
71
         except :
62
         except :
72
             pass
63
             pass
73
-
74
-        # content string contains all information not included into template
64
+        #I didn't add download/seed/leech count since as I figured out they are generated randowmly everytime
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