cleaned up some code
This commit is contained in:
parent
3601ab32ab
commit
4079b2f380
|
@ -168,8 +168,7 @@ class Deezer:
|
||||||
return tracks_array
|
return tracks_array
|
||||||
|
|
||||||
def get_album_gw(self, alb_id):
|
def get_album_gw(self, alb_id):
|
||||||
body = self.gw_api_call('album.getData', {'alb_id': alb_id})
|
return self.gw_api_call('album.getData', {'alb_id': alb_id})['results']
|
||||||
return body['results']
|
|
||||||
|
|
||||||
def get_album_tracks_gw(self, alb_id):
|
def get_album_tracks_gw(self, alb_id):
|
||||||
tracks_array = []
|
tracks_array = []
|
||||||
|
@ -181,12 +180,10 @@ class Deezer:
|
||||||
return tracks_array
|
return tracks_array
|
||||||
|
|
||||||
def get_artist_gw(self, art_id):
|
def get_artist_gw(self, art_id):
|
||||||
body = self.gw_api_call('deezer.pageArtist', {'art_id': art_id})
|
return self.gw_api_call('deezer.pageArtist', {'art_id': art_id})
|
||||||
return body
|
|
||||||
|
|
||||||
def get_playlist_gw(self, playlist_id):
|
def get_playlist_gw(self, playlist_id):
|
||||||
body = self.gw_api_call('deezer.pagePlaylist', {'playlist_id': playlist_id})
|
return self.gw_api_call('deezer.pagePlaylist', {'playlist_id': playlist_id})
|
||||||
return body
|
|
||||||
|
|
||||||
def get_playlist_tracks_gw(self, playlist_id):
|
def get_playlist_tracks_gw(self, playlist_id):
|
||||||
tracks_array = []
|
tracks_array = []
|
||||||
|
@ -205,54 +202,43 @@ class Deezer:
|
||||||
return tracks_array
|
return tracks_array
|
||||||
|
|
||||||
def get_lyrics_gw(self, sng_id):
|
def get_lyrics_gw(self, sng_id):
|
||||||
body = self.gw_api_call('song.getLyrics', {'sng_id': sng_id})
|
return self.gw_api_call('song.getLyrics', {'sng_id': sng_id})["results"]
|
||||||
return body["results"]
|
|
||||||
|
|
||||||
def get_user_playlist(self, user_id):
|
def get_user_playlist(self, user_id):
|
||||||
body = self.api_call('user/' + str(user_id) + '/playlists', {'limit': -1})
|
return self.api_call('user/' + str(user_id) + '/playlists', {'limit': -1})
|
||||||
return body
|
|
||||||
|
|
||||||
def get_track(self, user_id):
|
def get_track(self, user_id):
|
||||||
body = self.api_call('track/' + str(user_id))
|
return self.api_call('track/' + str(user_id))
|
||||||
return body
|
|
||||||
|
|
||||||
def get_track_by_ISRC(self, isrc):
|
def get_track_by_ISRC(self, isrc):
|
||||||
body = self.api_call('track/isrc:' + isrc)
|
return self.api_call('track/isrc:' + isrc)
|
||||||
return body
|
|
||||||
|
|
||||||
def get_charts_top_country(self):
|
def get_charts_top_country(self):
|
||||||
return self.get_user_playlist('637006841')
|
return self.get_user_playlist('637006841')
|
||||||
|
|
||||||
def get_playlist(self, playlist_id):
|
def get_playlist(self, playlist_id):
|
||||||
body = self.api_call('playlist/' + str(playlist_id))
|
return self.api_call('playlist/' + str(playlist_id))
|
||||||
return body
|
|
||||||
|
|
||||||
def get_playlist_tracks(self, playlist_id):
|
def get_playlist_tracks(self, playlist_id):
|
||||||
body = self.api_call('playlist/' + str(playlist_id) + '/tracks', {'limit': -1})
|
return self.api_call('playlist/' + str(playlist_id) + '/tracks', {'limit': -1})
|
||||||
return body
|
|
||||||
|
|
||||||
def get_album(self, album_id):
|
def get_album(self, album_id):
|
||||||
body = self.api_call('album/' + str(album_id))
|
return self.api_call('album/' + str(album_id))
|
||||||
return body
|
|
||||||
|
|
||||||
def get_album_by_UPC(self, upc):
|
def get_album_by_UPC(self, upc):
|
||||||
body = self.api_call('album/upc:' + str(upc))
|
return self.api_call('album/upc:' + str(upc))
|
||||||
|
|
||||||
def get_album_tracks(self, album_id):
|
def get_album_tracks(self, album_id):
|
||||||
body = self.api_call('album/' + str(album_id) + '/tracks', {'limit': -1})
|
return self.api_call('album/' + str(album_id) + '/tracks', {'limit': -1})
|
||||||
return body
|
|
||||||
|
|
||||||
def get_artist(self, artist_id):
|
def get_artist(self, artist_id):
|
||||||
body = self.api_call('artist/' + str(artist_id))
|
return self.api_call('artist/' + str(artist_id))
|
||||||
return body
|
|
||||||
|
|
||||||
def get_artist_albums(self, artist_id):
|
def get_artist_albums(self, artist_id):
|
||||||
body = self.api_call('artist/' + str(artist_id) + '/albums', {'limit': -1})
|
return self.api_call('artist/' + str(artist_id) + '/albums', {'limit': -1})
|
||||||
return body
|
|
||||||
|
|
||||||
def search(self, term, search_type, limit=30):
|
def search(self, term, search_type, limit=30):
|
||||||
body = self.api_call('search/' + search_type, {'q': term, 'limit': limit})
|
return self.api_call('search/' + search_type, {'q': term, 'limit': limit})
|
||||||
return body
|
|
||||||
|
|
||||||
def decrypt_track(self, track_id, input, output):
|
def decrypt_track(self, track_id, input, output):
|
||||||
response = open(input, 'rb')
|
response = open(input, 'rb')
|
||||||
|
@ -286,7 +272,7 @@ class Deezer:
|
||||||
|
|
||||||
def _ecb_crypt(self, key, data):
|
def _ecb_crypt(self, key, data):
|
||||||
res = b''
|
res = b''
|
||||||
for x in range(int(len(data) / 16)):
|
for _ in range(int(len(data) / 16)):
|
||||||
res += binascii.hexlify(AES.new(key, AES.MODE_ECB).encrypt(data[:16]))
|
res += binascii.hexlify(AES.new(key, AES.MODE_ECB).encrypt(data[:16]))
|
||||||
data = data[16:]
|
data = data[16:]
|
||||||
return res
|
return res
|
||||||
|
|
|
@ -90,7 +90,7 @@ def generateFilepath(track, trackAPI, settings):
|
||||||
(not 'SINGLE_TRACK' in trackAPI or ('SINGLE_TRACK' in trackAPI and settings['createSingleFolder'])) and
|
(not 'SINGLE_TRACK' in trackAPI or ('SINGLE_TRACK' in trackAPI and settings['createSingleFolder'])) and
|
||||||
(not '_EXTRA_PLAYLIST' in trackAPI or ('_EXTRA_PLAYLIST' in trackAPI and settings['savePlaylistAsCompilation']) or ('_EXTRA_PLAYLIST' in trackAPI and settings['createStructurePlaylist']))
|
(not '_EXTRA_PLAYLIST' in trackAPI or ('_EXTRA_PLAYLIST' in trackAPI and settings['savePlaylistAsCompilation']) or ('_EXTRA_PLAYLIST' in trackAPI and settings['createStructurePlaylist']))
|
||||||
)):
|
)):
|
||||||
filepath += 'CD'+str(track['discNumber']) + pathSep
|
filepath += 'CD' + str(track['discNumber']) + pathSep
|
||||||
|
|
||||||
return (filepath, artistPath, coverPath, extrasPath)
|
return (filepath, artistPath, coverPath, extrasPath)
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ def settingsRegexAlbum(foldername, album, settings):
|
||||||
foldername = foldername.replace("%type%", fixName(album['recordType'], settings['illegalCharacterReplacer']))
|
foldername = foldername.replace("%type%", fixName(album['recordType'], settings['illegalCharacterReplacer']))
|
||||||
foldername = foldername.replace("%upc%", album['barcode'])
|
foldername = foldername.replace("%upc%", album['barcode'])
|
||||||
foldername = foldername.replace("%label%", fixName(album['label'], settings['illegalCharacterReplacer']))
|
foldername = foldername.replace("%label%", fixName(album['label'], settings['illegalCharacterReplacer']))
|
||||||
if len(album['genre'])>0:
|
if len(album['genre']) > 0:
|
||||||
foldername = foldername.replace("%genre%", fixName(album['genre'][0], settings['illegalCharacterReplacer']))
|
foldername = foldername.replace("%genre%", fixName(album['genre'][0], settings['illegalCharacterReplacer']))
|
||||||
else:
|
else:
|
||||||
foldername = foldername.replace("%genre%", "Unknown")
|
foldername = foldername.replace("%genre%", "Unknown")
|
||||||
|
|
Loading…
Reference in New Issue