def retrievePlayListSongs(self): songs = [] songsIDs = [] sql = "SELECT song_id from playlists_songs where playlist_id = '" + str( self.playlist_id) + "'" cur.execute(sql) for row in cur: sid = row[0] songsIDs.append(sid) for sid in songsIDs: sql = "SELECT * from songs where song_id = '" + str(sid) + "'" cur.execute(sql) for row in cur: s = Song() s.song_id = row[0] s.name = row[1] s.lyrics = row[2] s.length = row[3] s.genres = row[4] s.release_date = row[5] s.album_id = row[6] s.band_id = row[7] s.featured_artists = row[8] songs.append(s) return songs
def retrieveSongs(self): sql = "SELECT * from songs" cur.execute(sql) self.myLibrary = [] for row in cur: s = Song() s.song_id = row[0] s.name = row[1] s.lyrics = row[2] s.length = row[3] s.genres = row[4] s.release_date = row[5] s.album_id = row[6] s.band_id = row[7] s.featured_artists = row[8] self.myLibrary.append(s)
def retrieveArtistSongs(self): songs = [] bandIDs = self.retrieveBandsIDs() for bid in bandIDs: sql = "SELECT * from songs where band_id = '" + str(bid) + "'" cur.execute(sql) for row in cur: s = Song() s.song_id = row[0] s.name = row[1] s.lyrics = row[2] s.length = row[3] s.genres = row[4] s.release_date = row[5] s.album_id = row[6] s.band_id = row[7] s.featured_artists = row[8] songs.append(s) return songs
MP.viewBands() bandNum = int(input("band number:"))-1 s.band_id = MP.myBands[bandNum].band_id #get albums of this band albumList = MP.myBands[bandNum].retrieveBandAlbums() alb = -1 if len(albumList) == 0: print("NO Albums for this band song is added single") else: print("List of Albums for this band:") for i in range(0,len(albumList)): print(i + 1, ".", albumList[i].title, "\ttracks:" , len(albumList[i].retrieveAlbumSongs())) alb = int(input("Enter album number or 0 if single: "))-1 if alb == -1 : s.album_id = 0 else: s.album_id = albumList[alb].album_id s.addSong() # delete song elif choice4 == "2": sID = int(input("Enter song # to delete"))-1 MP.myLibrary[sID].deleteSong(MP.myLibrary[sID].song_id) #play song elif choice4 == "3": sID = int(input("Enter song # to play ")) MP.myLibrary[sID-1].playSong() #view song elif choice4 == "4": sID = int(input("Enter song # to View:")) MP.myLibrary[sID - 1].viewSong()