Esempio n. 1
0
        public void PlayMovie(ApiMovie video)
        {
            if (video == null)
                return;
            if (!_parent.IsConnected())
                return;

            EmbyPlayPlayList(video.Path);
            _parent.Trace("Attemping to Play IdEpsiode equals" + video.Path);

            /*
            var args = new JsonObject();
            var items = new JsonObject();
            args["movieid"] = video.IdMovie;
            items["item"] = args;
            items["playlistid"] = 1;
            var plId = new JsonObject();
            plId["playlistid"] = 1;
            var item = new JsonObject();
            item["item"] = plId;
            _parent.JsonCommand("Playlist.Clear", plId);
            _parent.JsonCommand("Playlist.Add", items);
            _parent.JsonCommand("Player.Open", item);
            */

        }
Esempio n. 2
0
 public void PlayMovie(ApiMovie video)
 {
     if (video == null)
         return;
     if (!_parent.IsConnected())
         return;
     var file = (video.IsStack != 1) ? video.Path + video.FileName : video.FileName;
     _parent.AsyncCommand("PlayFile", file);
 }
Esempio n. 3
0
        public Collection<ApiMovie> GetMovies()
        {
            var movies = new Collection<ApiMovie>();
            var dblines = _parent.DBCommand("video","SELECT c00,c01,c03,c04,c05,c07,C09,c11,c12,c14,c15,c16,c18,idFile,idMovie,strFileName,strPath,playCount FROM movieview");
            if (dblines == null) return movies;
            foreach (var dbline in dblines)
            {
                if (dbline.Length < 18)
                {
                    _parent.Log("Invalid request DATA : " + dbline);
                    continue;
                }
                dbline[4] = dbline[4].Length > 3 ? dbline[4] : "0.0";
                var movie = new ApiMovie
                                {
                                    Title = dbline[0],
                                    Plot = dbline[1],
                                    Tagline = dbline[2],
                                    Votes = dbline[3],
                                    Rating = dbline[4].Substring(0, 3).Trim('.'),
                                    Year = Xbmc.StringToNumber(dbline[5]),
                                    IdScraper = dbline[6],
                                    Length = dbline[7],
                                    Mpaa = dbline[8],
                                    Genre = dbline[9],
                                    Director = dbline[10],
                                    OriginalTitle = dbline[11],
                                    Studio = dbline[12],
                                    IdFile = Xbmc.StringToNumber(dbline[13]),
                                    IdMovie = Xbmc.StringToNumber(dbline[14]),
                                    FileName = dbline[15],
                                    Path = dbline[16],
                                    PlayCount = Xbmc.StringToNumber(dbline[17])
                                };

                if (movie.FileName.StartsWith("stack://",StringComparison.OrdinalIgnoreCase))
                {
                    var temp = movie.FileName.Split(new[] { " , " }, StringSplitOptions.None);
                    movie.IsStack = 1;
                    movie.Hash = Xbmc.Hash(temp[0].Replace("stack://", ""));
                    movie.Thumb = @"special://profile/Thumbnails/Video/" + movie.Hash[0] + "/" + movie.Hash + ".tbn";
                    movie.Fanart = @"special://profile/Thumbnails/Video/Fanart/" + Xbmc.Hash(movie.FileName) + ".tbn";
                }
                else
                {
                    movie.IsStack = 0;
                    movie.Hash = Xbmc.Hash(movie.Path + movie.FileName);
                    movie.Thumb = @"special://profile/Thumbnails/Video/" + movie.Hash[0] + "/" + movie.Hash + ".tbn";
                    movie.Fanart = @"special://profile/Thumbnails/Video/Fanart/" + movie.Hash + ".tbn";
                }

                movies.Add(movie);
            }
            return movies;
        }
Esempio n. 4
0
        public void PlayMovie(ApiMovie video)
        {
            if (video == null)
                return;
            if (!_parent.IsConnected())
                return;

            var args = new JsonObject();
            args["movieid"] = video.IdMovie;
            _parent.AsyncJsonCommand("XBMC.Play", args);
        }
 public void PlayMovie(ApiMovie video)
 {
     if (video == null)
         return;
     if (!_parent.IsConnected())
         return;
     if (video.IdFile == 0)
         _parent.AsyncIPimpCommand(new CommandInfoIPimp { Action = "playmovie", Filter = video.IdMovie.ToString(CultureInfo.InvariantCulture) , Value = "force" , Tracks = "no" });
     if (video.IdFile == 1)
         _parent.AsyncIPimpCommand(new CommandInfoIPimp { Action = "playmovingpicture", Filter = video.IdMovie.ToString(CultureInfo.InvariantCulture), Value = "force", Tracks = "no" });
 }
