forked from zaclys/searxng
Merge pull request #2451 from mrwormo/invidious-engine
[Fix] Invidious Engine
This commit is contained in:
commit
b405646749
|
@ -6,6 +6,7 @@
|
||||||
from urllib.parse import quote_plus
|
from urllib.parse import quote_plus
|
||||||
from dateutil import parser
|
from dateutil import parser
|
||||||
import time
|
import time
|
||||||
|
import random
|
||||||
|
|
||||||
# about
|
# about
|
||||||
about = {
|
about = {
|
||||||
|
@ -23,19 +24,29 @@ paging = True
|
||||||
language_support = True
|
language_support = True
|
||||||
time_range_support = True
|
time_range_support = True
|
||||||
|
|
||||||
|
|
||||||
# search-url
|
# search-url
|
||||||
base_url = "https://invidio.us/"
|
|
||||||
|
base_url = ''
|
||||||
|
base_url_rand = ''
|
||||||
|
|
||||||
|
|
||||||
# do search-request
|
# do search-request
|
||||||
def request(query, params):
|
def request(query, params):
|
||||||
|
global base_url_rand
|
||||||
time_range_dict = {
|
time_range_dict = {
|
||||||
"day": "today",
|
"day": "today",
|
||||||
"week": "week",
|
"week": "week",
|
||||||
"month": "month",
|
"month": "month",
|
||||||
"year": "year",
|
"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(
|
params["url"] = search_url.format(
|
||||||
query=quote_plus(query)
|
query=quote_plus(query)
|
||||||
) + "&page={pageno}".format(pageno=params["pageno"])
|
) + "&page={pageno}".format(pageno=params["pageno"])
|
||||||
|
@ -61,12 +72,12 @@ def response(resp):
|
||||||
embedded_url = (
|
embedded_url = (
|
||||||
'<iframe width="540" height="304" '
|
'<iframe width="540" height="304" '
|
||||||
+ 'data-src="'
|
+ 'data-src="'
|
||||||
+ base_url
|
+ base_url_rand
|
||||||
+ 'embed/{videoid}" '
|
+ 'embed/{videoid}" '
|
||||||
+ 'frameborder="0" allowfullscreen></iframe>'
|
+ 'frameborder="0" allowfullscreen></iframe>'
|
||||||
)
|
)
|
||||||
|
|
||||||
base_invidious_url = base_url + "watch?v="
|
base_invidious_url = base_url_rand + "watch?v="
|
||||||
|
|
||||||
for result in search_results:
|
for result in search_results:
|
||||||
rtype = result.get("type", None)
|
rtype = result.get("type", None)
|
||||||
|
|
|
@ -630,7 +630,9 @@ engines:
|
||||||
|
|
||||||
- name : invidious
|
- name : invidious
|
||||||
engine : invidious
|
engine : invidious
|
||||||
base_url : 'https://invidio.us/'
|
base_url :
|
||||||
|
- https://invidious.tube/
|
||||||
|
- https://invidious.snopyta.org/
|
||||||
shortcut: iv
|
shortcut: iv
|
||||||
timeout : 5.0
|
timeout : 5.0
|
||||||
disabled : True
|
disabled : True
|
||||||
|
|
Loading…
Reference in New Issue