.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.engines.livespace Namespace Reference

Functions

 request (query, params)
 
 response (resp)
 

Variables

dict about
 
list categories = ['videos']
 
str base_url = 'https://backend.live.space'
 
bool paging = True
 
int results_per_page = 10
 

Detailed Description

LiveSpace (Videos)

.. hint::

   This engine only search for **live streams**!

Function Documentation

◆ request()

searx.engines.livespace.request ( query,
params )

Definition at line 32 of file livespace.py.

32def request(query, params):
33
34 args = {'page': params['pageno'] - 1, 'searchKey': query, 'size': results_per_page}
35 params['url'] = f"{base_url}/search/public/stream?{urlencode(args)}"
36 params['headers'] = {'Accept': 'application/json', 'Content-Type': 'application/json'}
37
38 return params
39
40

◆ response()

searx.engines.livespace.response ( resp)

Definition at line 41 of file livespace.py.

41def response(resp):
42
43 results = []
44 json = resp.json()
45 now = datetime.now()
46
47 # for live videos
48
49 for result in json.get('result', []):
50
51 title = result.get("title")
52 thumbnailUrl = result.get("thumbnailUrl")
53 category = result.get("category/name")
54 username = result.get("user", {}).get("userName", "")
55 url = f'https://live.space/watch/{username}'
56
57 # stream tags
58 # currently the api seems to always return null before the first tag,
59 # so strip that unless it's not already there
60 tags = ''
61 if result.get("tags"):
62 tags = [x for x in result.get("tags").split(';') if x and x != 'null']
63 tags = ', '.join(tags)
64
65 content = []
66 if category:
67 content.append(f'category - {category}')
68
69 if tags and len(tags) > 0:
70 content.append(f'tags - {tags}')
71
72 # time & duration
73 start_time = None
74 if result.get("startTimeStamp"):
75 start_time = datetime.fromtimestamp(result.get("startTimeStamp") / 1000)
76
77 # for VODs (videos on demand)
78 end_time = None
79 if result.get("endTimeStamp"):
80 end_time = datetime.fromtimestamp(result.get("endTimeStamp") / 1000)
81
82 timestring = ""
83 if start_time:
84 delta = (now if end_time is None else end_time) - start_time
85 timestring = dates.format_timedelta(delta, granularity='second')
86
87 results.append(
88 {
89 'url': url,
90 'title': title,
91 'content': "No category or tags." if len(content) == 0 else ' '.join(content),
92 'author': username,
93 'length': (">= " if end_time is None else "") + timestring,
94 'publishedDate': start_time,
95 'thumbnail': thumbnailUrl,
96 'template': 'videos.html',
97 }
98 )
99
100 return results

Variable Documentation

◆ about

dict searx.engines.livespace.about
Initial value:
1= {
2 "website": 'https://live.space',
3 "wikidata_id": None,
4 "official_api_documentation": None,
5 "use_official_api": True,
6 "require_api_key": False,
7 "results": 'JSON',
8}

Definition at line 14 of file livespace.py.

◆ base_url

str searx.engines.livespace.base_url = 'https://backend.live.space'

Definition at line 25 of file livespace.py.

◆ categories

list searx.engines.livespace.categories = ['videos']

Definition at line 23 of file livespace.py.

◆ paging

bool searx.engines.livespace.paging = True

Definition at line 28 of file livespace.py.

◆ results_per_page

int searx.engines.livespace.results_per_page = 10

Definition at line 29 of file livespace.py.