Artistas en entidades relacionadas
This commit is contained in:
@@ -92,7 +92,7 @@ def _get(entity_type, mbid, includes=None):
|
||||
return _do_request(f'{_mb_host}/{entity_type}/{mbid}?inc={_includes}')
|
||||
|
||||
|
||||
def _search(entity_type, query, limit=25, offset=0):
|
||||
def _search(entity_type, query, includes=None, limit=25, offset=0):
|
||||
"""Does a search of an entity to musicbrainz
|
||||
|
||||
:param str entity_type: Type of the entity (artist, release, recording...)
|
||||
@@ -104,14 +104,17 @@ def _search(entity_type, query, limit=25, offset=0):
|
||||
:rtype: dict
|
||||
"""
|
||||
|
||||
_log.info(f'Searching {entity_type} with query "{query}" at offset {offset} with limit of {limit}')
|
||||
_log.info(f'Searching {entity_type} with query "{query}" at offset {offset} with limit of {limit} with includes {includes}')
|
||||
|
||||
if limit >= 0 and offset >= 0:
|
||||
_query = urlencode({'query': query, 'limit': limit, 'offset': offset})
|
||||
_query = {'query': query, 'limit': limit, 'offset': offset}
|
||||
else:
|
||||
_query = urlencode({'query': query})
|
||||
_query = {'query': query}
|
||||
|
||||
return _do_request(f'{_mb_host}/{entity_type}/?{_query}')
|
||||
if includes is not None:
|
||||
_query['inc'] = '+'.join(includes)
|
||||
|
||||
return _do_request(f'{_mb_host}/{entity_type}/?{urlencode(_query)}')
|
||||
|
||||
|
||||
def _browse(entity_type, params, includes=None, limit=25, offset=0):
|
||||
@@ -166,9 +169,6 @@ def get_artist_by_mbid(mbid, includes=None):
|
||||
:param list includes: List of include parameters
|
||||
:return: dictionary with the response
|
||||
"""
|
||||
if includes is None:
|
||||
includes = []
|
||||
|
||||
return _get('artist', mbid, includes)
|
||||
|
||||
|
||||
@@ -180,9 +180,6 @@ def get_release_group_by_mbid(mbid, includes=None):
|
||||
:param list includes: List of include parameters
|
||||
:return: dictionary with the response
|
||||
"""
|
||||
if includes is None:
|
||||
includes = []
|
||||
|
||||
return _get('release-group', mbid, includes)
|
||||
|
||||
|
||||
@@ -194,9 +191,6 @@ def get_release_by_mbid(mbid, includes=None):
|
||||
:param list includes: List of include parameters
|
||||
:return: dictionary with the response
|
||||
"""
|
||||
if includes is None:
|
||||
includes = []
|
||||
|
||||
return _get('release', mbid, includes)
|
||||
|
||||
|
||||
@@ -208,58 +202,60 @@ def get_recording_by_mbid(mbid, includes=None):
|
||||
:param list includes: List of include parameters
|
||||
:return: dictionary with the response
|
||||
"""
|
||||
if includes is None:
|
||||
includes = []
|
||||
|
||||
return _get('recording', mbid, includes)
|
||||
|
||||
|
||||
@cache
|
||||
def search_artist(query, limit=25, offset=0):
|
||||
def search_artist(query, includes=None, limit=25, offset=0):
|
||||
"""Search an artist by a query string
|
||||
|
||||
:param str query: Query string
|
||||
:param list includes: List of include parameters
|
||||
:param int limit: Limit of the search, defaults to 25 and has a max of 100
|
||||
:param int offset: Offset of the search for paging purposes
|
||||
:return: dictionary with the response
|
||||
"""
|
||||
return _search('artist', query, limit, offset)
|
||||
return _search('artist', query, includes, limit, offset)
|
||||
|
||||
|
||||
@cache
|
||||
def search_release(query, limit=25, offset=0):
|
||||
def search_release(query, includes=None, limit=25, offset=0):
|
||||
"""Search a release by a query string
|
||||
|
||||
:param str query: Query string
|
||||
:param list includes: List of include parameters
|
||||
:param int limit: Limit of the search, defaults to 25 and has a max of 100
|
||||
:param int offset: Offset of the search for paging purposes
|
||||
:return: dictionary with the response
|
||||
"""
|
||||
return _search('release', query, limit, offset)
|
||||
return _search('release', query, includes, limit, offset)
|
||||
|
||||
|
||||
@cache
|
||||
def search_release_group(query, limit=25, offset=0):
|
||||
def search_release_group(query, includes=None, limit=25, offset=0):
|
||||
"""Search a release group by a query string
|
||||
|
||||
|
||||
:param str query: Query string
|
||||
:param list includes: List of include parameters
|
||||
:param int limit: Limit of the search, defaults to 25 and has a max of 100
|
||||
:param int offset: Offset of the search for paging purposes
|
||||
:return: dictionary with the response
|
||||
"""
|
||||
return _search('release-group', query, limit, offset)
|
||||
|
||||
return _search('release-group', query, includes, limit, offset)
|
||||
|
||||
|
||||
@cache
|
||||
def search_recording(query, limit=25, offset=0):
|
||||
def search_recording(query, includes=None, limit=25, offset=0):
|
||||
"""Search a recording by a query string
|
||||
|
||||
:param str query: Query string
|
||||
:param list includes: List of include parameters
|
||||
:param int limit: Limit of the search, defaults to 25 and has a max of 100
|
||||
:param int offset: Offset of the search for paging purposes
|
||||
:return: dictionary with the response
|
||||
"""
|
||||
return _search('recording', query, limit, offset)
|
||||
return _search('recording', query, includes,limit, offset)
|
||||
|
||||
|
||||
@cache
|
||||
@@ -272,9 +268,6 @@ def browse_artists(params, includes=None, limit=25, offset=0):
|
||||
:param int offset: Offset of the search for paging purposes
|
||||
:return: dictionary with the response
|
||||
"""
|
||||
if includes is None:
|
||||
includes = []
|
||||
|
||||
return _browse('artist', params, includes, limit, offset)
|
||||
|
||||
|
||||
@@ -288,9 +281,6 @@ def browse_recordings(params, includes=None, limit=25, offset=0):
|
||||
:param int offset: Offset of the search for paging purposes
|
||||
:return: dictionary with the response
|
||||
"""
|
||||
if includes is None:
|
||||
includes = []
|
||||
|
||||
return _browse('recording', params, includes, limit, offset)
|
||||
|
||||
|
||||
@@ -304,9 +294,6 @@ def browse_releases(params, includes=None, limit=25, offset=0):
|
||||
:param int offset: Offset of the search for paging purposes
|
||||
:return: dictionary with the response
|
||||
"""
|
||||
if includes is None:
|
||||
includes = []
|
||||
|
||||
return _browse('release', params, includes, limit, offset)
|
||||
|
||||
|
||||
@@ -320,9 +307,6 @@ def browse_release_groups(params, includes=None, limit=25, offset=0):
|
||||
:param int offset: Offset of the search for paging purposes
|
||||
:return: dictionary with the response
|
||||
"""
|
||||
if includes is None:
|
||||
includes = []
|
||||
|
||||
return _browse('release-group', params, includes, limit, offset)
|
||||
|
||||
|
||||
@@ -346,4 +330,3 @@ def get_release_group_cover_art(mbid):
|
||||
:return: dictionary with the response
|
||||
"""
|
||||
return _ca('release-group', mbid)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user