From 550232fc21ff2c3ae9a5de3d8b999de66c96171c Mon Sep 17 00:00:00 2001 From: Cqoicebordel Date: Mon, 22 Dec 2014 01:00:16 +0100 Subject: [PATCH 1/4] SubtitleSeeker Engine Add the subtitleseeker engine. --- searx/engines/subtitleseeker.py | 59 +++++++++++++++++++++++++++++++++ searx/settings.yml | 4 +++ 2 files changed, 63 insertions(+) create mode 100644 searx/engines/subtitleseeker.py diff --git a/searx/engines/subtitleseeker.py b/searx/engines/subtitleseeker.py new file mode 100644 index 0000000..3462983 --- /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 diff --git a/searx/settings.yml b/searx/settings.yml index 8cfe3f8..cc70731 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -127,6 +127,10 @@ engines: engine : searchcode_code shortcut : scc + - name : subtitleseeker + engine : subtitleseeker + shortcut : ss + - name : startpage engine : startpage shortcut : sp From 829948b85df0510e331372bcd60cb31db9c96a5c Mon Sep 17 00:00:00 2001 From: Cqoicebordel Date: Tue, 23 Dec 2014 01:41:25 +0100 Subject: [PATCH 2/4] 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 ++++++ searx/settings.yml | 11 +++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/searx/engines/subtitleseeker.py b/searx/engines/subtitleseeker.py index 3462983..c72f818 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] diff --git a/searx/settings.yml b/searx/settings.yml index cc70731..ed22ad9 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -1,13 +1,13 @@ server: - port : 8888 - secret_key : "ultrasecretkey" # change this! - debug : False # Debug mode, only for development + port : 2722 + secret_key : "8f92c98926f04c8cb2a5fdc3bca19f7c" # change this! + debug : True # Debug mode, only for development request_timeout : 2.0 # seconds base_url : False # Set custom base_url. Possible values: False or "https://your.custom.host/location/" themes_path : "" # Custom ui themes path default_theme : default # ui theme https_rewrite : True # Force rewrite result urls. See searx/https_rewrite.py - useragent_suffix : "" # suffix of searx_useragent, could contain informations like an email address to the administrator + useragent_suffix : "Cqcb Style" # suffix of searx_useragent, could contain informations like an email address to the administrator engines: - name : wikipedia @@ -130,6 +130,9 @@ engines: - name : subtitleseeker engine : subtitleseeker shortcut : ss +# The language is an option. You can put any language written in english +# Examples : English, French, German, Hungarian, Chinese... +# language : English - name : startpage engine : startpage From 2ea55b1c6451e77381bd88dd82f635d48ff1b6fe Mon Sep 17 00:00:00 2001 From: Cqoicebordel Date: Tue, 23 Dec 2014 01:45:39 +0100 Subject: [PATCH 3/4] 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 ------ searx/settings.yml | 11 ++++------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/searx/engines/subtitleseeker.py b/searx/engines/subtitleseeker.py index c72f818..3462983 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] diff --git a/searx/settings.yml b/searx/settings.yml index ed22ad9..cc70731 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -1,13 +1,13 @@ server: - port : 2722 - secret_key : "8f92c98926f04c8cb2a5fdc3bca19f7c" # change this! - debug : True # Debug mode, only for development + port : 8888 + secret_key : "ultrasecretkey" # change this! + debug : False # Debug mode, only for development request_timeout : 2.0 # seconds base_url : False # Set custom base_url. Possible values: False or "https://your.custom.host/location/" themes_path : "" # Custom ui themes path default_theme : default # ui theme https_rewrite : True # Force rewrite result urls. See searx/https_rewrite.py - useragent_suffix : "Cqcb Style" # suffix of searx_useragent, could contain informations like an email address to the administrator + useragent_suffix : "" # suffix of searx_useragent, could contain informations like an email address to the administrator engines: - name : wikipedia @@ -130,9 +130,6 @@ engines: - name : subtitleseeker engine : subtitleseeker shortcut : ss -# The language is an option. You can put any language written in english -# Examples : English, French, German, Hungarian, Chinese... -# language : English - name : startpage engine : startpage From 10e4f6f31631fe51d16b324223525570f3e75850 Mon Sep 17 00:00:00 2001 From: Cqoicebordel Date: Tue, 23 Dec 2014 01:51:07 +0100 Subject: [PATCH 4/4] 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 +++++ searx/settings.yml | 3 +++ 2 files changed, 8 insertions(+) diff --git a/searx/engines/subtitleseeker.py b/searx/engines/subtitleseeker.py index 3462983..48790a3 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] diff --git a/searx/settings.yml b/searx/settings.yml index cc70731..e3fe9b2 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -130,6 +130,9 @@ engines: - name : subtitleseeker engine : subtitleseeker shortcut : ss +# The language is an option. You can put any language written in english +# Examples : English, French, German, Hungarian, Chinese... +# language : English - name : startpage engine : startpage