summaryrefslogtreecommitdiff
path: root/searx
diff options
context:
space:
mode:
authorAdam Tauber <asciimoo@gmail.com>2016-12-11 02:33:04 +0100
committerAdam Tauber <asciimoo@gmail.com>2016-12-11 02:33:04 +0100
commitf6e9c074bbe8b4237ee361befa8dcb2c6d31a11a (patch)
tree4645177ca966ea5bdf1d7a337629546ff2040fa6 /searx
parenta2c94895c1fbba0b20a07ee13b1185ae741db2de (diff)
downloadsearxng-f6e9c074bbe8b4237ee361befa8dcb2c6d31a11a.tar.gz
searxng-f6e9c074bbe8b4237ee361befa8dcb2c6d31a11a.zip
[fix] vimeo engine change follow-up
Diffstat (limited to 'searx')
-rw-r--r--searx/engines/vimeo.py32
1 files changed, 12 insertions, 20 deletions
diff --git a/searx/engines/vimeo.py b/searx/engines/vimeo.py
index 517ac1c44..5d5310544 100644
--- a/searx/engines/vimeo.py
+++ b/searx/engines/vimeo.py
@@ -12,10 +12,8 @@
# @todo rewrite to api
# @todo set content-parameter with correct data
+from json import loads
from urllib import urlencode
-from lxml import html
-from HTMLParser import HTMLParser
-from searx.engines.xpath import extract_text
from dateutil import parser
# engine dependent config
@@ -23,17 +21,10 @@ categories = ['videos']
paging = True
# search-url
-base_url = 'https://vimeo.com'
+base_url = 'https://vimeo.com/'
search_url = base_url + '/search/page:{pageno}?{query}'
-# specific xpath variables
-results_xpath = '//div[contains(@class,"results_grid")]/ul/li'
-url_xpath = './/a/@href'
-title_xpath = './/span[@class="title"]'
-thumbnail_xpath = './/img[@class="js-clip_thumbnail_image"]/@src'
-publishedDate_xpath = './/time/attribute::datetime'
-
-embedded_url = '<iframe data-src="//player.vimeo.com/video{videoid}" ' +\
+embedded_url = '<iframe data-src="//player.vimeo.com/video/{videoid}" ' +\
'width="540" height="304" frameborder="0" ' +\
'webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>'
@@ -49,17 +40,18 @@ def request(query, params):
# get response from search-request
def response(resp):
results = []
-
- dom = html.fromstring(resp.text)
- p = HTMLParser()
+ data_start_pos = resp.text.find('{"filtered"')
+ data_end_pos = resp.text.find(';\n', data_start_pos + 1)
+ data = loads(resp.text[data_start_pos:data_end_pos])
# parse results
- for result in dom.xpath(results_xpath):
- videoid = result.xpath(url_xpath)[0]
+ for result in data['filtered']['data']:
+ result = result[result['type']]
+ videoid = result['uri'].split('/')[-1]
url = base_url + videoid
- title = p.unescape(extract_text(result.xpath(title_xpath)))
- thumbnail = extract_text(result.xpath(thumbnail_xpath)[0])
- publishedDate = parser.parse(extract_text(result.xpath(publishedDate_xpath)[0]))
+ title = result['name']
+ thumbnail = result['pictures']['sizes'][-1]['link']
+ publishedDate = parser.parse(result['created_time'])
embedded = embedded_url.format(videoid=videoid)
# append result