public void Total() { var service = new LastFmService(new HttpClient()); const string expected = "Week [804 scrobbles total]"; var actual = $"Week {service.TotalScrobblesAsync("week", "UnitR_").Result}"; Assert.AreEqual(expected, actual, "Improperly formatted top."); }
public PlaceController(FirestoreDb db, IPlacesService placesService, IUserService userService, SpotifyService spotify, LastFmService lastFm) { _db = db; _placesService = placesService; _userService = userService; _spotify = spotify; _lastFm = lastFm; }
public async Task Populate() { IsBusy = true; var getBiographiesResult = EchoNestService.GetArtistBiographies(Parameter); var getArtistDetailsResult = LastFmService.GetArtistDetails(Parameter); await Task.WhenAll(getBiographiesResult.Execute(), getArtistDetailsResult.Execute()); Biography = getBiographiesResult.PreferredBiographyInfo(); ArtistImage = getArtistDetailsResult.LargestImageUrl(); IsBusy = false; }
private async Task <EmbedBuilder> BuildResponse( dynamic images, dynamic description, dynamic tags, string name, dynamic url, dynamic playCount, dynamic listeners) { var imageUrl = ""; if (images != null && images.Count > 0) { imageUrl = await LastFmService.ChooseImage(images); } var strDescription = ""; if (description != null) { strDescription = description.ToString(); strDescription = !String.IsNullOrEmpty(strDescription) ? strDescription.Substring(0, strDescription.IndexOf('.') + 1) : ""; } var tagsBuilder = new StringBuilder(); if (tags.Count > 0) { foreach (var tag in tags) { tagsBuilder.Append($"{new CultureInfo("en-US").TextInfo.ToTitleCase(tag.name.ToString())}, "); } tagsBuilder.Remove(tagsBuilder.Length - 2, 2); } var embed = new EmbedBuilder(); embed.WithTitle(name); embed.WithUrl(url.ToString()); embed.WithThumbnailUrl(imageUrl); embed.AddField("Total Scrobbles:", String.Format("{0:n0}", (int)playCount), true); embed.AddField("Total Listeners:", String.Format("{0:n0}", (int)listeners), true); if (strDescription != String.Empty && !strDescription.Contains("<a")) { embed.WithDescription(strDescription); } if (tagsBuilder.Length > 0) { embed.AddField("Tags:", tagsBuilder.ToString()); } embed.WithColor(255, 255, 255); return(embed); }
//builds the embed for the chart private async Task <EmbedBuilder> BuildTopAsync(string list, string username, string ListType, string span) { var totalScrobbles = await lastFm.TotalScrobblesAsync(span, username); span = await LastFmService.FormatSpan(span.ToLowerInvariant()); var embed = new EmbedBuilder() .WithTitle($"Top {ListType} for {username} - {span} {totalScrobbles}") .WithDescription(list) .WithColor(Color.Gold); return(embed); }
/// <summary> /// /// </summary> /// <param name="query"></param> /// <returns></returns> private Object GetSource(String query, String data) { try { if (String.IsNullOrEmpty(query)) { return(null); } if (String.IsNullOrEmpty(data)) { return(null); } Regex regex = new Regex(@"^(artist:)(.*?)(\|album:)(.*?)(\|song:)(.*?)$"); Console.WriteLine(regex.IsMatch("artist:e|album:1|song:5")); if (!regex.IsMatch(data)) { return(null); } Match match = regex.Match(data); String artist = match.Groups[2].Value.Trim(); String album = match.Groups[4].Value.Trim(); String song = match.Groups[6].Value.Trim(); LastFmService lastfm = new LastFmService(); if (String.IsNullOrEmpty(artist)) { return(null); } if (String.IsNullOrEmpty(album) && String.IsNullOrEmpty(song)) { return(lastfm.SearchAlbum(artist, 0)); } } catch { } return(null); }
static void Main(string[] args) { //NounCollection coll = NounCollection.Instance; //String [] related = null; //Console.WriteLine(coll.Nouns["hello"].GetDescription(0, out related)); //using (StreamWriter writer = new StreamWriter(File.Create(@"\1.txt"))) //{ // for (int index = 0; index < 256; index++) // writer.WriteLine(String.Concat(index, " ", (char)index)); //} //Console.WriteLine((int)'e');//'é'); //BingSearch search = new BingSearch(); //search.SearchWeb("apj kalam"); //Wikipedia wClass = new Wikipedia(new WikiQueryEngine()); //Console.WriteLine(wClass.IsArticleAvailable("Plain white T's")); //SearchSuggestion searchSuggest = wClass.SearchArticles("Plain white T's", 10); //foreach (SearchSuggestionItem sItem in searchSuggest.Section) //{ // Console.WriteLine(sItem.Text + "\n\t" + sItem.Description + "\n" + sItem.Url); //} //Console.WriteLine(wClass.GetArticle("Seattle", false).Introduction); OmukSemantics semantics = new OmukSemantics(); //YSearch search = new YSearch(); //YSearchResultCollection resCollection = search.SearchWeb("me genera serotonina listening to Viva la Vida by Coldplay", 0, 10, ref semantics); BingSearch bsearch = new BingSearch(); bsearch.SearchWeb("Am I Dreaming by Xscape", 0, 10, ref semantics); semantics.PostSearch(); semantics.FormContext(); LyricWiki wiki = new LyricWiki(); LyricsResult lyrics = wiki.getSong("Rihanna", "Umbrella"); Console.WriteLine(lyrics.lyrics); //Console.WriteLine(""); LastFmService service = new LastFmService(); //service.GetArtistInfo( //MusicBrainz mb = new MusicBrainz(); // mb.GetAlbums //Grooveshark gshark = new Grooveshark(); //GSSong[] song = gshark.SearchSong("Sugar", 2); //LyricWiki wiki = new LyricWiki(); //LyricsResult lyrics = wiki.getSong("R.e.m", "Moon river"); //lyrics.GetLyricsHtml(); //SongResult songs = wiki.searchSongs("R.e.m", "Moon river"); //String artist = "Flo rida"; //String album = "Sugar"; //int year = 2009; //String[] albums = null; //String res = wiki.getAlbum(ref artist, ref album, ref year, out albums); //AlbumData[] album = (AlbumData[])wiki.getArtist(ref artist); //LWLyrics lyrics = wiki.GetLyricsForSong("Flo rida", "sugar"); //Console.WriteLine(wiki.IsArtist("rihanna")); //String[] albums = wiki.GetAlbums("rihanna"); //LastFmService service = new LastFmService(); //LFMArtist artist = service.GetArtistInfo("Rihanna"); //List<LFMArtist> albums = service.SearchArtist("Kid Cudi", 0); //Immem immem = new Immem(); //List<ImmemSearchItem> items = immem.SearchMedia("Rihanna good girl gone bad", "music", 0, 10); MusicBrainz mb = new MusicBrainz(); List <MBAlbum> albums = mb.GetAlbums(String.Empty, "Rihanna", "73e5e69d-3554-40d8-8516-00cb38737a1c", 0, 10); List <MBSong> songs = mb.GetSongs("oh Carol", "Neil", "", "", "", 0, 2); //YouTube yt = new YouTube(); //List<YTVideo> videos = yt.SearchVideos("oh carol", 0, 3); //RottenTomatoes rt = new RottenTomatoes(); //String val = rt.GetTomatometerScore("http://www.rottentomatoes.com/m/1009437-heidi/"); /* * Twitter twitter = new Twitter(); * ////twitter.SearchTwitter("i gotta feeling", 0, 10); * TMovieTrendsClass mTrends = new TMovieTrendsClass(); * twitter.GetMovieTrends("The Martian", ref mTrends); * Console.WriteLine(""); */ //twitter.GetMovieTrends("\"the proposal\"",ref mTrends); //twitter.GetMovieTrends("\"year one\"", ref mTrends); //twitter.GetMovieTrends("\"Terminator Salvation\"", ref mTrends); //twitter.GetMovieTrends("\"Next day air\"", ref mTrends); //twitter.GetMovieTrends("\"Imagine That\"", ref mTrends); //twitter.GetMovieTrends("\"Taking of Pelham 1 2 3", ref mTrends); //twitter.GetMovieTrends("Wolverine", ref mTrends); //using (StreamWriter writer = new StreamWriter(File.Create("trend.txt"))) //{ // foreach (KeyValuePair<String, int> keyval in mTrends.Trend) // { // if (keyval.Value > 3) // writer.WriteLine(String.Format("{0} {1}", keyval.Key, keyval.Value)); // } //} //TSearchResultCollection twRes = twitter.SearchTwitter("palm pre", 0, 15); //Eventful evntful = new Eventful (); //EventCollection coll = evntful.SearchEvents("San Jose", 0, 10); //Digg digg = new Digg(); //List<DiggResult> res = digg.SearchDigg("Hello", 0, 10); return; }
public LastFm(LastFmService service, Repository <User> repo) { lastFm = service; userRepo = repo; }
public void Setup() { _subject = new LastFmService(new MockLastFmConfigurationProvider()); }
public Information(LastFmService service) { lastFm = service; }
public ChartService(LastFmService service, HttpClient client) { lastFm = service; httpClient = client; }