.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
deezer.py
Go to the documentation of this file.
1
# SPDX-License-Identifier: AGPL-3.0-or-later
2
"""
3
Deezer (Music)
4
"""
5
6
from
json
import
loads
7
from
urllib.parse
import
urlencode
8
9
# about
10
about = {
11
"website"
:
'https://deezer.com'
,
12
"wikidata_id"
:
'Q602243'
,
13
"official_api_documentation"
:
'https://developers.deezer.com/'
,
14
"use_official_api"
:
True
,
15
"require_api_key"
:
False
,
16
"results"
:
'JSON'
,
17
}
18
19
# engine dependent config
20
categories = [
'music'
]
21
paging =
True
22
23
# search-url
24
url =
'https://api.deezer.com/'
25
search_url = url +
'search?{query}&index={offset}'
26
iframe_src =
"https://www.deezer.com/plugins/player?type=tracks&id={audioid}"
27
28
29
# do search-request
30
def
request
(query, params):
31
offset = (params[
'pageno'
] - 1) * 25
32
33
params[
'url'
] = search_url.format(query=urlencode({
'q'
: query}), offset=offset)
34
35
return
params
36
37
38
# get response from search-request
39
def
response
(resp):
40
results = []
41
42
search_res = loads(resp.text)
43
44
# parse results
45
for
result
in
search_res.get(
'data'
, []):
46
if
result[
'type'
] ==
'track'
:
47
title = result[
'title'
]
48
url = result[
'link'
]
# pylint: disable=redefined-outer-name
49
50
if
url.startswith(
'http://'
):
51
url =
'https'
+ url[4:]
52
53
content =
'{} - {} - {}'
.
format
(result[
'artist'
][
'name'
], result[
'album'
][
'title'
], result[
'title'
])
54
55
# append result
56
results.append(
57
{
'url'
: url,
'title'
: title,
'iframe_src'
: iframe_src.format(audioid=result[
'id'
]),
'content'
: content}
58
)
59
60
# return results
61
return
results
searx.engines.deezer.response
response(resp)
Definition
deezer.py:39
searx.engines.deezer.request
request(query, params)
Definition
deezer.py:30
searx.format
format
Definition
__init__.py:94
searxng
searx
engines
deezer.py
Generated on Sat Nov 16 2024 00:10:57 for .oO SearXNG Developer Documentation Oo. by
1.12.0