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
break if choice == "4": while True: choice4 = input("1. add new Song 2. Delete Song 3. Play Song 4. " + "View Song 5.View All Songs 6.play certain genre 7.back :\n") #add song if choice4 == "1": s = Song() s.name = input("name:") s.genres = input("genres: ") s.lyrics = input("lyrics: ") s.length = input("length: ") s.release_date = input("release date: ") s.featured_artists = input("featured artists:") MP.retrieveBands() 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