on master help sign in
Merge pull request #161 from Cqoicebordel/SubtitleSeeker-engine

SubtitleSeeker Engine

commit5857141e498e80c1528ac13091ae374e807cbf75 authorAdam Tauber <asciimoo@gmail.com> dateWed 24 Dec 2014, 20:21 (12 years ago) parentb97541810e4f6f
2 files changed+71
searx/engines/subtitleseeker.py+64 searx/settings.yml+7
searx/engines/subtitleseeker.pynew file+64
@@ -0,0 +1,64 @@
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+language = ""
19+
20+# search-url
21+url = 'http://www.subtitleseeker.com/'
22+search_url = url+'search/TITLES/{query}&p={pageno}'
23+
24+# specific xpath variables
25+results_xpath = '//div[@class="boxRows"]'
26+
27+
28+# do search-request
29+def request(query, params):
30+ params['url'] = search_url.format(query=quote_plus(query),
31+ pageno=params['pageno'])
32+ return params
33+
34+
35+# get response from search-request
36+def response(resp):
37+ results = []
38+
39+ dom = html.fromstring(resp.text)
40+
41+ # parse results
42+ for result in dom.xpath(results_xpath):
43+ link = result.xpath(".//a")[0]
44+ href = link.attrib.get('href')
45+
46+ if language is not "":
47+ href = href + language + "/"
48+
49+ title = escape(link.xpath(".//text()")[0])
50+
51+ content = result.xpath('.//div[contains(@class,"red")]//text()')[0]
52+ content = content + " - "
53+ content = content + html.tostring(result.xpath('.//div[contains(@class,"grey-web")]')[0], method='text')
54+
55+ if result.xpath(".//span") != []:
56+ content = content + " - (" + result.xpath(".//span//text()")[0].strip() + ")"
57+
58+ # append result
59+ results.append({'url': href,
60+ 'title': title,
61+ 'content': escape(content)})
62+
63+ # return results
64+ return results
searx/settings.yml+7
@@ -131,6 +131,13 @@ engines:
131131 engine : searchcode_code
132132 shortcut : scc
133133
134+ - name : subtitleseeker
135+ engine : subtitleseeker
136+ shortcut : ss
137+# The language is an option. You can put any language written in english
138+# Examples : English, French, German, Hungarian, Chinese...
139+# language : English
140+
134141 - name : startpage
135142 engine : startpage
136143 shortcut : sp