mirror of
https://gitlab.com/RemixDev/deezer-py.git
synced 2025-01-29 17:18:28 +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
|
||||
import json
|
||||
|
||||
__version__ = "0.0.3"
|
||||
__version__ = "0.0.4"
|
||||
|
||||
class TrackFormats():
|
||||
"""Number associtation for formats"""
|
||||
|
|
11
deezer/gw.py
11
deezer/gw.py
|
@ -1,6 +1,7 @@
|
|||
import eventlet
|
||||
requests = eventlet.import_patched('requests')
|
||||
|
||||
import json
|
||||
from deezer.utils import map_artist_album
|
||||
|
||||
class LyricsStatus():
|
||||
|
@ -213,6 +214,16 @@ class GW:
|
|||
}
|
||||
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
|
||||
|
||||
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"}
|
||||
|
||||
# maps gw-light api user/tracks to standard api
|
||||
|
@ -185,3 +187,13 @@ def map_playlist(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
|
||||
|
|
Loading…
Reference in a new issue