private async void ScrapeButton_Click(object sender, RoutedEventArgs e) { ScrapeButton.IsEnabled = false; try { Paging <PlaylistTrack> tracks = GetPlaylistTracks(); bool skip = true; foreach (PlaylistTrack plt in tracks.Items) { SimpleArtist artist = plt.Track.Artists.FirstOrDefault(); //// skip the ones that we've processed :\ //if(artist.Id == "0z6zRFzl5njXWLVAisXQBz") //{ // skip = false; // continue; //} //if (skip) { continue; } FullArtist fullArtist = _spotify.GetArtist(artist.Id); await ScrapeArtistInfo(fullArtist); } } catch (System.Exception ex) { ArtistProgressList.Items.Add("** Error: " + ex.Message); } }
public static Artist ToArtist(this SimpleArtist simpleArtist) { return(new Artist { Name = simpleArtist.Name.Trim().Replace(" ", " "), ProviderId = "spotify." + simpleArtist.Id }); }
public static ArtistInfo Create(SimpleArtist artist) { return(new ArtistInfo() { Id = artist.Id, Name = artist.Name }); }
private WebArtist CreateArtist(SimpleArtist artist) { return(new WebArtist(GetType()) { Name = artist.Name, Token = artist.Id, IsPartial = true }); }
public async Task <Release> GetReleaseById(string id) { FullAlbum album = await dataLayer.ExecuteQuery(new AlbumByIdQuery(id)); SimpleArtist artist = album.Artists.First(); return(new Release( id, name: album.Name, artistId: artist.Id, artistName: artist.Name, url: album.ExternalUrls["spotify"])); }
public async Task fmspotifyAsync(IUser user = null) { Data.Entities.User userSettings = await _userService.GetUserSettingsAsync(Context.User).ConfigureAwait(false); if (userSettings == null || userSettings.UserNameLastFM == null) { await ReplyAsync("Your LastFM username has not been set. Please set your username using the `.fmset 'username' 'embedfull/embedmini/textfull/textmini'` command.").ConfigureAwait(false); return; } try { PageResponse <LastTrack> tracks = await _lastFmService.GetRecentScrobblesAsync(userSettings.UserNameLastFM, 1).ConfigureAwait(false); LastTrack currentTrack = tracks.Content[0]; string TrackName = string.IsNullOrWhiteSpace(currentTrack.Name) ? null : currentTrack.Name; string ArtistName = string.IsNullOrWhiteSpace(currentTrack.ArtistName) ? null : currentTrack.ArtistName; string AlbumName = string.IsNullOrWhiteSpace(currentTrack.AlbumName) ? null : currentTrack.AlbumName; string querystring = TrackName + " - " + ArtistName + " " + AlbumName; SearchItem item = await _spotifyService.GetSearchResultAsync(querystring).ConfigureAwait(false); if (item.Tracks?.Items?.Any() == true) { FullTrack track = item.Tracks.Items.FirstOrDefault(); SimpleArtist trackArtist = track.Artists.FirstOrDefault(); await ReplyAsync("https://open.spotify.com/track/" + track.Id).ConfigureAwait(false); this._logger.LogCommandUsed(Context.Guild?.Id, Context.Channel.Id, Context.User.Id, Context.Message.Content); } else { await ReplyAsync("No results have been found for this track. Querystring: `" + querystring + "`").ConfigureAwait(false); } } catch (Exception e) { _logger.LogException(Context.Message.Content, e); await ReplyAsync("Unable to show Last.FM info via Spotify due to an internal error. Try setting a Last.FM name with the 'fmset' command, scrobbling something, and then use the command again.").ConfigureAwait(false); } }
public async Task fmspotifysearchAsync(params string[] searchterms) { try { string querystring = null; if (searchterms.Length > 0) { querystring = string.Join(" ", searchterms); SearchItem item = await _spotifyService.GetSearchResultAsync(querystring).ConfigureAwait(false); if (item.Tracks.Items.Count > 0) { FullTrack track = item.Tracks.Items.FirstOrDefault(); SimpleArtist trackArtist = track.Artists.FirstOrDefault(); await ReplyAsync("https://open.spotify.com/track/" + track.Id).ConfigureAwait(false); this._logger.LogCommandUsed(Context.Guild?.Id, Context.Channel.Id, Context.User.Id, Context.Message.Content); } else { await ReplyAsync("No results have been found for this track.").ConfigureAwait(false); } } else { await ReplyAsync("Please specify what you want to search for.").ConfigureAwait(false); } } catch (Exception e) { _logger.LogException(Context.Message.Content, e); await ReplyAsync("Unable to search for music via Spotify due to an internal error.").ConfigureAwait(false); } }
private async Task <List <TrackInfo> > GetPlaylistArtists(Paging <PlaylistTrack> playlistTracks, FeatureTable artistPlaces) { List <TrackInfo> artists = new List <TrackInfo>(); foreach (PlaylistTrack plt in playlistTracks.Items) { SimpleArtist artist = plt.Track.Artists.FirstOrDefault(); string artistid = artist.Id; string trackid = plt.Track.Id; string trackname = plt.Track.Name; QueryParameters query = new QueryParameters { WhereClause = "artistid = '" + artistid + "'" }; FeatureQueryResult queryResult = await artistPlaces.QueryFeaturesAsync(query); foreach (Feature f in queryResult) { await(f as ArcGISFeature).LoadAsync(); string artistname = f.Attributes["artistname"].ToString(); string hometown = f.Attributes["placename"].ToString(); string bio = f.Attributes["bioshort"].ToString(); bool isOnTour = int.Parse(f.Attributes["isontour"].ToString()) == 1; string imgUrl = f.Attributes["imageurl"].ToString(); BitmapImage src = new BitmapImage(new Uri(imgUrl, UriKind.Absolute)); TrackInfo thisArtist = new TrackInfo(artistname, artistid, bio, src, hometown, trackname, trackid, f.Geometry as MapPoint, isOnTour); // Add the track info to the list artists.Add(thisArtist); } } return(artists); }
public static string GetArtistUrl(this SimpleArtist artist) { return($"{SpotifyBaseUrl}/artist/{artist.Id}"); }
public SpotifyArtist(SimpleArtist oSpotifySimpleArtist) : base(oSpotifySimpleArtist.Id, oSpotifySimpleArtist.Name) { }