public DetailsPage()
 {
     InitializeComponent();
     lastfm           = new LastFmApi();
     Loaded          += DetailsPage_Loaded;
     this.DataContext = Items;
 }
Exemple #2
0
		public static async Task<List<Artist>> GetWeeklyTopArtists(int limit = 10)
		{

			ILastFmConfig config = new LastFmConfig();
			string userName = ConfigurationManager.AppSettings["LastFMUserName"];
			string apiKey = ConfigurationManager.AppSettings["LastFMApiKey"];
			string secret = ConfigurationManager.AppSettings["LastFMSecret"];
			var lastFm = new LastFmApi(config);

			var things = lastFm.User.GetArtistTracks("llamabroth", "Radiohead");


			string url =
				string.Format(
					@"http://ws.audioscrobbler.com/2.0/?method=user.gettopartists&user={0}&period=7day&api_key={1}&limit={2}",
					userName, apiKey, limit);

			//var request = WebRequest.Create(_url + _json) as HttpWebRequest;
			HttpClient client = new HttpClient();
			HttpResponseMessage response = await client.GetAsync(url);

			XmlDocument doc = new XmlDocument();
			doc.Load(await response.Content.ReadAsStreamAsync());

			var artists = doc.DocumentElement.SelectNodes("/lfm/topartists/artist");

			var artistList = (from XmlNode artist in artists select new Artist(artist)).ToList();

			InitilizeArtistList(artistList);

			return artistList;
		}
Exemple #3
0
        public ValuesController()
        {
            var youTubeApi = new YouTubeApi(AppConsts.OAuthGoogleId, AppConsts.OAuthGoogleSecret, AppConsts.AppName);
            var lastFmApi  = new LastFmApi(AppConsts.LastfmApiKey, AppConsts.LastfmApiSecret);

            this.geniusApi = new GeniusApi(AppConsts.GeniusAccessToken, youTubeApi, lastFmApi, AppConsts.GeniusClientId, AppConsts.GeniusClientSecret);
        }
        private void GetSimilarArtistsAsync(SynoItem artist)
        {
            // TODO : Look on last.fm
            LastFmApi api = new LastFmApi();
            var       t   = api.GetSimilarArtistsAsync(artist.Title);

            t.ContinueWith(o =>
            {
                SimilarArtists.Clear();
                foreach (var lastFmArtist in o.Result)
                {
                    // FIXME : USe a factory.
                    SimilarArtists.Add(new ArtistViewModel(lastFmArtist.Name, lastFmArtist.Mbid, lastFmArtist.Url, lastFmArtist.Match, lastFmArtist.Images));
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
Exemple #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ArtistApiTest"/> class.
 /// </summary>
 public ArtistApiTest()
 {
     Api = new LastFmApi(new TestLastFmConfig());
 }
Exemple #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TagApiTest"/> class.
 /// </summary>
 public TagApiTest()
 {
     Api = new LastFmApi(new TestLastFmConfig());
 }
Exemple #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TagApiTest"/> class.
 /// </summary>
 public TagApiTest()
 {
     Api = new LastFmApi(new TestLastFmConfig());
 }
Exemple #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ArtistApiTest"/> class.
 /// </summary>
 public ArtistApiTest()
 {
     Api = new LastFmApi(new TestLastFmConfig());
 }
Exemple #9
0
        private static void ProcessTrack(LastFmApi.DataTypes.Track.RootObject o, Database.Song row)
        {
            if (o != null && o.track != null)
            {

                if (o.track.album != null)
                {
                    row.Album = o.track.album.title == null ? "" : o.track.album.title;

                    row.Track = o.track.album.attr.position == null ? "" : o.track.album.attr.position;

                    /*
                    if (o.track.album.image.Count > 0)
                    {
                        ImageHelper.DownloadFile(o.track.album.image[0].text, "temp.jpg");
                        System.Drawing.Bitmap b = new System.Drawing.Bitmap("temp.jpg");
                        byte[] image = ImageHelper.ConvertBitmapToBytes(b);
                        dsMusic.ImageCache.AddImageCacheRow(row.Artist, row.Album, o.track.album.image[0].text, ImageHelper.ConvertBitmapToBytes(b), "0x0", "");
                    }
                    */
                }

                if (o.track.artist != null)
                {
                    row.Artist = o.track.artist.name == null ? "" : o.track.artist.name;
                }

                if (o.track.wiki != null)
                {
                    row.Comments = o.track.wiki.summary == null ? "" : o.track.wiki.summary;
                }

                row.Title = o.track.name == null ? "" : o.track.name;

            }
        }
Exemple #10
0
        private void ProcessTrack(LastFmApi.DataTypes.Track.RootObject o)
        {
            if (o != null && o.track != null)
            {

                if (o.track.album != null)
                {
                    txtAlbum.Text = o.track.album.title == null ? "" : o.track.album.title;

                    txtTrack.Text = o.track.album.attr.position == null ? "" : o.track.album.attr.position;

                    if (o.track.album.image.Count > 0)
                    {
                        ImageHelper.DownloadFile(o.track.album.image[0].text, "temp.jpg");
                        BitmapImage b = new BitmapImage();
                        b.BeginInit();
                        b.UriSource = new Uri("temp.jpg", UriKind.Relative);
                        b.CacheOption = BitmapCacheOption.OnLoad;
                        b.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
                        b.EndInit();

                        imgArt.Source = b;
                    }
                }

                if (o.track.artist != null)
                {
                    txtArtist.Text = o.track.artist.name == null ? "" : o.track.artist.name;
                }

                if (o.track.wiki != null)
                {
                    txtComments.Text = o.track.wiki.summary == null ? "" : o.track.wiki.summary;
                }

                txtTitle.Text = o.track.name == null ? "" : o.track.name;

            }
            else
            {
                MessageBox.Show("No match.");
            }
        }
 public LastfmApiWrapper()
 {
     _api = new LastFmApi(new TestLastFmConfig());
 }