public Collection<ApiAudioAlbum> GetAlbums()
        {
            var albums = new Collection<ApiAudioAlbum>();
            if (!_parent.IsConnected())
                return albums;
            var dblines = _parent.IPimpDBCommand(new CommandInfoIPimp { Action = "getallmusicalbums" }, "albums");
            if (dblines == null) return albums;

            foreach (JsonObject dbline in dblines)
            {
                var album = new ApiAudioAlbum
                {
                    IdAlbum = Convert.ToInt32("0" + (string)dbline["id"], CultureInfo.InvariantCulture),
                    Thumb = (string)dbline["thumb"],
                    Fanart = (string)dbline["fanart"],
                    IdGenre = 0,
                    Artist = (string)dbline["albumartist"],
                    Genre = (string)dbline["genre"],
                    Title = (string)dbline["name"],
                    Year = Convert.ToInt32("0" + (string)dbline["year"], CultureInfo.InvariantCulture),
                    Hash = MediaPortal.Hash((string)dbline["name"]),
                    IdArtist = 0
                };

                albums.Add(album);
            }

            return albums;
        }
Esempio n. 2
0
        public Collection<ApiAudioAlbum> GetAlbums()
        {
            var albums = new Collection<ApiAudioAlbum>();
            const string req = "SELECT idAlbum,strAlbum,idGenre,idArtist,strArtist,strGenre,iYear,strThumb FROM albumview GROUP BY strAlbum";

            var dblines = _parent.DBCommand("music", req);
            if (dblines == null) return albums;
            foreach (var dbline in dblines)
            {
                if (dbline.Length < 8)
                {
                    _parent.Log("Invalid request DATA : " + dbline);
                    continue;
                }
                var album = new ApiAudioAlbum
                                {
                                    IdAlbum = Xbmc.StringToNumber(dbline[0]),
                                    Title = dbline[1],
                                    IdGenre = Xbmc.StringToNumber(dbline[2]),
                                    IdArtist = Xbmc.StringToNumber(dbline[3]),
                                    Artist = dbline[4],
                                    Genre = dbline[5],
                                    Year = Xbmc.StringToNumber(dbline[6]),
                                    Thumb = dbline[7]
                                };
                var thumbparts = dbline[7].Split('/');
                var hash = thumbparts[thumbparts.Length - 1].Replace(".tbn", "");
                album.Hash = hash;

                albums.Add(album);
            }
            return albums;
        }
Esempio n. 3
0
 public Yatse2AudioAlbum(ApiAudioAlbum apiAudioAlbum)
 {
     if (apiAudioAlbum == null)
         return;
     Title = apiAudioAlbum.Title;
     IdAlbum = apiAudioAlbum.IdAlbum;
     IdArtist = apiAudioAlbum.IdArtist;
     Artist = apiAudioAlbum.Artist;
     Genre = apiAudioAlbum.Genre;
     IdGenre = apiAudioAlbum.IdGenre;
     Year = apiAudioAlbum.Year;
     Thumb = apiAudioAlbum.Thumb;
     Fanart = apiAudioAlbum.Fanart;
     Hash = apiAudioAlbum.Hash;
 }
Esempio n. 4
0
    public Collection<ApiAudioAlbum> GetAlbums()
    {
      var albums = new Collection<ApiAudioAlbum>();

      var properties = new JsonArray(new[] { "title", "thumbnail", "genre", "genreid", "artist", "year" });
      var param = new JsonObject();
      param["properties"] = properties;
      var result = (JsonObject)_parent.JsonCommand("AudioLibrary.GetAlbums", param);
      if (result != null)
      {
        if (result.Contains("albums"))
        {
          foreach (JsonObject genre in (JsonArray)result["albums"])
          {
            try
            {
              var album = new ApiAudioAlbum
                {
                  IdAlbum = (long)(JsonNumber)genre["albumid"],
                  Title = genre["title"].ToString(),
                  IdGenre = 0,
                  IdArtist = 0,
                  Artist = _parent.JsonArrayToString((JsonArray)genre["artist"]),
                  Genre = _parent.JsonArrayToString((JsonArray)genre["genre"]),
                  Year = (long)(JsonNumber)genre["year"],
                  Thumb = genre["thumbnail"].ToString()
                };
              albums.Add(album);
            }
            catch (Exception)
            {
            }
          }
        }
      }
      return albums;
    }
