Exemplo n.º 1
0
 public IAlbumApi LastFmAlbumRepository()
 {
     if (this._albumApi == null)
     {
         this._albumApi = _lastfmClient.Album;
     }
     return(_albumApi);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LastFmApi"/> class.
        /// </summary>
        /// <param name="config">The config.</param>
        public LastFmApi(ILastFmConfig config)
        {
            Config = config;

            Track  = new TrackApi(this);
            Tag    = new TagApi(this);
            Album  = new AlbumApi(this);
            Artist = new ArtistApi(this);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LastFmApi"/> class.
        /// </summary>
        /// <param name="config">The config.</param>
        public LastFmApi(ILastFmConfig config)
        {
            Config = config;

            Track = new TrackApi(this);
            Tag = new TagApi(this);
            Album = new AlbumApi(this);
            Artist = new ArtistApi(this);
        }
Exemplo n.º 4
0
        public AlbumViewModel()
        {
            albumDatabase = App.Container.Resolve <AlbumDatabase>();
            albumApi      = App.Container.Resolve <AlbumApi>();
            photoApi      = App.Container.Resolve <PhotoApi>();
            userApi       = App.Container.Resolve <UserApi>();

            GetDatabase();
        }
Exemplo n.º 5
0
 public ScrobblerService(ICredentialHelper credentialHelper)
 {
     _credentialHelper = credentialHelper;
     _auth             = new LastAuth(ApiKeys.LastFmId, ApiKeys.LastFmSecret);
     _albumApi         = new AlbumApi(_auth);
     _artistApi        = new ArtistApi(_auth);
     _chartApi         = new ChartApi(_auth);
     _trackApi         = new TrackApi(_auth);
     _userApi          = new UserApi(_auth);
     GetSessionTokenAsync();
 }
Exemplo n.º 6
0
 public ScrobblerService()
 {
     //  _credentialHelper = credentialHelper;
     _auth      = new LastAuth(ApiKeys.LastFmId, ApiKeys.LastFmSecret);
     _albumApi  = new AlbumApi(_auth);
     _artistApi = new ArtistApi(_auth);
     _chartApi  = new ChartApi(_auth);
     _trackApi  = new TrackApi(_auth);
     // _userApi = new UserApi(_auth);
     // loadthis();
 }
Exemplo n.º 7
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            System.Net.ServicePointManager.ServerCertificateValidationCallback +=
                delegate(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate,
                         System.Security.Cryptography.X509Certificates.X509Chain chain,
                         System.Net.Security.SslPolicyErrors sslPolicyErrors)
            {
                return(true);           // **** Always accept
            };
            ServicePointManager.ServerCertificateValidationCallback = MyRemoteCertificateValidationCallback;


            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById <Button>(Resource.Id.myButton);

            button.Click += delegate {
                button.Text = string.Format("{0} calls!", count++);

                // Configure API key authorization: key
                if (!Configuration.Default.ApiKey.ContainsKey("apikey"))
                {
                    Configuration.Default.ApiKey.Add("apikey", "YOUR_API_KEY");
                }
                // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
                // Configuration.Default.ApiKeyPrefix.Add("apikey", "Bearer");

                var apiInstance = new AlbumApi();
                var albumId     = "14250417";         // string | The musiXmatch album id
                var format      = "json";             // string | output format: json, jsonp, xml. (optional)  (default to json)

                try
                {
                    //
                    InlineResponse200 result = apiInstance.AlbumGetGet(albumId, format);
                    var res = JsonConvert.SerializeObject(result);
                    Log.Debug("SWAGGER", res);
                }
                catch (IO.Swagger.Client.ApiException e)
                {
                    Log.Warn("SWAGGER", "Exception when calling DefaultApi.AlbumGetGet: " + e.Message);
                }
                catch (Exception e)
                {
                    Log.Warn("SWAGGER", "Exception when calling DefaultApi.AlbumGetGet: " + e.Message);
                }
            };
        }
Exemplo n.º 8
0
 /// <summary>
 /// 专辑的封面地址改变时重新下载图像
 /// </summary>
 private void CoverUrlChangedAsync(string url)
 {
     if (string.IsNullOrEmpty(CoverUrl))
     {
         var alaalbum = AlbumApi.InitBriefInfoAlbumAsync(AlbumId).Result;
         Companyname = alaalbum.Companyname;
         Desc        = alaalbum.Desc;
         _coverUrl   = alaalbum.CoverUrl;
         PubTime     = alaalbum.PubTime;
         Bitmap bit1 = TaNewHelper.ImageHelper.DownAsync(alaalbum.CoverUrl).Result;
         DispatcherHelper.CheckBeginInvokeOnUI((() => Cover = TaNewHelper.ImageHelper.GetBitmapImage(bit1)));
     }
     else
     {
         Bitmap bit = TaNewHelper.ImageHelper.DownAsync(url).Result;
         DispatcherHelper.CheckBeginInvokeOnUI((() => Cover = TaNewHelper.ImageHelper.GetBitmapImage(bit)));
     }
 }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            //IndexData data=new IndexData();
            //data.GetIndexData();
            var dsdasdas = MusicApi.GetIndexList();
            var fdf      = HttpClientHelper.GetAsync(dsdasdas).Result;
            var resss    = SearchApi.GetKeySuggest("李");
            var str      = MusicApi.GetKeySuggesUrl("修炼爱情");
            var ss       = HttpClientHelper.GetAsync(str).Result;
            var swe      = MusicApi.GetHotKey();
            var sdsad    = HttpClientHelper.GetAsync(swe).Result;
            var sds      = AlbumApi.InitBriefInfoAlbumAsync("2265047").Result;
            //var sss =
            //    MusicApi.GetSingerAlbum("000GGDys0yA0Nk", 0, 10);
            var     bir     = ImageHelper.DownAsync("http://y.gtimg.cn/music/photo_new/T002R500x500M000004Z9rf305fzyj.jpg").Result;
            SongApi songApi = new SongApi();

            songApi.InitAllListAsync().Wait();
            var lis = songApi.GetCover();

            foreach (var song in lis)
            {
                song.Album.GetAllInfor.BeginInvoke(string.Empty, null, null);
            }
            TopList top = new TopList();

            top.InitFromJsonAsync(4, 0, 10).Wait();
            var sss = MusicApi.GetTopList(4, 0, 30);

            var ssss = HttpClientHelper.GetAsync(sss).Result;

            JObject json = JObject.Parse(ssss);
            var     list = json["songlist"];

            foreach (var VARIABLE in list)
            {
            }

            var s = MusicApi.GetMusicianUrl(1, 200, NetMusic.Mode.MusicianType.cn_man, "L");

            var tt = HttpClientHelper.GetAsync(s).Result;
        }
