def getArtistAlbums(self, id, includeEP = False): albums = [] msg, data = self.__getItems__('artists/' + str(id) + "/albums") if msg is not None: return msg, None for item in data: albums.append(dictToModel(item, Album())) if includeEP == False: return None, albums msg, data = self.__getItems__('artists/' + str(id) + "/albums", {"filter": "EPSANDSINGLES"}) if msg is not None: return msg, None for item in data: albums.append(dictToModel(item, Album())) return None, albums
def getVideoStreamUrl(self, id, quality: VideoQuality): paras = { "videoquality": "HIGH", "playbackmode": "STREAM", "assetpresentation": "FULL" } msg, data = self.__get__( 'videos/' + str(id) + "/playbackinfopostpaywall", paras) if msg is not None: return msg, None resp = dictToModel(data, __StreamRespon__()) if "vnd.tidal.emu" in resp.manifestMimeType: manifest = json.loads( base64.b64decode(resp.manifest).decode('utf-8')) array = self.__getResolutionList__(manifest['urls'][0]) icmp = int(quality.value) index = 0 for item in array: if icmp >= int(item.resolutions[1]): break index += 1 if index >= len(array): index = len(array) - 1 return "", array[index] return "", None
def read(): txt = getFileContent('./usersettings.json', True) if txt == "": return UserSettings() txt = __decode__(txt) data = json.loads(txt) ret = dictToModel(data, UserSettings()) return ret
def getItems(self, id, type: Type): if type == Type.Playlist: msg, data = self.__getItems__('playlists/' + str(id) + "/items") elif type == Type.Album: msg, data = self.__getItems__('albums/' + str(id) + "/items") else: return "invalid Type!", None, None if msg is not None: return msg, None, None tracks = [] videos = [] for item in data: if item['type'] == 'track': tracks.append(dictToModel(item['item'], Track())) else: videos.append(dictToModel(item['item'], Video())) return msg, tracks, videos
def read(): txt = getFileContent('./settings.json') if txt == "": return Settings() data = json.loads(txt) ret = dictToModel(data, Settings()) ret.audioQuality = Settings.getAudioQuality(ret.audioQuality) ret.videoQuality = Settings.getVideoQuality(ret.videoQuality) return ret
def read(): path = TokenSettings.__getFilePath__() txt = getContent(path) if txt == "": return TokenSettings() txt = __decode__(txt) data = json.loads(txt) ret = dictToModel(data, TokenSettings()) return ret
def read(): txt = getFileContent('./settings.json') if txt == "": return Settings() data = json.loads(txt) ret = dictToModel(data, Settings()) ret.audioQuality = Settings.getAudioQuality(ret.audioQuality) ret.videoQuality = Settings.getVideoQuality(ret.videoQuality) ret.usePlaylistFolder = ret.usePlaylistFolder == True or ret.usePlaylistFolder is None ret.multiThreadDownload = ret.multiThreadDownload == True or ret.multiThreadDownload is None return ret
def read(): txt = "" if "XDG_CONFIG_HOME" in os.environ: txt = getFileContent( os.environ['XDG_CONFIG_HOME'] + '/.tidal-dl.token.json', True) else: txt = getFileContent(os.environ['HOME'] + '/.tidal-dl.token.json', True) if txt == "": return TokenSettings() txt = __decode__(txt) data = json.loads(txt) ret = dictToModel(data, TokenSettings()) return ret
def read(): path = Settings.__getFilePath__() txt = getContent(path) if txt == "": return Settings() data = json.loads(txt) ret = dictToModel(data, Settings()) ret.audioQuality = Settings.getAudioQuality(ret.audioQuality) ret.videoQuality = Settings.getVideoQuality(ret.videoQuality) ret.usePlaylistFolder = ret.usePlaylistFolder == True or ret.usePlaylistFolder is None ret.multiThreadDownload = ret.multiThreadDownload == True or ret.multiThreadDownload is None if ret.albumFolderFormat is None: ret.albumFolderFormat = Settings.getDefaultAlbumFolderFormat() if ret.trackFileFormat is None: ret.trackFileFormat = Settings.getDefaultTrackFileFormat() return ret
def getStreamUrl(self, id, quality: AudioQuality): squality = self.__getQualityString__(quality) paras = {"audioquality": squality, "playbackmode": "STREAM", "assetpresentation": "FULL"} msg, data = self.__get__('tracks/' + str(id) + "/playbackinfopostpaywall", paras) if msg is not None: return msg, None resp = dictToModel(data, __StreamRespon__()) if "vnd.tidal.bt" in resp.manifestMimeType: manifest = json.loads(base64.b64decode(resp.manifest).decode('utf-8')) ret = StreamUrl() ret.trackid = resp.trackid ret.soundQuality = resp.audioQuality ret.codec = manifest['codecs'] ret.encryptionKey = manifest['keyId'] if 'keyId' in manifest else "" ret.url = manifest['urls'][0] return "", ret return "Can't get the streamUrl, type is " + resp.manifestMimeType, None
def read(): txt = "" if "XDG_CONFIG_HOME" in os.environ: txt = getFileContent( os.environ['XDG_CONFIG_HOME'] + '/.tidal-dl.json', True) else: txt = getFileContent(os.environ['HOME'] + '/.tidal-dl.json', True) if txt == "": return Settings() data = json.loads(txt) ret = dictToModel(data, Settings()) ret.audioQuality = Settings.getAudioQuality(ret.audioQuality) ret.videoQuality = Settings.getVideoQuality(ret.videoQuality) ret.usePlaylistFolder = ret.usePlaylistFolder == True or ret.usePlaylistFolder is None ret.multiThreadDownload = ret.multiThreadDownload == True or ret.multiThreadDownload is None if ret.albumFolderFormat is None: ret.albumFolderFormat = Settings.getDefualtAlbumFolderFormat() if ret.trackFileFormat is None: ret.trackFileFormat = Settings.getDefualtTrackFileFormat() return ret
def search(self, text: str, type: Type, offset: int, limit: int): typeStr = "ARTISTS,ALBUMS,TRACKS,VIDEOS,PLAYLISTS" if type == Type.Album: typeStr = "ALBUMS" if type == Type.Artist: typeStr = "ARTISTS" if type == Type.Track: typeStr = "TRACKS" if type == Type.Video: typeStr = "VIDEOS" if type == Type.Playlist: typeStr = "PLAYLISTS" params = { "query": text, "offset": offset, "limit": limit, "types": typeStr } msg, data = self.__get__('search', params=params) return msg, dictToModel(data, SearchResult())
def getVideo(self, id): msg, data = self.__get__('videos/' + str(id)) return msg, dictToModel(data, Video())
def getTrack(self, id): msg, data = self.__get__('tracks/' + str(id)) return msg, dictToModel(data, Track())
def getArtist(self, id): msg, data = self.__get__('artists/' + str(id)) return msg, dictToModel(data, Artist())
def getPlaylist(self, id): msg, data = self.__get__('playlists/' + str(id)) return msg, dictToModel(data, Playlist())
def getAlbum(self, id): msg, data = self.__get__('albums/' + str(id)) return msg, dictToModel(data, Album())
def getLyrics(self, id): msg, data = self.__get__('tracks/' + str(id) + "/lyrics", urlpre='https://listen.tidal.com/v1/') return msg, dictToModel(data, Lyrics())