Explorar el Código

SubtitleSeeker Engine

Cqoicebordel hace 10 años
padre
commit
550232fc21
Se han modificado 2 ficheros con 63 adiciones y 0 borrados
  1. 59
    0
      searx/engines/subtitleseeker.py
  2. 4
    0
      searx/settings.yml

+ 59
- 0
searx/engines/subtitleseeker.py Ver fichero

@@ -0,0 +1,59 @@
1
+## Subtitleseeker (Video)
2
+#
3
+# @website     http://www.subtitleseeker.com
4
+# @provide-api no
5
+#
6
+# @using-api   no
7
+# @results     HTML
8
+# @stable      no (HTML can change)
9
+# @parse       url, title, content
10
+
11
+from cgi import escape
12
+from urllib import quote_plus
13
+from lxml import html
14
+
15
+# engine dependent config
16
+categories = ['videos']
17
+paging = True
18
+
19
+# search-url
20
+url = 'http://www.subtitleseeker.com/'
21
+search_url = url+'search/TITLES/{query}&p={pageno}'
22
+
23
+# specific xpath variables
24
+results_xpath = '//div[@class="boxRows"]'
25
+
26
+
27
+# do search-request
28
+def request(query, params):
29
+    params['url'] = search_url.format(query=quote_plus(query),
30
+                                      pageno=params['pageno'])
31
+    return params
32
+
33
+
34
+# get response from search-request
35
+def response(resp):
36
+    results = []
37
+
38
+    dom = html.fromstring(resp.text)
39
+
40
+    # parse results
41
+    for result in dom.xpath(results_xpath):
42
+        link = result.xpath(".//a")[0]
43
+        href = link.attrib.get('href')
44
+        title = escape(link.xpath(".//text()")[0])
45
+
46
+        content = result.xpath('.//div[contains(@class,"red")]//text()')[0]
47
+        content = content + " - "
48
+        content = content + html.tostring(result.xpath('.//div[contains(@class,"grey-web")]')[0], method='text')
49
+
50
+        if result.xpath(".//span") != []:
51
+            content = content + " - (" + result.xpath(".//span//text()")[0].strip() + ")"
52
+
53
+        # append result
54
+        results.append({'url': href,
55
+                        'title': title,
56
+                        'content': escape(content)})
57
+
58
+    # return results
59
+    return results

+ 4
- 0
searx/settings.yml Ver fichero

@@ -127,6 +127,10 @@ engines:
127 127
     engine : searchcode_code
128 128
     shortcut : scc
129 129
 
130
+  - name : subtitleseeker
131
+    engine : subtitleseeker
132
+    shortcut : ss
133
+
130 134
   - name : startpage
131 135
     engine : startpage
132 136
     shortcut : sp