Exemple #1
0
 public XbmcFile(Xbmc parent)
 {
     _parent          = parent;
     _workerDownloads = new BackgroundWorker {
         WorkerSupportsCancellation = true
     };
     _workerDownloads.DoWork += AsyncImagesDownloadsWorker;
 }
Exemple #2
0
 public MpcHcRemote(Xbmc parent)
 {
     _parent = parent;
 }
Exemple #3
0
        public Collection <ApiMovie> GetMovies()
        {
            var movies  = new Collection <ApiMovie>();
            var MovieId = GetMainSelection("Movies");

            try
            {
                _parent.Trace("Getting Main Movie Database Result" + _parent.IP);
                string NPurl = "http://" + _parent.IP + ":" + _parent.Port + "/emby/Users/" + Globals.CurrentUserID + "/Items?ParentId=" + MovieId;

                var request = WebRequest.CreateHttp(NPurl);

                request.Method  = "get";
                request.Timeout = 150000;
                _parent.Trace("Main Selection: " + _parent.IP + ":" + _parent.Port);

                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 All Movies Results ------" + json);

                        var deserializer = new JavaScriptSerializer();

                        var ItemData = deserializer.Deserialize <Movies.Rootobject>(json);

                        _parent.Trace("---------------Get Worlds Result:  Issue: Results.Count: " + ItemData.Items.Count);

                        foreach (var id in ItemData.Items)
                        {
                            try
                            {
                                SingleMovieItem.Rootobject Movieitem = GetSingleMovieItem(id.Id);
                                string newDirector = "";
                                bool   index       = Movieitem.People.Any(item => item.Type == "Director");
                                if (index == true)
                                {
                                    newDirector = Movieitem.People.First(i => i.Type == "Director").Name.ToString();
                                }

                                var Seconds      = Convert.ToInt64(id.RunTimeTicks);
                                var RoundSeconds = Math.Round(Seconds / 10000000.00, 1);


                                var movie = new ApiMovie
                                {
                                    Title         = Movieitem.Name ?? "Unknown",
                                    Plot          = Movieitem.Overview ?? "Unknown",
                                    Votes         = Movieitem.VoteCount.ToString() ?? "0",
                                    Rating        = id.CommunityRating.ToString() ?? "0",
                                    Year          = id.ProductionYear,
                                    Tagline       = Movieitem.Taglines.FirstOrDefault() ?? "Might be a good movie",
                                    IdScraper     = Movieitem.ProviderIds.Imdb ?? "",
                                    Length        = new TimeSpan(0, 0, 0, Convert.ToInt32(RoundSeconds)).ToString() ?? "Unknown",
                                    Mpaa          = id.OfficialRating ?? "Unknown",
                                    Genre         = Movieitem.Genres.FirstOrDefault() ?? "Unknown",
                                    Director      = newDirector ?? "",
                                    OriginalTitle = id.Name ?? "",
                                    Studio        = Movieitem.Studios.FirstOrDefault().Name ?? "Unknown",
                                    IdFile        = 0,
                                    IdMovie       = Xbmc.IDtoNumber(Movieitem.Id),
                                    FileName      = Movieitem.Path ?? "",
                                    Path          = Movieitem.Id ?? "",
                                    PlayCount     = Movieitem.UserData.PlayCount,
                                    Thumb         = "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + id.Id + "/Images/Primary",
                                    Fanart        = "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + id.Id + "/Images/Backdrop",
                                    Hash          = Xbmc.Hash(id.Id)
                                };
                                movies.Add(movie);
                            }

                            catch (Exception ex)
                            {
                                _parent.Trace("Exception with Movie Name :" + ex);
                            }
                        }


                        /*
                         *                _nowPlaying.FanartURL = "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + server.PrimaryItemId + "/Images/Backdrop";
                         *                _nowPlaying.ThumbURL = "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + server.PrimaryItemId + "/Images/Primary";
                         */
                    }
                }
            }
            catch (Exception ex)
            {
                _parent.Trace("ERROR in Main Movies obtaining: " + ex);
            }


            /*
             *
             * var properties = new JsonArray(new[] { "title", "plot", "genre", "year", "fanart", "thumbnail", "playcount", "studio", "rating", "runtime", "mpaa", "originaltitle", "director", "votes" });
             * var param = new JsonObject();
             * param["properties"] = properties;
             * var result = (JsonObject)_parent.JsonCommand("VideoLibrary.GetMovies", param);
             * if (result != null)
             * {
             * if (result.Contains("movies"))
             * {
             *  foreach (JsonObject genre in (JsonArray)result["movies"])
             *  {
             *    try
             *    {
             *      var t = TimeSpan.FromSeconds((long)(JsonNumber)genre["runtime"]);
             *      var duration = string.Format("{0:D2}:{1:D2}", t.Hours, t.Minutes);
             *      var movie = new ApiMovie
             *        {
             *
             *          Title = genre["title"].ToString(),
             *          Plot = genre["plot"].ToString(),
             *          Votes = genre["votes"].ToString(),
             *          Rating = genre["rating"].ToString(),
             *          Year = (long)(JsonNumber)genre["year"],
             *          IdScraper = "",
             *          Length = duration,
             *          Mpaa = genre["mpaa"].ToString(),
             *          Genre = _parent.JsonArrayToString((JsonArray)genre["genre"]),
             *          Director = _parent.JsonArrayToString((JsonArray)genre["director"]),
             *          OriginalTitle = genre["originaltitle"].ToString(),
             *          Studio = _parent.JsonArrayToString((JsonArray)genre["studio"]),
             *          IdFile = 0,
             *          IdMovie = (long)(JsonNumber)genre["movieid"],
             *          FileName = "",
             *          Path = "",
             *          PlayCount = 0,
             *          Thumb = genre["thumbnail"].ToString(),
             *          Fanart = genre["fanart"].ToString(),
             *          Hash = Xbmc.Hash(genre["thumbnail"].ToString())
             *        };
             *      movies.Add(movie);
             *    }
             *    catch (Exception)
             *    {
             *    }
             *  }
             * }
             * }
             */
            return(movies);
        }
