summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarIT.de>2023-04-16 21:03:19 +0200
committerGitHub <noreply@github.com>2023-04-16 21:03:19 +0200
commitc0bc8634fd8d4c433ce91fbc868270504c2e00be (patch)
treeba5516a55ab01c6546c08e99d64b72879c8796b9
parentb55a62dbc9d23b19c690f42311fed4365cb11098 (diff)
parentf1b6351ae1bade2e323b7d2d603c0678e940651d (diff)
downloadsearxng-c0bc8634fd8d4c433ce91fbc868270504c2e00be.tar.gz
searxng-c0bc8634fd8d4c433ce91fbc868270504c2e00be.zip
Merge pull request #2352 from return42/fix-1599
[fix] engine: google play movies
-rw-r--r--searx/engines/google_play.py (renamed from searx/engines/google_play_apps.py)54
-rw-r--r--searx/settings.yml21
2 files changed, 54 insertions, 21 deletions
diff --git a/searx/engines/google_play_apps.py b/searx/engines/google_play.py
index 6506a446a..45a3fdb69 100644
--- a/searx/engines/google_play_apps.py
+++ b/searx/engines/google_play.py
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-"""
- Google Play Apps
+# lint: pylint
+"""Google Play Apps & Google Play Movies
"""
from urllib.parse import urlencode
@@ -21,22 +21,66 @@ about = {
"results": "HTML",
}
-categories = ["files", "apps"]
send_accept_language_header = True
-search_url = "https://play.google.com/store/search?{query}&c=apps"
+play_categ = None # apps|movies
+base_url = 'https://play.google.com'
+search_url = base_url + "/store/search?{query}&c={play_categ}"
def request(query, params):
- params["url"] = search_url.format(query=urlencode({"q": query}))
+
+ if play_categ not in ('movies', 'apps'):
+ raise ValueError(f"unknown google play category: {play_categ}")
+
+ params["url"] = search_url.format(
+ query=urlencode({"q": query}),
+ play_categ=play_categ,
+ )
params['cookies']['CONSENT'] = "YES+"
return params
def response(resp):
+
+ if play_categ == 'movies':
+ return response_movies(resp)
+ if play_categ == 'apps':
+ return response_apps(resp)
+ return []
+
+
+def response_movies(resp):
+
results = []
+ dom = html.fromstring(resp.text)
+
+ for section in eval_xpath(dom, '//c-wiz/section/header/..'):
+ sec_name = extract_text(eval_xpath(section, './header'))
+ for item in eval_xpath(section, './/a'):
+ url = base_url + item.get('href')
+ div_1, div_2 = eval_xpath(item, './div')[:2]
+ title = extract_text(eval_xpath(div_2, './div[@title]'))
+ metadata = extract_text(eval_xpath(div_2, './div[@class]'))
+ img = eval_xpath(div_1, './/img')[0]
+ img_src = img.get('src')
+ results.append(
+ {
+ "url": url,
+ "title": title,
+ "content": sec_name,
+ "img_src": img_src,
+ 'metadata': metadata,
+ 'template': 'videos.html',
+ }
+ )
+ return results
+
+def response_apps(resp):
+
+ results = []
dom = html.fromstring(resp.text)
if eval_xpath(dom, '//div[@class="v6DsQb"]'):
diff --git a/searx/settings.yml b/searx/settings.yml
index fa6141dd4..e63ded9ad 100644
--- a/searx/settings.yml
+++ b/searx/settings.yml
@@ -755,29 +755,18 @@ engines:
shortcut: gos
- name: google play apps
- engine: google_play_apps
+ engine: google_play
+ categories: [files, apps]
shortcut: gpa
+ play_categ: apps
disabled: true
- name: google play movies
- engine: xpath
- send_accept_language_header: true
- search_url: https://play.google.com/store/search?q={query}&c=movies
- results_xpath: '//div[@class="ImZGtf mpg5gc"]'
- title_xpath: './/div[@class="RZEgze"]//div[@class="kCSSQe"]//a'
- url_xpath: './/div[@class="RZEgze"]//div[@class="kCSSQe"]//a/@href'
- content_xpath: './/div[@class="kCSSQe"]'
- thumbnail_xpath: './/div[@class="uzcko"]/div/span[1]//img/@data-src'
+ engine: google_play
categories: videos
shortcut: gpm
+ play_categ: movies
disabled: true
- about:
- website: https://play.google.com/
- wikidata_id: Q79576
- official_api_documentation:
- use_official_api: false
- require_api_key: false
- results: HTML
- name: gpodder
engine: json_engine