def getSongs(self): if self.length <= 0 or len(self.songs) <= 0: self.getLength() if len(self.songs) > 0: return iterations = math.ceil(self.length / 100) url = f"playlists/{self.playlistID}/tracks" tmp = [] for i in range(iterations): selector = { "fields": "items(track(name%2Cartists%2Calbum%2Cid))", "offset": i * 100, "limit": 100 } if self.spotify.query(url, payload=selector): for item in self.spotify.data["items"]: tmp.append(Track(item["track"])) self.songs = tmp return self.songs
from Playlist import PlaylistAPI from Util import better_mean, list2json, json2obj import statistics import json import time from Models import Track from Genius import Genius beg = time.time() token = "BQBPEX_Zo3Eu1sGfSOe23PGUxt9bGkbOLxH95mrjcyc3Cj8fwqEE4EuGVi3G8Neo7mOEXCLIeNCOQXm0MPAIvYm6YU7UzSJqiF6XYzlgSGbkjhOl1NtkfmqWA7cum2CnYOeth-P3_9RbBOORhQxucYIeI7BT-Z3jsDY5qiqApRyICifRzuTYg7hSZqIoR2ssYUxKJuITYmBUzJCB2S4MyLgQbh4swmaNS6MO69_tjbgFRWUTZOIVGSp4c858pJGG5cmuHeFeH-_dqV85Zkht" playlist = PlaylistAPI(playlistID="37i9dQZF1DZ06evO2dYtbO", token=token) try: with open("playlist_dump_features.json", "r") as f: playlist.songs = [Track(t) for t in json2obj(f.read())] except: print("File not loaded") pass print("Post LOAD:", time.time() - beg) playlist.getSongs() print("Post getSongs():", time.time() - beg) '''spot = Spotify(token) if not spot.query("me/playlists"): print(spot.status) exit(1) r = spot.data