summaryrefslogtreecommitdiff
path: root/searx/engines
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2021-01-16 19:25:45 +0100
committerGitHub <noreply@github.com>2021-01-16 19:25:45 +0100
commitb405646749e87aad95b4a717bdde9ec12608cb5a (patch)
tree07c0c3d122921b28b2ff146f8dddc732ce8e6171 /searx/engines
parent709dd960f125af17cffa10715d5bdef15018a918 (diff)
parent2dff3887f0c64ce317b3bb720c75f764c1ec8b3e (diff)
downloadsearxng-b405646749e87aad95b4a717bdde9ec12608cb5a.tar.gz
searxng-b405646749e87aad95b4a717bdde9ec12608cb5a.zip
Merge pull request #2451 from mrwormo/invidious-engine
[Fix] Invidious Engine
Diffstat (limited to 'searx/engines')
-rw-r--r--searx/engines/invidious.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/searx/engines/invidious.py b/searx/engines/invidious.py
index 1d6d69f64..61a6e5a19 100644
--- a/searx/engines/invidious.py
+++ b/searx/engines/invidious.py
@@ -6,6 +6,7 @@
from urllib.parse import quote_plus
from dateutil import parser
import time
+import random
# about
about = {
@@ -23,19 +24,29 @@ paging = True
language_support = True
time_range_support = True
+
# search-url
-base_url = "https://invidio.us/"
+
+base_url = ''
+base_url_rand = ''
# do search-request
def request(query, params):
+ global base_url_rand
time_range_dict = {
"day": "today",
"week": "week",
"month": "month",
"year": "year",
}
- search_url = base_url + "api/v1/search?q={query}"
+
+ if isinstance(base_url, list):
+ base_url_rand = random.choice(base_url)
+ else:
+ base_url_rand = base_url
+
+ search_url = base_url_rand + "api/v1/search?q={query}"
params["url"] = search_url.format(
query=quote_plus(query)
) + "&page={pageno}".format(pageno=params["pageno"])
@@ -61,12 +72,12 @@ def response(resp):
embedded_url = (
'<iframe width="540" height="304" '
+ 'data-src="'
- + base_url
+ + base_url_rand
+ 'embed/{videoid}" '
+ 'frameborder="0" allowfullscreen></iframe>'
)
- base_invidious_url = base_url + "watch?v="
+ base_invidious_url = base_url_rand + "watch?v="
for result in search_results:
rtype = result.get("type", None)