Exemplo n.º 10
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Code to start the Xamarin Test Cloud Agent
#if ENABLE_TEST_CLOUD
            Xamarin.Calabash.Start();
#endif

            // Perform any additional setup after loading the view, typically from a nib.
            Button.AccessibilityIdentifier = "myButton";
            Button.TouchUpInside          += delegate
            {
                var title = string.Format("{0} clicks!", count++);
                Button.SetTitle(title, UIControlState.Normal);

                // Configure API key authorization: key
                Configuration.Default.ApiKey.Add("apikey", "YOUR_API_KEY");
                // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
                // Configuration.Default.ApiKeyPrefix.Add("apikey", "Bearer");

                var apiInstance = new AlbumApi();
                var albumId     = "14250417";         // string | The musiXmatch album id
                var format      = "json";             // string | output format: json, jsonp, xml. (optional)  (default to json)

                try
                {
                    //
                    InlineResponse200 result = apiInstance.AlbumGetGet(albumId, format);
                    var res = JsonConvert.SerializeObject(result);
                    Console.WriteLine(res);
                }
                catch (IO.Swagger.Client.ApiException e)
                {
                    Console.WriteLine("Exception when calling DefaultApi.AlbumGetGet: " + e.Message);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Exception when calling DefaultApi.AlbumGetGet: " + e.Message);
                }
            };
        }
Exemplo n.º 11
0
        public async Task <IEnumerable <AudioMetaData> > TracksForRelease(string artist, string Release)
        {
            if (string.IsNullOrEmpty(artist) || string.IsNullOrEmpty(Release))
            {
                return(null);
            }
            var result = new List <AudioMetaData>();

            try
            {
                var       responseCacheKey = string.Format("uri:lastFm:artistAndRelease:{0}:{1}", artist, Release);
                LastAlbum releaseInfo      = this.CacheManager.Get <LastAlbum>(responseCacheKey);
                if (releaseInfo == null)
                {
                    try
                    {
                        var auth     = new LastAuth(this.ApiKey.Key, this.ApiKey.KeySecret);
                        var albumApi = new AlbumApi(auth); // this is an unauthenticated call to the API
                        var response = await albumApi.GetInfoAsync(artist, Release);

                        releaseInfo = response.Content;
                        if (releaseInfo != null)
                        {
                            this.CacheManager.Add(responseCacheKey, releaseInfo);
                        }
                    }
                    catch
                    {
                        this.Logger.LogWarning("LastFmAPI: Error Getting Tracks For Artist [{0}], Release [{1}]", artist, Release);
                    }
                }

                if (releaseInfo != null && releaseInfo.Tracks != null && releaseInfo.Tracks.Any())
                {
                    var tracktotal = releaseInfo.Tracks.Where(x => x.Rank.HasValue).Max(x => x.Rank);
                    List <AudioMetaDataImage> images = null;
                    if (releaseInfo.Images != null)
                    {
                        images = releaseInfo.Images.Select(x => new AudioMetaDataImage
                        {
                            Url = x.AbsoluteUri
                        }).ToList();
                    }
                    foreach (var track in releaseInfo.Tracks)
                    {
                        result.Add(new AudioMetaData
                        {
                            Artist               = track.ArtistName,
                            Release              = track.AlbumName,
                            Title                = track.Name,
                            Year                 = releaseInfo.ReleaseDateUtc != null ? (int?)releaseInfo.ReleaseDateUtc.Value.Year : null,
                            TrackNumber          = (short?)track.Rank,
                            TotalTrackNumbers    = tracktotal,
                            Time                 = track.Duration,
                            LastFmId             = track.Id,
                            ReleaseLastFmId      = releaseInfo.Id,
                            ReleaseMusicBrainzId = releaseInfo.Mbid,
                            MusicBrainzId        = track.Mbid,
                            Images               = images
                        });
                    }
                }
            }
            catch (System.Exception ex)
            {
                this.Logger.LogError(ex, string.Format("LastFm: Error Getting Tracks For Artist [{0}], Release [{1}]", artist, Release));
            }
            return(result);
        }
Exemplo n.º 12
0
        public MockAlbumApi(Mock <ILastAuth> auth)
        {
            Auth = auth;

            Object = new AlbumApi(Auth.Object);
        }
Exemplo n.º 13
0
 public void Setup()
 {
     _albumApi = new AlbumApi();
 }