def compareUsersTopArtists(user, otherUser, periodInput): topArtistsListUser = lastfm_network.get_user(user).get_top_artists(period=periodInput, limit = 100) topArtistsListOtherUser = lastfm_network.get_user(otherUser).get_top_artists(period=periodInput, limit= 100) formattedArtistListUser = [] for artist in topArtistsListUser: formattedArtistListUser.append(artist.item) formattedArtistListOtherUser = [] for artist in topArtistsListOtherUser: formattedArtistListOtherUser.append(artist.item) commonTopArtistsList = list(set.intersection(set(formattedArtistListUser), set(formattedArtistListOtherUser))) return commonTopArtistsList
def compareUsersTopTracks(user, otherUser, periodInput): topTracksListUser = lastfm_network.get_user(user).get_top_tracks(period = periodInput, limit = 150) topTracksListOtherUser = lastfm_network.get_user(otherUser).get_top_tracks(period=periodInput, limit=150) formattedTrackListUser = [] for track in topTracksListUser: formattedTrackListUser.append(track.item.title) formattedTrackListOtherUser = [] for track in topTracksListOtherUser: formattedTrackListOtherUser.append(track.item.title) commonTopTracksList = list(set.intersection(set(formattedTrackListUser), set(formattedTrackListOtherUser))) return commonTopTracksList
def playCount(user): playCount = lastfm_network.get_user(user).get_playcount() return '{:,}'.format(playCount) ### formats number with comma
def getTopArtist(user, periodInput): topTracksList = lastfm_network.get_user(user).get_top_artists(period=periodInput, limit=25) return topTracksList
def getNowPlaying(user): now_playing = [lastfm_network.get_user(user).get_now_playing()] return now_playing
def getTracksTimeInterval(timeFrom, timeTo, user): trackList = lastfm_network.get_user(user).get_recent_tracks(cacheable=False, limit=None, time_from=timeFrom, time_to=timeTo) return trackList