Exemple #4
0
 public XbmcVideoLibrary(Xbmc parent)
 {
     _parent = parent;
 }
Exemple #5
0
        public Collection <ApiTvEpisode> GetTvEpisodes()
        {
            var episodes = new Collection <ApiTvEpisode>();

            try
            {
                _parent.Trace("Getting TV Episodes: Parent IP: " + _parent.IP);
                string NPurl = "http://" + _parent.IP + ":" + _parent.Port + "/emby/Users/" + Globals.CurrentUserID + "/Items?Recursive=true&IncludeItemTypes=Episode";

                var request = WebRequest.CreateHttp(NPurl);

                request.Method  = "get";
                request.Timeout = 150000;
                _parent.Trace("Single TV Episode Selection: " + _parent.IP + ":" + _parent.Port);

                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 TV Episodes Selection Result ------" + json);

                        var deserializer = new JavaScriptSerializer();
                        deserializer.MaxJsonLength = Int32.MaxValue;
                        var ItemData = deserializer.Deserialize <TVEpisodes.Rootobject>(json);
                        _parent.Trace("---------------Get Single TV Episode Selection:  Issue: Results.Taglines: " + ItemData.TotalRecordCount);

                        foreach (var genre in ItemData.Items)
                        {
                            try
                            {
                                //Use Path to pass data on Item Number to play as API Long can't hold
                                //var SingleTVData = GetSingleTVFromSeries(genre.Id);
                                var tvShow = new ApiTvEpisode
                                {
                                    Title     = genre.Name ?? "",
                                    Plot      = "",
                                    Rating    = genre.OfficialRating ?? "",
                                    Mpaa      = "",
                                    Date      = genre.PremiereDate.ToString(),
                                    Director  = "",
                                    PlayCount = genre.UserData.PlayCount,
                                    Studio    = "",
                                    IdEpisode = Xbmc.IDtoNumber(genre.Id),
                                    IdShow    = Xbmc.IDtoNumber(genre.SeriesId),
                                    Season    = genre.ParentIndexNumber,
                                    Episode   = genre.IndexNumber,
                                    Path      = genre.Id ?? "",
                                    ShowTitle = genre.SeriesName ?? "",
                                    Thumb     = "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + genre.Id + "/Images/Primary" ?? "",
                                    Fanart    = "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + genre.SeriesId + "/Images/Backdrop" ?? "",
                                    Hash      = Xbmc.Hash(genre.Id)
                                };
                                episodes.Add(tvShow);
                            }
                            catch (Exception ex)
                            {
                                _parent.Trace("TV Shows Exception Caught " + ex);
                            }
                        }
                    }
                }
            }
            catch (Exception Ex)
            {
                _parent.Trace("Another tV Episodes exception" + Ex);
            }

            /*
             * var properties = new JsonArray(new[] { "title", "plot", "season", "episode", "showtitle", "tvshowid", "fanart", "thumbnail", "rating", "playcount", "firstaired" });
             * var param = new JsonObject();
             * param["properties"] = properties;
             * var result = (JsonObject)_parent.JsonCommand("VideoLibrary.GetEpisodes", param);
             * if (result != null)
             * {
             * if (result.Contains("episodes"))
             * {
             *  foreach (JsonObject genre in (JsonArray)result["episodes"])
             *  {
             *    try
             *    {
             *      var tvShow = new ApiTvEpisode
             *        {
             *          Title = genre["title"].ToString(),
             *          Plot = genre["plot"].ToString(),
             *          Rating = genre["rating"].ToString(),
             *          Mpaa = "",
             *          Date = genre["firstaired"].ToString(),
             *          Director = "",
             *          PlayCount = 0,
             *          Studio = "",
             *          IdEpisode = (long)(JsonNumber)genre["episodeid"],
             *          IdShow = (long)(JsonNumber)genre["tvshowid"],
             *          Season = (long)(JsonNumber)genre["season"],
             *          Episode = (long)(JsonNumber)genre["episode"],
             *          Path = "",
             *          ShowTitle = genre["showtitle"].ToString(),
             *          Thumb = genre["thumbnail"].ToString(),
             *          Fanart = genre["fanart"].ToString(),
             *          Hash = Xbmc.Hash(genre["thumbnail"].ToString())
             *        };
             *      episodes.Add(tvShow);
             *    }
             *    catch (Exception)
             *    {
             *    }
             *  }
             * }
             * }
             */
            return(episodes);
        }
