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

Functions

 request (query, params)
 
 parse_lyric (hit)
 
 parse_artist (hit)
 
 parse_album (hit)
 
 response (resp)
 

Variables

dict about
 
list categories = ['music', 'lyrics']
 
bool paging = True
 
int page_size = 5
 
str url = 'https://genius.com/api/'
 
str search_url = url + 'search/{index}?{query}&page={pageno}&per_page={page_size}'
 
str music_player = 'https://genius.com{api_path}/apple_music_player'
 
dict parse = {'lyric': parse_lyric, 'song': parse_lyric, 'artist': parse_artist, 'album': parse_album}
 

Detailed Description

Genius

Function Documentation

◆ parse_album()

searx.engines.genius.parse_album ( hit)

Definition at line 76 of file genius.py.

76def parse_album(hit):
77 res = hit['result']
78 content = res.get('name_with_artist', res.get('name', ''))
79 x = res.get('release_date_components')
80 if x:
81 x = x.get('year')
82 if x:
83 content = "%s / %s" % (x, content)
84 return {
85 'url': res['url'],
86 'title': res['full_title'],
87 'img_src': res['cover_art_url'],
88 'content': content.strip(),
89 }
90
91

◆ parse_artist()

searx.engines.genius.parse_artist ( hit)

Definition at line 66 of file genius.py.

66def parse_artist(hit):
67 result = {
68 'url': hit['result']['url'],
69 'title': hit['result']['name'],
70 'content': '',
71 'img_src': hit['result']['image_url'],
72 }
73 return result
74
75

◆ parse_lyric()

searx.engines.genius.parse_lyric ( hit)

Definition at line 40 of file genius.py.

40def parse_lyric(hit):
41 content = ''
42 highlights = hit['highlights']
43 if highlights:
44 content = hit['highlights'][0]['value']
45 else:
46 content = hit['result'].get('title_with_featured', '')
47
48 timestamp = hit['result']['lyrics_updated_at']
49 result = {
50 'url': hit['result']['url'],
51 'title': hit['result']['full_title'],
52 'content': content,
53 'img_src': hit['result']['song_art_image_thumbnail_url'],
54 }
55 if timestamp:
56 result.update({'publishedDate': datetime.fromtimestamp(timestamp)})
57 api_path = hit['result'].get('api_path')
58 if api_path:
59 # The players are just playing 30sec from the title. Some of the player
60 # will be blocked because of a cross-origin request and some players will
61 # link to apple when you press the play button.
62 result['iframe_src'] = music_player.format(api_path=api_path)
63 return result
64
65

◆ request()

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

Definition at line 30 of file genius.py.

30def request(query, params):
31 params['url'] = search_url.format(
32 query=urlencode({'q': query}),
33 index='multi',
34 page_size=page_size,
35 pageno=params['pageno'],
36 )
37 return params
38
39

◆ response()

searx.engines.genius.response ( resp)

Definition at line 95 of file genius.py.

95def response(resp):
96 results = []
97 for section in resp.json()['response']['sections']:
98 for hit in section['hits']:
99 func = parse.get(hit['type'])
100 if func:
101 results.append(func(hit))
102 return results

Variable Documentation

◆ about

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

Definition at line 11 of file genius.py.

◆ categories

list searx.engines.genius.categories = ['music', 'lyrics']

Definition at line 21 of file genius.py.

◆ music_player

str searx.engines.genius.music_player = 'https://genius.com{api_path}/apple_music_player'

Definition at line 27 of file genius.py.

◆ page_size

int searx.engines.genius.page_size = 5

Definition at line 23 of file genius.py.

◆ paging

bool searx.engines.genius.paging = True

Definition at line 22 of file genius.py.

◆ parse

dict searx.engines.genius.parse = {'lyric': parse_lyric, 'song': parse_lyric, 'artist': parse_artist, 'album': parse_album}

Definition at line 92 of file genius.py.

◆ search_url

str searx.engines.genius.search_url = url + 'search/{index}?{query}&page={pageno}&per_page={page_size}'

Definition at line 26 of file genius.py.

◆ url

str searx.engines.genius.url = 'https://genius.com/api/'

Definition at line 25 of file genius.py.