2015-05-02 13:45:17 +00:00
|
|
|
"""
|
|
|
|
Subtitleseeker (Video)
|
|
|
|
|
|
|
|
@website http://www.subtitleseeker.com
|
|
|
|
@provide-api no
|
|
|
|
|
|
|
|
@using-api no
|
|
|
|
@results HTML
|
|
|
|
@stable no (HTML can change)
|
|
|
|
@parse url, title, content
|
|
|
|
"""
|
2014-12-22 00:00:16 +00:00
|
|
|
|
|
|
|
from lxml import html
|
2014-12-24 20:02:26 +00:00
|
|
|
from searx.languages import language_codes
|
2015-02-06 15:39:59 +00:00
|
|
|
from searx.engines.xpath import extract_text
|
2016-11-30 17:43:03 +00:00
|
|
|
from searx.url_utils import quote_plus
|
2014-12-22 00:00:16 +00:00
|
|
|
|
|
|
|
# engine dependent config
|
|
|
|
categories = ['videos']
|
|
|
|
paging = True
|
2014-12-23 00:51:07 +00:00
|
|
|
language = ""
|
2014-12-22 00:00:16 +00:00
|
|
|
|
|
|
|
# search-url
|
|
|
|
url = 'http://www.subtitleseeker.com/'
|
2016-11-06 02:51:38 +00:00
|
|
|
search_url = url + 'search/TITLES/{query}?p={pageno}'
|
2014-12-22 00:00:16 +00:00
|
|
|
|
|
|
|
# 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)
|
|
|
|
|
2014-12-24 20:02:26 +00:00
|
|
|
search_lang = ""
|
|
|
|
|
2016-08-06 04:34:56 +00:00
|
|
|
# dirty fix for languages named differenly in their site
|
|
|
|
if resp.search_params['language'][:2] == 'fa':
|
|
|
|
search_lang = 'Farsi'
|
2016-12-14 05:51:15 +00:00
|
|
|
elif resp.search_params['language'] == 'pt-BR':
|
2016-08-06 04:34:56 +00:00
|
|
|
search_lang = 'Brazilian'
|
2017-07-20 20:47:20 +00:00
|
|
|
else:
|
2016-08-06 04:34:56 +00:00
|
|
|
search_lang = [lc[3]
|
2014-12-24 20:02:26 +00:00
|
|
|
for lc in language_codes
|
2016-11-06 02:51:38 +00:00
|
|
|
if lc[0].split('-')[0] == resp.search_params['language'].split('-')[0]]
|
|
|
|
search_lang = search_lang[0].split(' (')[0]
|
2014-12-24 20:02:26 +00:00
|
|
|
|
2014-12-22 00:00:16 +00:00
|
|
|
# parse results
|
|
|
|
for result in dom.xpath(results_xpath):
|
|
|
|
link = result.xpath(".//a")[0]
|
|
|
|
href = link.attrib.get('href')
|
2014-12-23 00:51:07 +00:00
|
|
|
|
|
|
|
if language is not "":
|
2014-12-24 20:02:26 +00:00
|
|
|
href = href + language + '/'
|
|
|
|
elif search_lang:
|
|
|
|
href = href + search_lang + '/'
|
2014-12-23 00:51:07 +00:00
|
|
|
|
2016-12-09 10:44:24 +00:00
|
|
|
title = extract_text(link)
|
2014-12-22 00:00:16 +00:00
|
|
|
|
2015-02-06 15:39:59 +00:00
|
|
|
content = extract_text(result.xpath('.//div[contains(@class,"red")]'))
|
2014-12-22 00:00:16 +00:00
|
|
|
content = content + " - "
|
2015-02-06 15:39:59 +00:00
|
|
|
text = extract_text(result.xpath('.//div[contains(@class,"grey-web")]')[0])
|
|
|
|
content = content + text
|
2014-12-22 00:00:16 +00:00
|
|
|
|
|
|
|
if result.xpath(".//span") != []:
|
2014-12-29 20:31:04 +00:00
|
|
|
content = content +\
|
2015-01-02 11:33:40 +00:00
|
|
|
" - (" +\
|
2015-02-06 15:39:59 +00:00
|
|
|
extract_text(result.xpath(".//span")) +\
|
2015-01-02 11:33:40 +00:00
|
|
|
")"
|
2014-12-22 00:00:16 +00:00
|
|
|
|
|
|
|
# append result
|
|
|
|
results.append({'url': href,
|
|
|
|
'title': title,
|
2016-12-09 10:44:24 +00:00
|
|
|
'content': content})
|
2014-12-22 00:00:16 +00:00
|
|
|
|
|
|
|
# return results
|
|
|
|
return results
|