Esempio n. 5
0
        public Collection<ApiAudioAlbum> GetAlbums()
        {
            var albums = new Collection<ApiAudioAlbum>();

            //var AlbumID = GetMainSelection("Albums");


            try
            {
                _parent.Trace("Getting Album : Parent IP: " + _parent.IP);
                string NPurl = "http://" + _parent.IP + ":" + _parent.Port + "/emby/Users/" + Globals.CurrentUserID + "/Items?Recursive=true&IncludeItemTypes=MusicAlbum&EnableImages=true";
                var request = WebRequest.CreateHttp(NPurl);
                request.Method = "get";
                request.Timeout = 500000;
                _parent.Trace("Genre 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();
 //REMOVETHIS                   System.IO.StreamReader reader = new System.IO.StreamReader(dataStream);

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

                        var deserializer = new JavaScriptSerializer();
                        var ItemData = deserializer.Deserialize<MusicAlbums.Rootobject>(json);
                        _parent.Trace("---------------Get Album  :  Issue: Results.Record Count: " + ItemData.TotalRecordCount);
                        long GenreIDSet = 0;
                        MusicGenres.Rootobject MusicGenres = GetMusicGenres();

                        foreach (var genre in ItemData.Items)
                        {
                            MusicSingleAlbumItem.Rootobject AlbumItem = GetSingleAlbum(genre.Id);

                            foreach (var findingid in MusicGenres.Items)
                            {

                                if (AlbumItem.Genres != null && AlbumItem.Genres.Length != 0)
                                    {
                                        if (findingid.Name == AlbumItem.Genres.FirstOrDefault().ToString())
                                        {
                                            GenreIDSet = Xbmc.IDtoNumber(findingid.Id);
                                        }
                                    }

                            }

                            try
                            {


                                string TempAlbumGenreID = "";
                                if (genre.AlbumArtists != null && genre.AlbumArtists.Length != 0)
                                {
                                    if (genre.AlbumArtists.FirstOrDefault() != null) 
                                    {
                                        TempAlbumGenreID = genre.AlbumArtists.FirstOrDefault().Id;
                                    }
                                }
                                
                                string TempAlbumGenre = "";
                                if (AlbumItem.Genres != null && AlbumItem.Genres.Length != 0)
                                {
                                    if (AlbumItem.Genres.FirstOrDefault() != null)
                                    {
                                        TempAlbumGenre = AlbumItem.Genres.FirstOrDefault().ToString();
                                    }
                                }


                                _parent.Trace("AudioLIBRARY Single Album Checks");
                                _parent.Trace( genre.Id.ToString() );
                                _parent.Trace(genre.Name ?? "");
                                _parent.Trace(GenreIDSet.ToString());
                                _parent.Trace(Xbmc.IDtoNumber(TempAlbumGenreID).ToString());
                                _parent.Trace(genre.AlbumArtist ?? "");
                                _parent.Trace(TempAlbumGenre ?? "");
                                _parent.Trace(genre.ProductionYear.ToString());
                                _parent.Trace("http://" + _parent.IP + ":" + _parent.Port + "/Items/" + genre.Id + "/Images/Primary" ?? "");

                                var album = new ApiAudioAlbum
                                          {
                                              IdAlbum = Xbmc.IDtoNumber(genre.Id),
                                              Title = genre.Name ?? "",
                                              IdGenre = GenreIDSet,
                                              IdArtist = Xbmc.IDtoNumber(TempAlbumGenreID),
                                              Artist = genre.AlbumArtist ?? "",
                                              Genre = TempAlbumGenre ?? "",
                                              Year = genre.ProductionYear ?? 1999,
                                              Thumb = "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + genre.Id + "/Images/Primary" ?? "",
                                          };
                                albums.Add(album);
                            }
                            catch (Exception ex)
                            {
                                _parent.Trace("Music Album exception" + ex);
                            }
                        }

                    }
                }
            }
            catch (Exception Ex)
            {
                _parent.Trace("Music Album   exception" + Ex);
            }
            return albums;
        }
Esempio n. 6
0
        public ApiAudioAlbum ToApi()
        {
            var api = new ApiAudioAlbum
                          {
                              Artist = Artist,
                              Fanart = Fanart,
                              Genre = Genre,
                              Hash = Hash,
                              IdAlbum = IdAlbum,
                              IdArtist = IdArtist,
                              IdGenre = IdGenre,
                              Thumb = Thumb,
                              Title = Title,
                              Year = Year
                          };


            return api;
        }