.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
360search_videos.py
Go to the documentation of this file.
1
# SPDX-License-Identifier: AGPL-3.0-or-later
2
# pylint: disable=invalid-name
3
"""360Search-Videos: A search engine for retrieving videos from 360Search."""
4
5
from
urllib.parse
import
urlencode
6
from
datetime
import
datetime
7
8
from
searx.exceptions
import
SearxEngineAPIException
9
from
searx.utils
import
html_to_text, get_embeded_stream_url
10
11
about = {
12
"website"
:
"https://tv.360kan.com/"
,
13
"use_official_api"
:
False
,
14
"require_api_key"
:
False
,
15
"results"
:
"JSON"
,
16
}
17
18
paging =
True
19
results_per_page = 10
20
categories = [
"videos"
]
21
22
base_url =
"https://tv.360kan.com"
23
24
25
def
request
(query, params):
26
query_params = {
"count"
: 10,
"q"
: query,
"start"
: params[
"pageno"
] * 10}
27
28
params[
"url"
] = f
"{base_url}/v1/video/list?{urlencode(query_params)}"
29
return
params
30
31
32
def
response
(resp):
33
try
:
34
data = resp.json()
35
except
Exception
as
e:
36
raise
SearxEngineAPIException
(f
"Invalid response: {e}"
)
from
e
37
results = []
38
39
if
"data"
not
in
data
or
"result"
not
in
data[
"data"
]:
40
raise
SearxEngineAPIException
(
"Invalid response"
)
41
42
for
entry
in
data[
"data"
][
"result"
]:
43
if
not
entry.get(
"title"
)
or
not
entry.get(
"play_url"
):
44
continue
45
46
published_date =
None
47
if
entry.get(
"publish_time"
):
48
try
:
49
published_date = datetime.fromtimestamp(int(entry[
"publish_time"
]))
50
except
(ValueError, TypeError):
51
published_date =
None
52
53
results.append(
54
{
55
'url'
: entry[
"play_url"
],
56
'title'
: html_to_text(entry[
"title"
]),
57
'content'
: html_to_text(entry[
"description"
]),
58
'template'
:
'videos.html'
,
59
'publishedDate'
: published_date,
60
'thumbnail'
: entry[
"cover_img"
],
61
"iframe_src"
: get_embeded_stream_url(entry[
"play_url"
]),
62
}
63
)
64
65
return
results
searx.exceptions.SearxEngineAPIException
Definition
exceptions.py:54
searx.engines.360search_videos.response
response(resp)
Definition
360search_videos.py:32
searx.engines.360search_videos.request
request(query, params)
Definition
360search_videos.py:25
searx.exceptions
Definition
exceptions.py:1
searx.utils
Definition
utils.py:1
searxng
searx
engines
360search_videos.py
Generated on Sat Mar 8 2025 14:18:40 for .oO SearXNG Developer Documentation Oo. by
1.13.2