Esempio n. 6
0
        public void PlayMovie(ApiMovie video)
        {
            if (video == null)
                return;
            if (!_parent.IsConnected())
                return;

            var args = new JsonObject();
            var items = new JsonObject();
            args["movieid"] = video.IdMovie;
            items["item"] = args;
            items["playlistid"] = 1;
            var plId = new JsonObject();
            plId["playlistid"] = 1;
            var item = new JsonObject();
            item["item"] = plId;
            _parent.JsonCommand("Playlist.Clear", plId);
            _parent.JsonCommand("Playlist.Add", items);
            _parent.JsonCommand("Player.Open", item);
        }
Esempio n. 7
0
    public Collection<ApiMovie> GetMovies()
    {
      var movies = new Collection<ApiMovie>();

      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;
    }
Esempio n. 8
0
 public void PlayMovie(ApiMovie video)
 {
 }
        public Collection<ApiMovie> GetMovies()
        {
            var movies = new Collection<ApiMovie>();
            if (!_parent.IsConnected())
                return movies;
            var dblines = _parent.IPimpDBCommand(new CommandInfoIPimp { Action = "getallmovies" }, "movies");
            if (dblines == null) return movies;

            foreach (JsonObject dbline in dblines)
            {
                var movie = new ApiMovie
                {
                    Title = (string)dbline["title"],
                    Plot = (string)dbline["plot"],
                    Tagline = (string)dbline["tagline"],
                    Votes = (string)dbline["votes"],
                    Rating = Convert.ToDouble(((string)dbline["rating"]).Replace(',','.'), CultureInfo.InvariantCulture).ToString(CultureInfo.InvariantCulture),
                    Year = Convert.ToInt32(dbline["year"], CultureInfo.InvariantCulture),
                    IdScraper = (string)dbline["imdbNumber"],
                    Length = "",
                    Mpaa = (string)dbline["mpaa"],
                    Genre = (string)dbline["genre"],
                    Director = (string)dbline["director"],
                    OriginalTitle = (string)dbline["originaltitle"],
                    Studio = "",
                    IdFile = 0,
                    IdMovie = Convert.ToInt32(dbline["id"], CultureInfo.InvariantCulture),
                    FileName = (string)dbline["files"],
                    Path = (string)dbline["path"],
                    PlayCount = Convert.ToInt32(dbline["watched"], CultureInfo.InvariantCulture),
                    Thumb = (string)dbline["thumb"],
                    Fanart = (string)dbline["fanart"],
                    Hash = MediaPortal.Hash((string)dbline["files"])
                };

                movies.Add(movie);
            }

            dblines = _parent.IPimpDBCommand(new CommandInfoIPimp { Action = "getallmovingpicture" }, "movies");
            if (dblines == null) return movies;

            foreach (JsonObject dbline in dblines)
            {
                var movie = new ApiMovie
                {
                    Title = (string)dbline["title"],
                    Plot = (string)dbline["plot"],
                    Tagline = (string)dbline["tagline"],
                    Votes = (string)dbline["votes"],
                    Rating = Convert.ToDouble(((string)dbline["rating"]).Replace(',', '.'), CultureInfo.InvariantCulture).ToString(CultureInfo.InvariantCulture),
                    Year = Convert.ToInt32(dbline["year"], CultureInfo.InvariantCulture),
                    IdScraper = (string)dbline["imdbNumber"],
                    Length = "",
                    Mpaa = (string)dbline["mpaa"],
                    Genre = (string)dbline["genre"],
                    Director = (string)dbline["director"],
                    OriginalTitle = (string)dbline["originaltitle"],
                    Studio = "",
                    IdFile = 1,
                    IdMovie = Convert.ToInt32(dbline["id"], CultureInfo.InvariantCulture),
                    FileName = (string)dbline["files"],
                    Path = (string)dbline["path"],
                    PlayCount = Convert.ToInt32(dbline["watched"], CultureInfo.InvariantCulture),
                    Thumb = (string)dbline["thumb"],
                    Fanart = (string)dbline["fanart"],
                    Hash = MediaPortal.Hash((string)dbline["files"])
                };

                movies.Add(movie);
            }

            return movies;
        }
