internal static XbmcVideo FromJson(JObject obj) { if (obj == null) { return(null); } try { // If there is a showtitle field and it has a value, the retrieved item is a XbmcTvEpisode if (obj["showtitle"] != null && !string.IsNullOrEmpty(JsonRpcClient.GetField <string>(obj, "showtitle"))) { return(XbmcTvEpisode.FromJson(obj)); } // If there is a artist field and it has a vaue, the retrieved item is a XbmcMusicVideo if (obj["artist"] != null && !string.IsNullOrEmpty(JsonRpcClient.GetField <string>(obj, "artist"))) { return(XbmcMusicVideo.FromJson(obj)); } // Otherwise it must be a movie return(XbmcMovie.FromJson(obj)); } catch (Exception ex) { return(null); } }
internal static XbmcVideo FromJson(JObject obj, JsonRpcClient logger) { if (obj == null) { return(null); } try { string type; if (obj["type"] == null) { type = "unknown"; } else { type = JsonRpcClient.GetField <string>(obj, "type"); } if (logger != null) { logger.LogMessage("Trying to identify " + type); } if ("episode" == type) { return(XbmcTvEpisode.FromJson(obj, logger)); } if ("musicvideo" == type) { return(XbmcMusicVideo.FromJson(obj, logger)); } if ("movie" == type) { return(XbmcMovie.FromJson(obj, logger)); } // Otherwise try a movie //else if () //{ if (logger != null) { logger.LogMessage("Trying to identify Unhandled type of media as movie"); } return(XbmcMovie.FromJson(obj, logger)); //} } catch (Exception ex) { if (logger != null) { logger.LogErrorMessage("EXCEPTION in XbmcVideo.FromJson()!!!", ex); } return(null); } }
public ICollection <XbmcMovie> GetRecentlyAddedMovies(int start, int end, params string[] fields) { this.client.LogMessage("XbmcVideoLibrary.GetRecentlyAddedMovies()"); JObject args = new JObject(); if (fields != null && fields.Length > 0) { string[] fieldCopy = new string[fields.Length + 2]; fieldCopy[0] = "movieid"; fieldCopy[1] = "title"; Array.Copy(fields, 0, fieldCopy, 2, fields.Length); args.Add(new JProperty("fields", fieldCopy)); } else { args.Add(new JProperty("fields", XbmcMovie.Fields)); } JObject limits = new JObject(); if (start >= 0) { limits.Add(new JProperty("start", start)); } if (end >= 0) { limits.Add(new JProperty("end", end)); } args.Add(new JProperty("limits", limits)); JObject query = this.client.Call("VideoLibrary.GetRecentlyAddedMovies", args) as JObject; if (query == null || query["movies"] == null) { this.client.LogErrorMessage("VideoLibrary.GetRecentlyAddedMovies(): Invalid response"); return(null); } List <XbmcMovie> movies = new List <XbmcMovie>(); foreach (JObject item in (JArray)query["movies"]) { movies.Add(XbmcMovie.FromJson(item, this.client)); } return(movies); }
public bool Play(XbmcMovie movie) { this.client.LogMessage("XbmcGeneral.Play(movie)"); if (movie == null) { throw new ArgumentNullException("movie"); } if (movie.Id < 0) { throw new ArgumentException("Invalid movie ID"); } JObject args = new JObject(); args.Add(new JProperty("movieid", movie.Id)); return(this.client.Call("XBMC.Play", args) != null); }
private static List<string> buildMovieInfo(ICollection<string> patterns, XbmcMovie movie) { Dictionary<string, string> data = new Dictionary<string, string>(12); data.Add("title", movie.Title); data.Add("year", movie.Year.ToString()); data.Add("rating", movie.Rating.ToString("0.#")); data.Add("genre", movie.Genre); data.Add("duration", movie.Duration.TotalMinutes.ToString("0")); data.Add("mpaa", movie.Mpaa); data.Add("tagline", movie.Tagline); data.Add("studio", movie.Studio); data.Add("director", movie.Director); data.Add("writer", movie.Writer); data.Add("outline", movie.Outline); data.Add("plot", movie.Plot); return buildInfoText(patterns, data); }
public bool Play(XbmcMovie movie) { this.client.LogMessage("XbmcGeneral.Play(movie)"); if (movie == null) { throw new ArgumentNullException("movie"); } if (movie.Id < 0) { throw new ArgumentException("Invalid movie ID"); } JObject args = new JObject(); args.Add(new JProperty("movieid", movie.Id)); return (this.client.Call("XBMC.Play", args) != null); }