예제 #1
0
        public Collection<ApiAudioArtist> GetArtists()
        {
            var artists = new Collection<ApiAudioArtist>();
            if (!_parent.IsConnected())
                return artists;
            var dblines = _parent.IPimpDBCommand(new CommandInfoIPimp { Action = "getallmusicartists" }, "artists");
            if (dblines == null) return artists;

            foreach (JsonObject dbline in dblines)
            {
                var artist = new ApiAudioArtist
                {
                    Thumb = (string)dbline["thumb"],
                    Fanart = (string)dbline["fanart"],
                    Hash = MediaPortal.Hash((string)dbline["files"]),
                    Biography = (string)dbline["biography"],
                    IdArtist = Convert.ToInt32("0" + (string)dbline["id"], CultureInfo.InvariantCulture),
                    Name = (string)dbline["name"]
                };

                artists.Add(artist);
            }

            
            return artists;
        }
예제 #2
0
        public Collection<ApiAudioArtist> GetArtists()
        {
            var artists = new Collection<ApiAudioArtist>();
            var dblines = _parent.DBCommand("music", "SELECT idArtist,strArtist FROM artist");
            if (dblines == null) return artists;
            foreach (var dbline in dblines)
            {
                if (dbline.Length < 2)
                {
                    _parent.Log("Invalid request DATA : " + dbline);
                    continue;
                }
                var hash = Xbmc.Hash(dbline[1]);
                var hash2 = Xbmc.Hash("artist"+dbline[1]);
                var genre = new ApiAudioArtist
                                {
                                    IdArtist = Xbmc.StringToNumber(dbline[0]), 
                                    Name = dbline[1], 
                                    Thumb =  @"special://profile/Thumbnails/Music/Artists/" + hash2 + ".tbn",
                                    Fanart = @"special://profile/Thumbnails/Music/Fanart/" + hash + ".tbn",
                                    Hash = hash2
                                };
                artists.Add(genre);
            }

            dblines = _parent.DBCommand("music", "SELECT idArtist,strBiography FROM artistinfo");
            if (dblines == null) return artists;

            foreach (var dbline in dblines)
            {
                if (dbline.Length < 2)
                {
                    _parent.Log("Invalid request DATA : " + dbline);
                    continue;
                }
                foreach (var artist in artists)
                {
                    if (artist.IdArtist.ToString(CultureInfo.InvariantCulture) == dbline[0])
                    {
                        artist.Biography = dbline[1];
                    }
                }
            }

            return artists;
        }
예제 #3
0
    public Collection<ApiAudioArtist> GetArtists()
    {
      var artists = new Collection<ApiAudioArtist>();

      var properties = new JsonArray(new[] { "thumbnail", "fanart", "description" });
      var param = new JsonObject();
      param["properties"] = properties;
      var result = (JsonObject)_parent.JsonCommand("AudioLibrary.GetArtists", param);
      if (result != null)
      {
        if (result.Contains("artists"))
        {
          foreach (JsonObject genre in (JsonArray)result["artists"])
          {
            try
            {
              var artist = new ApiAudioArtist
                {
                  IdArtist = (long)(JsonNumber)genre["artistid"],
                  Name = genre["artist"].ToString(),
                  Thumb = genre["thumbnail"].ToString(),
                  Fanart = genre["fanart"].ToString(),
                  Biography = genre["description"].ToString()
                };
              artists.Add(artist);
            }
            catch (Exception)
            {
            }
          }
        }
      }
      return artists;
    }
예제 #4
0
        public Collection<ApiAudioArtist> GetArtists()
        {
            var artists = new Collection<ApiAudioArtist>();


            //var MusicID = GetMainSelection("Album Artists");


            try
            {
                _parent.Trace("Getting Album ARtists: Parent IP: " + _parent.IP);
                string NPurl = "http://" + _parent.IP + ":" + _parent.Port + "/emby/Artists/AlbumArtists?Recursive=true&EnableImages=true"; // /" + Globals.CurrentUserID + "/Items?ParentId=" + ;
                var request = WebRequest.CreateHttp(NPurl);
                request.Method = "get";
                request.Timeout = 150000;
                _parent.Trace("Album Artists Music Selection: " + NPurl);
                var authString = _parent.GetAuthString();
                request.Headers.Add("X-MediaBrowser-Token", Globals.EmbyAuthToken);
                request.Headers.Add("X-Emby-Authorization", authString);
                request.ContentType = "application/json; charset=utf-8";
                request.Accept = "application/json; charset=utf-8";

                var response = request.GetResponse();

                if (((HttpWebResponse)response).StatusCode == HttpStatusCode.OK)
                {

                    System.IO.Stream dataStream = response.GetResponseStream();


                    using (var sr = new System.IO.StreamReader(response.GetResponseStream()))
                    {
                        string json = sr.ReadToEnd();
                        _parent.Trace("--------------GETTING Album Artists Genres Selection Result ------" + json);

                        var deserializer = new JavaScriptSerializer();
                        var ItemData = deserializer.Deserialize<AlbumArtists.Rootobject>(json);
                        _parent.Trace("---------------Get Album Artists :  Issue: Results.Record Count: " + ItemData.TotalRecordCount);

                        foreach (var genre in ItemData.Items)
                        {
                            MusicSingleArtistInfo.Rootobject ArtistItem = GetSingleArtist(genre.Id);

                            try
                            {
                                var artist = new ApiAudioArtist
                                  {
                                      IdArtist = Xbmc.IDtoNumber(genre.Id),
                                      Name = genre.Name ?? "",
                                      Thumb = "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + genre.Id + "/Images/Primary" ?? "",
                                      Fanart = "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + genre.Id + "/Images/Backdrop" ?? "",
                                      Biography = ArtistItem.Overview
                                  };
                                artists.Add(artist);
                            }

                            catch (Exception ex)
                            {
                                _parent.Trace("Another Album Artists Exception Caught " + ex);
                            }
                        }

                    }
                }
            }
            catch (Exception Ex)
            {
                _parent.Trace("Another Album Artists  exception" + Ex);
            }
            
            
            return artists;
        }
예제 #5
0
 public Yatse2AudioArtist(ApiAudioArtist apiAudioArtist)
 {
     if (apiAudioArtist == null)
         return;
     IdArtist = apiAudioArtist.IdArtist;
     Name = apiAudioArtist.Name;
     Biography = apiAudioArtist.Biography;
     Thumb = apiAudioArtist.Thumb;
     Fanart = apiAudioArtist.Fanart;
     Hash = apiAudioArtist.Hash;
 }
예제 #6
0
 public ApiAudioArtist ToApi()
 {
     var api = new ApiAudioArtist
                   {
                       Biography = Biography,
                       Fanart = Fanart,
                       Hash = Hash,
                       IdArtist = IdArtist,
                       Name = Name,
                       Thumb = Thumb
                   };
     return api;
 }