Esempio n. 10
0
 public Yatse2Movie(ApiMovie apiMovie)
 {
     if (apiMovie == null)
         return;
     FileName = apiMovie.FileName;
     Path = apiMovie.Path;
     Plot = apiMovie.Plot;
     Title = apiMovie.Title;
     Mpaa = apiMovie.Mpaa;
     OriginalTitle = apiMovie.OriginalTitle;
     Genre = apiMovie.Genre;
     Tagline = apiMovie.Tagline;
     Director = apiMovie.Director;
     IdFile = apiMovie.IdFile;
     IdScraper = apiMovie.IdScraper;
     IdMovie = apiMovie.IdMovie;
     Thumb = apiMovie.Thumb;
     Fanart = apiMovie.Fanart;
     Banner = apiMovie.Banner;
     Logo = apiMovie.Logo;
     Hash = apiMovie.Hash;
     IsStack = apiMovie.IsStack;
     Length = apiMovie.Length;
     PlayCount = apiMovie.PlayCount;
     Rating = apiMovie.Rating;
     Studio = apiMovie.Studio;
     Votes = apiMovie.Votes;
     Year = apiMovie.Year;
     DateAdded = apiMovie.DateAdded;
     MovieIcons = apiMovie.MovieIcons;
 }
Esempio n. 11
0
 public ApiMovie ToApi()
 {
     var api = new ApiMovie
                   {
                       Director = Director,
                       Fanart = Fanart,
                       FileName = FileName,
                       Genre = Genre,
                       Hash = Hash,
                       IdFile = IdFile,
                       IdMovie = IdMovie,
                       IdScraper = IdScraper,
                       IsStack = IsStack,
                       Length = Length,
                       Mpaa = Mpaa,
                       OriginalTitle = OriginalTitle,
                       Path = Path,
                       PlayCount = PlayCount,
                       Plot = Plot,
                       Rating = Rating,
                       Studio = Studio,
                       Tagline = Tagline,
                       Thumb = Thumb,
                       Banner = Banner,
                       Logo = Logo,
                       Title = Title,
                       Votes = Votes,
                       Year = Year,
                       DateAdded = DateAdded,
                       MovieIcons = MovieIcons
                   };
     return api;
 }
Esempio n. 12
0
        public Collection<ApiMovie> GetMovies()
    {
      var movies = new Collection<ApiMovie>();

        //add dateadded

      var properties = new JsonArray(new[] { "title", "art","streamdetails","plot", "dateadded", "genre", "year", "fanart", "thumbnail", "playcount", "studio", "rating", "runtime", "mpaa", "originaltitle", "director", "votes", "file" });
      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 clearlogo = "NONE";
              var banner = "NONE";
                            // go through art and see.

               JsonObject results = (JsonObject)genre["art"];

              if (results != null)
              {
                                if (results["clearlogo"] != null)
                                {
                                    clearlogo = results["clearlogo"].ToString();
                                }
                                if (results["banner"] != null)
                                {
                                    banner = results["banner"].ToString();
                                }
               }

               JsonObject streamdetails = (JsonObject)genre["streamdetails"];
               List<string> MovieIcons = new List<string>();
               MovieIcons = GetMovieIcons(streamdetails);

                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 = genre["file"].ToString(),
                  Path = "",
                  PlayCount = 0,
                  Thumb = genre["thumbnail"].ToString(),
                  Fanart = genre["fanart"].ToString(),
                  Logo = clearlogo,
                  Banner = banner,
                  Hash = Xbmc.Hash(genre["thumbnail"].ToString()),
                  DateAdded = genre["dateadded"].ToString(),
                  MovieIcons = String.Join(",", MovieIcons)
                };
              movies.Add(movie);
            }
            catch (Exception ex)
            {
                            _parent.Log("Exception Caught: Json Clearlogo seems to equal :" + ex);
            }
          }
        }
      }

      return movies;
    }
