mirror of
https://gitlab.com/RemixDev/deezer-py.git
synced 2025-02-17 18:50:07 +00:00
Added clean_search_query and gw.search
This commit is contained in:
parent
1856846992
commit
605efe5e2d
|
@ -4,7 +4,7 @@ from deezer.gw import GW
|
||||||
from deezer.api import API
|
from deezer.api import API
|
||||||
import json
|
import json
|
||||||
|
|
||||||
__version__ = "0.0.3"
|
__version__ = "0.0.4"
|
||||||
|
|
||||||
class TrackFormats():
|
class TrackFormats():
|
||||||
"""Number associtation for formats"""
|
"""Number associtation for formats"""
|
||||||
|
|
11
deezer/gw.py
11
deezer/gw.py
|
@ -1,6 +1,7 @@
|
||||||
import eventlet
|
import eventlet
|
||||||
requests = eventlet.import_patched('requests')
|
requests = eventlet.import_patched('requests')
|
||||||
|
|
||||||
|
import json
|
||||||
from deezer.utils import map_artist_album
|
from deezer.utils import map_artist_album
|
||||||
|
|
||||||
class LyricsStatus():
|
class LyricsStatus():
|
||||||
|
@ -213,6 +214,16 @@ class GW:
|
||||||
}
|
}
|
||||||
return self.api_call('page.get', params=params)
|
return self.api_call('page.get', params=params)
|
||||||
|
|
||||||
|
def search(self, query, index=0, limit=10, suggest=True, artist_suggest=True, top_tracks=True):
|
||||||
|
return self.api_call('deezer.pageSearch', {
|
||||||
|
"query": query,
|
||||||
|
"start": index,
|
||||||
|
"nb": limit,
|
||||||
|
"suggest": suggest,
|
||||||
|
"artist_suggest": artist_suggest,
|
||||||
|
"top_tracks": top_tracks
|
||||||
|
})
|
||||||
|
|
||||||
# Extra calls
|
# Extra calls
|
||||||
|
|
||||||
def get_artist_discography_tabs(self, art_id, limit=100):
|
def get_artist_discography_tabs(self, art_id, limit=100):
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import re
|
||||||
|
|
||||||
RELEASE_TYPE = {0:"single", 1:"album", 2:"compile", 3:"ep", 4:"bundle"}
|
RELEASE_TYPE = {0:"single", 1:"album", 2:"compile", 3:"ep", 4:"bundle"}
|
||||||
|
|
||||||
# maps gw-light api user/tracks to standard api
|
# maps gw-light api user/tracks to standard api
|
||||||
|
@ -185,3 +187,13 @@ def map_playlist(playlist):
|
||||||
},
|
},
|
||||||
'type': "playlist"
|
'type': "playlist"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Cleanup terms that can hurt search results
|
||||||
|
def clean_search_query(term):
|
||||||
|
term = str(term)
|
||||||
|
term = re.sub(r' feat[\.]? ', " ", term)
|
||||||
|
term = re.sub(r' ft[\.]? ', " ", term)
|
||||||
|
term = re.sub(r'\(feat[\.]? ', " ", term)
|
||||||
|
term = re.sub(r'\(ft[\.]? ', " ", term)
|
||||||
|
term = term.replace('&', " ").replace('–', "-").replace('—', "-")
|
||||||
|
return term
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -7,7 +7,7 @@ README = (HERE / "README.md").read_text()
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="deezer-py",
|
name="deezer-py",
|
||||||
version="0.0.3",
|
version="0.0.4",
|
||||||
description="A wrapper for all Deezer's APIs",
|
description="A wrapper for all Deezer's APIs",
|
||||||
long_description=README,
|
long_description=README,
|
||||||
long_description_content_type="text/markdown",
|
long_description_content_type="text/markdown",
|
||||||
|
|
Loading…
Reference in a new issue