From 550232fc21ff2c3ae9a5de3d8b999de66c96171c Mon Sep 17 00:00:00 2001 From: Cqoicebordel Date: Mon, 22 Dec 2014 01:00:16 +0100 Subject: SubtitleSeeker Engine Add the subtitleseeker engine. --- searx/engines/subtitleseeker.py | 59 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 searx/engines/subtitleseeker.py (limited to 'searx/engines') diff --git a/searx/engines/subtitleseeker.py b/searx/engines/subtitleseeker.py new file mode 100644 index 000000000..346298300 --- /dev/null +++ b/searx/engines/subtitleseeker.py @@ -0,0 +1,59 @@ +## Subtitleseeker (Video) +# +# @website http://www.subtitleseeker.com +# @provide-api no +# +# @using-api no +# @results HTML +# @stable no (HTML can change) +# @parse url, title, content + +from cgi import escape +from urllib import quote_plus +from lxml import html + +# engine dependent config +categories = ['videos'] +paging = True + +# search-url +url = 'http://www.subtitleseeker.com/' +search_url = url+'search/TITLES/{query}&p={pageno}' + +# specific xpath variables +results_xpath = '//div[@class="boxRows"]' + + +# do search-request +def request(query, params): + params['url'] = search_url.format(query=quote_plus(query), + pageno=params['pageno']) + return params + + +# get response from search-request +def response(resp): + results = [] + + dom = html.fromstring(resp.text) + + # parse results + for result in dom.xpath(results_xpath): + link = result.xpath(".//a")[0] + href = link.attrib.get('href') + title = escape(link.xpath(".//text()")[0]) + + content = result.xpath('.//div[contains(@class,"red")]//text()')[0] + content = content + " - " + content = content + html.tostring(result.xpath('.//div[contains(@class,"grey-web")]')[0], method='text') + + if result.xpath(".//span") != []: + content = content + " - (" + result.xpath(".//span//text()")[0].strip() + ")" + + # append result + results.append({'url': href, + 'title': title, + 'content': escape(content)}) + + # return results + return results -- cgit v1.2.3 From 829948b85df0510e331372bcd60cb31db9c96a5c Mon Sep 17 00:00:00 2001 From: Cqoicebordel Date: Tue, 23 Dec 2014 01:41:25 +0100 Subject: Add language support Allow the user to select a language. It must be written in english, and capitalized, ie : English, French, German, Hungarian... --- searx/engines/subtitleseeker.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'searx/engines') diff --git a/searx/engines/subtitleseeker.py b/searx/engines/subtitleseeker.py index 346298300..c72f81899 100644 --- a/searx/engines/subtitleseeker.py +++ b/searx/engines/subtitleseeker.py @@ -16,6 +16,8 @@ from lxml import html categories = ['videos'] paging = True +language = "" + # search-url url = 'http://www.subtitleseeker.com/' search_url = url+'search/TITLES/{query}&p={pageno}' @@ -41,6 +43,10 @@ def response(resp): for result in dom.xpath(results_xpath): link = result.xpath(".//a")[0] href = link.attrib.get('href') + + if language is not "": + href = href + language + "/" + title = escape(link.xpath(".//text()")[0]) content = result.xpath('.//div[contains(@class,"red")]//text()')[0] -- cgit v1.2.3 From 2ea55b1c6451e77381bd88dd82f635d48ff1b6fe Mon Sep 17 00:00:00 2001 From: Cqoicebordel Date: Tue, 23 Dec 2014 01:45:39 +0100 Subject: Add language support Allow the user to select a language. It must be written in english, and capitalized, ie : English, French, German, Hungarian... (reverted from commit 829948b85df0510e331372bcd60cb31db9c96a5c) --- searx/engines/subtitleseeker.py | 6 ------ 1 file changed, 6 deletions(-) (limited to 'searx/engines') diff --git a/searx/engines/subtitleseeker.py b/searx/engines/subtitleseeker.py index c72f81899..346298300 100644 --- a/searx/engines/subtitleseeker.py +++ b/searx/engines/subtitleseeker.py @@ -16,8 +16,6 @@ from lxml import html categories = ['videos'] paging = True -language = "" - # search-url url = 'http://www.subtitleseeker.com/' search_url = url+'search/TITLES/{query}&p={pageno}' @@ -43,10 +41,6 @@ def response(resp): for result in dom.xpath(results_xpath): link = result.xpath(".//a")[0] href = link.attrib.get('href') - - if language is not "": - href = href + language + "/" - title = escape(link.xpath(".//text()")[0]) content = result.xpath('.//div[contains(@class,"red")]//text()')[0] -- cgit v1.2.3 From 10e4f6f31631fe51d16b324223525570f3e75850 Mon Sep 17 00:00:00 2001 From: Cqoicebordel Date: Tue, 23 Dec 2014 01:51:07 +0100 Subject: Add language support Allow the user to select a language. It must be written in english, and capitalized, ie : English, French, German, Hungarian... --- searx/engines/subtitleseeker.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'searx/engines') diff --git a/searx/engines/subtitleseeker.py b/searx/engines/subtitleseeker.py index 346298300..48790a35c 100644 --- a/searx/engines/subtitleseeker.py +++ b/searx/engines/subtitleseeker.py @@ -15,6 +15,7 @@ from lxml import html # engine dependent config categories = ['videos'] paging = True +language = "" # search-url url = 'http://www.subtitleseeker.com/' @@ -41,6 +42,10 @@ def response(resp): for result in dom.xpath(results_xpath): link = result.xpath(".//a")[0] href = link.attrib.get('href') + + if language is not "": + href = href + language + "/" + title = escape(link.xpath(".//text()")[0]) content = result.xpath('.//div[contains(@class,"red")]//text()')[0] -- cgit v1.2.3