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

Functions

 request (query, params)
 
 response (resp)
 

Variables

dict about
 
list categories = ['music']
 
bool paging = True
 
str base_url = "https://bandcamp.com/"
 
str search_string = 'search?{query}&page={page}'
 
str iframe_src = "https://bandcamp.com/EmbeddedPlayer/{type}={result_id}/size=large/bgcol=000/linkcol=fff/artwork=small"
 

Detailed Description

Bandcamp (Music)

@website     https://bandcamp.com/
@provide-api no
@results     HTML
@parse       url, title, content, publishedDate, iframe_src, thumbnail

Function Documentation

◆ request()

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

Definition at line 39 of file bandcamp.py.

39def request(query, params):
40
41 search_path = search_string.format(query=urlencode({'q': query}), page=params['pageno'])
42 params['url'] = base_url + search_path
43 return params
44
45

◆ response()

searx.engines.bandcamp.response ( resp)

Definition at line 46 of file bandcamp.py.

46def response(resp):
47
48 results = []
49 dom = html.fromstring(resp.text)
50
51 for result in eval_xpath_list(dom, '//li[contains(@class, "searchresult")]'):
52
53 link = eval_xpath_getindex(result, './/div[@class="itemurl"]/a', 0, default=None)
54 if link is None:
55 continue
56
57 title = result.xpath('.//div[@class="heading"]/a/text()')
58 content = result.xpath('.//div[@class="subhead"]/text()')
59 new_result = {
60 "url": extract_text(link),
61 "title": extract_text(title),
62 "content": extract_text(content),
63 }
64
65 date = eval_xpath_getindex(result, '//div[@class="released"]/text()', 0, default=None)
66 if date:
67 new_result["publishedDate"] = dateparse(date.replace("released ", ""))
68
69 thumbnail = result.xpath('.//div[@class="art"]/img/@src')
70 if thumbnail:
71 new_result['thumbnail'] = thumbnail[0]
72
73 result_id = parse_qs(urlparse(link.get('href')).query)["search_item_id"][0]
74 itemtype = extract_text(result.xpath('.//div[@class="itemtype"]')).lower()
75 if "album" == itemtype:
76 new_result["iframe_src"] = iframe_src.format(type='album', result_id=result_id)
77 elif "track" == itemtype:
78 new_result["iframe_src"] = iframe_src.format(type='track', result_id=result_id)
79
80 results.append(new_result)
81 return results

Variable Documentation

◆ about

dict searx.engines.bandcamp.about
Initial value:
1= {
2 "website": 'https://bandcamp.com/',
3 "wikidata_id": 'Q545966',
4 "official_api_documentation": 'https://bandcamp.com/developer',
5 "use_official_api": False,
6 "require_api_key": False,
7 "results": 'HTML',
8}

Definition at line 22 of file bandcamp.py.

◆ base_url

str searx.engines.bandcamp.base_url = "https://bandcamp.com/"

Definition at line 34 of file bandcamp.py.

◆ categories

list searx.engines.bandcamp.categories = ['music']

Definition at line 31 of file bandcamp.py.

◆ iframe_src

str searx.engines.bandcamp.iframe_src = "https://bandcamp.com/EmbeddedPlayer/{type}={result_id}/size=large/bgcol=000/linkcol=fff/artwork=small"

Definition at line 36 of file bandcamp.py.

◆ paging

bool searx.engines.bandcamp.paging = True

Definition at line 32 of file bandcamp.py.

◆ search_string

str searx.engines.bandcamp.search_string = 'search?{query}&page={page}'

Definition at line 35 of file bandcamp.py.