Esempio n. 13
0
        public Collection<ApiMovie> GetMoviesRefresh()
        {
            {
                var movies = new Collection<ApiMovie>();
                List<string> MovieId = GetMainSelection("movies");

                try
                {
                    foreach (string MovieDirectory in MovieId)
                    {


                        try
                        {

                            _parent.Trace("Getting Main Movie Database Result" + _parent.IP);
                            string NPurl = "http://" + _parent.IP + ":" + _parent.Port + "/emby/Users/" + Globals.CurrentUserID + "/Items?Limit=30&SortBy=DateCreated&SortOrder=Descending&ParentId=" + MovieDirectory;
                            _parent.Trace("Getting Main Movie Database Refresh URL Called" + NPurl);
                            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);

                                            List<string> MovieIcons = new List<string>();

                                            // if null equals null-  doesn't make much sense but no harm.  Perhaps change to empty later.
                                            // needs to be empty otherwise will fail with null exception down further
                                            //

                                            MovieIcons = GetMovieIcons(Movieitem);


                                            

                                            string newDirector = "";

                                            bool index = Movieitem.People.Any(item => item.Type == "Director");
                                            if (index == true)
                                            {
                                                newDirector = Movieitem.People.First(i => i.Type == "Director").Name.ToString();
                                            }

                                            string Taglines = "";
                                            if (Movieitem.Taglines != null && Movieitem.Taglines.Length != 0)
                                            {
                                                if (Movieitem.Taglines.FirstOrDefault() != null)
                                                {
                                                    Taglines = Movieitem.Taglines.FirstOrDefault().ToString();
                                                }
                                            }
                                            string Studios = "";
                                            if (Movieitem.Studios != null && Movieitem.Studios.Length != 0)
                                            {
                                                if (Movieitem.Studios.FirstOrDefault() != null)
                                                {
                                                    Studios = Movieitem.Studios.FirstOrDefault().Name.ToString();
                                                }
                                            }



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

                                            _parent.Trace("VideoLibrary Check:");
                                            _parent.Trace(Movieitem.Name ?? "Unknown");
                                            _parent.Trace(Movieitem.Overview ?? "Unknown");
                                            _parent.Trace(Movieitem.VoteCount.ToString() ?? "0");
                                            _parent.Trace(id.CommunityRating.ToString() ?? "0");
                                            _parent.Trace(id.ProductionYear.ToString() ?? "nil Production Year:");
                                            _parent.Trace(Taglines);
                                            _parent.Trace(Movieitem.ProviderIds.Imdb ?? "");
                                            _parent.Trace(new TimeSpan(0, 0, 0, Convert.ToInt32(RoundSeconds)).ToString() ?? "Unknown");
                                            _parent.Trace(id.OfficialRating ?? "Unknown");
                                            _parent.Trace(Movieitem.Genres.FirstOrDefault() ?? "Unknown");
                                            _parent.Trace(newDirector ?? "");
                                            _parent.Trace(id.Name ?? "");
                                            _parent.Trace(Studios);
                                            _parent.Trace(Xbmc.IDtoNumber(Movieitem.Id).ToString());
                                            _parent.Trace(Movieitem.Path.ToString() ?? "");
                                            _parent.Trace(Movieitem.Id ?? "");
                                            _parent.Trace(Movieitem.UserData.PlayCount.ToString() ?? "nilPlayCount");
                                            _parent.Trace("http://" + _parent.IP + ":" + _parent.Port + "/Items/" + id.Id + "/Images/Primary");
                                            _parent.Trace("http://" + _parent.IP + ":" + _parent.Port + "/Items/" + id.Id + "/Images/Backdrop");
                                            _parent.Trace(Xbmc.Hash(id.Id));
                                            _parent.Trace("MovieIcons Set:" + String.Join(",", MovieIcons));



                                            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 ?? 1901,
                                                Tagline = Taglines,
                                                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 = Studios,
                                                IdFile = 0,
                                                IdMovie = Xbmc.IDtoNumber(Movieitem.Id),
                                                FileName = Movieitem.Path.ToString() ?? "",
                                                Path = Movieitem.Id ?? "",
                                                PlayCount = Movieitem.UserData.PlayCount ?? 0,
                                                Thumb = "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + id.Id + "/Images/Primary",
                                                Banner = "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + id.Id + "/Images/Banner",
                                                Logo = "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + id.Id + "/Images/Logo",
                                                Fanart = "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + id.Id + "/Images/Backdrop",
                                                Hash = Xbmc.Hash(id.Id),
                                                DateAdded = Movieitem.DateCreated.ToString("s"),
                                                MovieIcons = String.Join(",",MovieIcons)
                                            };
                                            movies.Add(movie);
                                        }

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

                                        }
                                    }




                                }

                            }


                        }
                        catch (Exception ex)
                        {
                            _parent.Trace("ERROR in Main Movies obtaining: " + ex);


                        }


                    }
                    return movies;
                }
                catch (Exception ex)
                {
                    _parent.Trace("Error in List Array for Main Selection:" + ex);
                    return null;
                }
            }
        }