Exemple #6
0
 public XbmcRemote(Xbmc parent)
 {
     _parent = parent;
 }
 public XbmcAudioLibrary(Xbmc parent)
 {
     _parent = parent;
 }
        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);
        }
Exemple #9
0
        //private readonly BackgroundWorker _bw = new BackgroundWorker{WorkerSupportsCancellation = true};

        public XbmcAudioPlayer(Xbmc parent)
        {
            _parent = parent;
            //_bw.DoWork += AsyncPlayFilesWorker;
        }
Exemple #10
0
 public XbmcRemote(Xbmc parent)
 {
     _parent = parent;
 }
Exemple #11
0
 public XbmcFile(Xbmc parent)
 {
     _parent = parent;
     _workerDownloads = new BackgroundWorker { WorkerSupportsCancellation = true };
     _workerDownloads.DoWork += AsyncImagesDownloadsWorker;
 }
Exemple #12
0
 public XbmcVideoPlayer(Xbmc parent)
 {
     _parent = parent;
 }
 public XbmcVideoLibrary(Xbmc parent)
 {
     _parent = parent;
 }
Exemple #14
0
 public XbmcPlayer(Xbmc parent)
 {
     _parent = parent;
 }
Exemple #15
0
 public XbmcPlayer(Xbmc parent)
 {
     _parent = parent;
 }
        public Collection <ApiAudioGenre> GetGenres()
        {
            var MusicID = GetMainSelection("Genres");  //Genres bit no longer needed
            // Change away from GetMainSelection which is no longer working
            // Use Emby Genres to get info.

            var genres = new Collection <ApiAudioGenre>();

            try
            {
                _parent.Trace("Getting Music Genres: Parent IP: " + _parent.IP);
                string NPurl   = "http://" + _parent.IP + ":" + _parent.Port + "/MusicGenres?ParentId=" + MusicID;
                var    request = WebRequest.CreateHttp(NPurl);
                request.Method  = "get";
                request.Timeout = 150000;
                _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();
//REMOTETHIS        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 Music Genres Selection Result ------" + json);

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

                        foreach (var genre in ItemData.Items)
                        {
                            try
                            {
                                var gen = new ApiAudioGenre
                                {
                                    IdGenre    = Xbmc.IDtoNumber(genre.Id),
                                    Name       = genre.Name ?? "",
                                    AlbumCount = 0, //genre.ChildCount,
                                    Thumb      = "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + genre.Id + "/Images/Primary" ?? ""
                                };
                                genres.Add(gen);
                            }
                            catch (Exception ex)
                            {
                                _parent.Trace("Music Genres Exception Caught " + ex);
                            }
                        }
                    }
                }
            }
            catch (Exception Ex)
            {
                _parent.Trace("Another Music Genres exception" + Ex);
            }


            return(genres);
        }
 public XbmcVideoPlayer(Xbmc parent)
 {
     _parent = parent;
 }
        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);
        }
Exemple #19
0
 public XbmcSystem(Xbmc parent)
 {
     _parent = parent;
 }
        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);
            }
        }
Exemple #21
0
 public MpcHcRemote(Xbmc parent)
 {
     _parent = parent;
 }
 public XbmcAudioLibrary(Xbmc parent)
 {
     _parent = parent;
 }
 public XbmcPicturePlayer(Xbmc parent)
 {
     _parent = parent;
 }
