public Collection <ApiAudioSong> GetSongs()
        {
            var songs = new Collection <ApiAudioSong>();

            // var MusicID = GetMainSelection("Songs");


            try
            {
                _parent.Trace("Getting Songs: Parent IP: " + _parent.IP);
                string NPurl   = "http://" + _parent.IP + ":" + _parent.Port + "/emby/Users/" + Globals.CurrentUserID + "/Items?Recursive=true&IncludeItemTypes=Audio&EnableImages=true";
                var    request = WebRequest.CreateHttp(NPurl);
                request.Method  = "get";
                request.Timeout = 150000;
                _parent.Trace("Songs 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 Songs Selection Result ------" + json);

                        var deserializer = new JavaScriptSerializer();
                        deserializer.MaxJsonLength = Int32.MaxValue;
                        long GenreIDSet = 0;
                        var  ItemData   = deserializer.Deserialize <MusicSongs.Rootobject>(json);
                        MusicGenres.Rootobject MusicGenres = GetMusicGenres();

                        foreach (var genre in ItemData.Items)
                        {
                            // Do get more data - but takes FOREVER !!
                            MusicSongSingleItem.Rootobject Songitem = GetSingleSong(genre.Id);

                            foreach (var findingid in MusicGenres.Items)
                            {
                                if (Songitem.Genres != null && Songitem.Genres.Length != 0)
                                {
                                    if (findingid.Name == Songitem.Genres.FirstOrDefault().ToString())
                                    {
                                        GenreIDSet = Xbmc.IDtoNumber(findingid.Id);
                                    }
                                }
                            }

                            var RoundSeconds = (genre.RunTimeTicks / 10000000.00) ?? 0;

                            string TempSongGenreID = "";
                            if (genre.AlbumArtists != null && genre.AlbumArtists.Length != 0)
                            {
                                if (genre.AlbumArtists.FirstOrDefault() != null)
                                {
                                    TempSongGenreID = genre.AlbumArtists.FirstOrDefault().Id;
                                }
                            }

                            string TempSongGenre = "";
                            if (Songitem.Genres != null && Songitem.Genres.Length != 0)
                            {
                                if (Songitem.Genres.FirstOrDefault() != null)
                                {
                                    TempSongGenre = Songitem.Genres.FirstOrDefault().ToString();
                                }
                            }


                            try
                            {
                                var song = new ApiAudioSong
                                {
                                    IdSong   = Xbmc.IDtoNumber(genre.Id),
                                    Title    = genre.Name ?? "",
                                    Track    = Convert.ToInt64(genre.IndexNumber ?? 0),
                                    Duration = Convert.ToInt64(RoundSeconds),
                                    Year     = Convert.ToInt64(genre.ProductionYear ?? 1999),
                                    FileName = Songitem.Path,
                                    IdAlbum  = Xbmc.IDtoNumber(genre.AlbumId),
                                    Album    = genre.Album ?? "",
                                    Path     = genre.Id,
                                    IdArtist = Xbmc.IDtoNumber(TempSongGenreID),
                                    Artist   = genre.Artists.FirstOrDefault() ?? "",
                                    IdGenre  = GenreIDSet,
                                    Genre    = TempSongGenre ?? "",
                                    Thumb    = "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + genre.Id + "/Images/Primary" ?? "",
                                };
                                songs.Add(song);
                            }
                            catch (Exception)
                            {
                            }
                        }
                    }
                }

                return(songs);
            }


            catch (Exception ex)
            {
                _parent.Trace("Exception Caught: " + ex);
                return(null);
            }
        }
        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);
        }