Exemple #24
0
        public Collection <ApiTvShow> GetTvShows()
        {
            //var MovieId = GetMainSelection("TV");
            var shows = new Collection <ApiTvShow>();

            try
            {
                _parent.Trace("Getting TV Shows" + _parent.IP);
                string NPurl = "http://" + _parent.IP + ":" + _parent.Port + "/emby/Users/" + Globals.CurrentUserID + "/Items?Recursive=true&IncludeItemTypes=Series";

                var request = WebRequest.CreateHttp(NPurl);

                request.Method  = "get";
                request.Timeout = 150000;
                _parent.Trace("Single TV Show Selection: " + _parent.IP + ":" + _parent.Port);

                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 Single TV Show Selection Result ------" + json);

                        var deserializer = new JavaScriptSerializer();

                        var ItemData = deserializer.Deserialize <TVShows.Rootobject>(json);
                        _parent.Trace("---------------Get Single TV Show Selection:  Issue: Results.Taglines: " + ItemData.TotalRecordCount);

                        foreach (var genre in ItemData.Items)
                        {
                            try
                            {
                                var SingleTVData = GetSingleTVFromSeries(genre.Id);

                                var tvShow = new ApiTvShow
                                {
                                    Title      = genre.Name ?? "Unknown",
                                    Plot       = SingleTVData.Overview ?? "",
                                    Rating     = genre.CommunityRating.ToString() ?? "",
                                    IdScraper  = "",
                                    Mpaa       = SingleTVData.OfficialRating ?? "Unknown",
                                    Genre      = SingleTVData.Genres.FirstOrDefault().ToString() ?? "",
                                    Studio     = SingleTVData.Studios.FirstOrDefault().Name.ToString() ?? "",
                                    IdShow     = Xbmc.IDtoNumber(genre.Id),
                                    TotalCount = genre.RecursiveItemCount,
                                    Path       = SingleTVData.Path ?? "",
                                    Premiered  = genre.PremiereDate.ToString() ?? "",
                                    Thumb      = "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + genre.Id + "/Images/Primary" ?? "",
                                    Fanart     = "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + genre.Id + "/Images/Backdrop" ?? "",
                                    Hash       = Xbmc.Hash(genre.Id)
                                };

                                shows.Add(tvShow);
                            }
                            catch (Exception ex)
                            {
                                _parent.Trace("TV Shows Exception Caught " + ex);
                            }
                        }
                    }
                }
            }
            catch (Exception Ex)
            {
                _parent.Trace("Another tV SHows exception" + Ex);
            }

            return(shows);
        }
 public XbmcPicturePlayer(Xbmc parent)
 {
     _parent = parent;
 }
Exemple #26
0
        public Collection <ApiTvSeason> GetTvSeasons()
        {
            var seasons = new Collection <ApiTvSeason>();

            try
            {
                _parent.Trace("Getting TV Seasons" + _parent.IP);
                string NPurl = "http://" + _parent.IP + ":" + _parent.Port + "/emby/Users/" + Globals.CurrentUserID + "/Items?Recursive=true&IncludeItemTypes=Season";

                var request = WebRequest.CreateHttp(NPurl);

                request.Method  = "get";
                request.Timeout = 150000;
                _parent.Trace("Single TV Season Selection: " + _parent.IP + ":" + _parent.Port);

                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 Single TV Season Selection Result ------" + json);

                        var deserializer = new JavaScriptSerializer();

                        var ItemData = deserializer.Deserialize <TVSeasons.Rootobject>(json);
                        _parent.Trace("---------------Get Single TV Season Selection:  Issue: Results.Taglines: " + ItemData.TotalRecordCount);

                        foreach (var genre in ItemData.Items)
                        {
                            try
                            {
                                //var SingleTVData = GetSingleTVFromSeries(genre.Id);

                                var tvShow = new ApiTvSeason
                                {
                                    SeasonNumber = genre.IndexNumber,
                                    IdShow       = Xbmc.IDtoNumber(genre.SeriesId),
                                    Show         = genre.SeriesName ?? "",
                                    Thumb        = "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + genre.Id + "/Images/Primary" ?? "",
                                    EpisodeCount = genre.ChildCount,
                                    Fanart       = "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + genre.SeriesId + "/Images/Backdrop" ?? "",
                                    Hash         = Xbmc.Hash(genre.Id)
                                };
                                seasons.Add(tvShow);

/*
 *                        var tvShow = new ApiTvShow
 *                        {
 *
 *                            Title = genre.Name ?? "Unknown",
 *                            Plot = SingleTVData.Overview ?? "",
 *                            Rating = genre.CommunityRating.ToString() ?? "",
 *                            IdScraper = "",
 *                            Mpaa = SingleTVData.OfficialRating ?? "Unknown",
 *                            Genre = SingleTVData.Genres.FirstOrDefault().ToString() ?? "",
 *                            Studio = SingleTVData.Studios.FirstOrDefault().Name.ToString() ?? "",
 *                            IdShow = Xbmc.IDtoNumber(genre.Id),
 *                            TotalCount = genre.RecursiveItemCount,
 *                            Path = SingleTVData.Path ?? "",
 *                            Premiered = genre.PremiereDate.ToString() ?? "",
 *                            Thumb = "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + genre.Id + "/Images/Primary" ?? "",
 *                            Fanart = "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + genre.Id + "/Images/Backdrop" ?? "",
 *                            Hash = Xbmc.Hash(genre.Id)
 *
 *                        };
 *
 *                        shows.Add(tvShow);*/
                            }
                            catch (Exception ex)
                            {
                                _parent.Trace("TV Shows Exception Caught " + ex);
                            }
                        }
                    }
                }
            }
            catch (Exception Ex)
            {
                _parent.Trace("Another tV SHows exception" + Ex);
            }


            /*
             * var properties = new Jayrock.Json.JsonArray(new[] { "title" });
             * var param = new JsonObject();
             * param["properties"] = properties;
             *
             *
             * var result = (JsonObject)_parent.JsonCommand("VideoLibrary.GetTVShows", param);
             *
             *
             * if (result != null)
             * {
             *  if (result.Contains("tvshows"))
             *  {
             *    foreach (JsonObject show in (JsonArray)result["tvshows"])
             *    {
             *      var properties2 =
             *        new JsonArray(new[] { "tvshowid", "fanart", "thumbnail", "season", "showtitle", "episode" });
             *      var param2 = new JsonObject();
             *      param2["properties"] = properties2;
             *      param2["tvshowid"] = (long)(JsonNumber)show["tvshowid"];
             *      var result2 = (JsonObject)_parent.JsonCommand("VideoLibrary.GetSeasons", param2);
             *      if (result2 == null) continue;
             *      if (!result2.Contains("seasons")) continue;
             *      foreach (JsonObject genre in (JsonArray)result2["seasons"])
             *      {
             *        try
             *        {
             *          var tvShow = new ApiTvSeason
             *            {
             *              SeasonNumber = (long)(JsonNumber)genre["season"],
             *              IdShow = (long)(JsonNumber)genre["tvshowid"],
             *              Show = genre["showtitle"].ToString(),
             *              Thumb = genre["thumbnail"].ToString(),
             *              EpisodeCount = (long)(JsonNumber)genre["episode"],
             *              Fanart = genre["fanart"].ToString(),
             *              Hash = Xbmc.Hash(genre["thumbnail"].ToString())
             *            };
             *          seasons.Add(tvShow);
             *        }
             *        catch (Exception)
             *        {
             *        }
             *      }
             *    }
             *  }
             * }
             */
            return(seasons);
        }
Exemple #27
0
        public Collection <ApiAudioAlbum> GetAlbums()
        {
            var albums = new Collection <ApiAudioAlbum>();

            var AlbumID = GetMainSelection("Albums");


            try
            {
                _parent.Trace("Getting Album ARtists: Parent IP: " + _parent.IP);
                string NPurl   = "http://" + _parent.IP + ":" + _parent.Port + "/emby/Users/" + Globals.CurrentUserID + "/Items?ParentId=" + AlbumID;
                var    request = WebRequest.CreateHttp(NPurl);
                request.Method  = "get";
                request.Timeout = 150000;
                _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);

                        foreach (var genre in ItemData.Items)
                        {
                            try
                            {
                                var album = new ApiAudioAlbum
                                {
                                    IdAlbum  = Xbmc.IDtoNumber(genre.Id),
                                    Title    = genre.Name ?? "",
                                    IdGenre  = 0,
                                    IdArtist = 0,
                                    Artist   = genre.AlbumArtist ?? "",
                                    Genre    = "",
                                    Year     = genre.ProductionYear,
                                    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);
        }
Exemple #28
0
        //private readonly BackgroundWorker _bw = new BackgroundWorker{WorkerSupportsCancellation = true};

        public XbmcAudioPlayer(Xbmc parent)
        {
            _parent = parent;
            //_bw.DoWork += AsyncPlayFilesWorker;
        }
Exemple #29
0
 public XbmcSystem(Xbmc parent)
 {
     _parent = parent;
 }