internal static new XbmcTvEpisode FromJson(JObject obj) { if (obj == null) { return(null); } try { return(new XbmcTvEpisode(JsonRpcClient.GetField <int>(obj, "episodeid"), JsonRpcClient.GetField <string>(obj, "thumbnail"), JsonRpcClient.GetField <string>(obj, "fanart"), JsonRpcClient.GetField <string>(obj, "file"), JsonRpcClient.GetField <string>(obj, "title"), JsonRpcClient.GetField <int>(obj, "year"), JsonRpcClient.GetField <double>(obj, "rating"), JsonRpcClient.GetField <string>(obj, "director", string.Empty), JsonRpcClient.GetField <string>(obj, "plot", string.Empty), JsonRpcClient.GetField <string>(obj, "lastplayed", string.Empty), JsonRpcClient.GetField <string>(obj, "showtitle"), JsonRpcClient.GetField <string>(obj, "firstaired"), JsonRpcClient.GetField <int>(obj, "duration"), JsonRpcClient.GetField <int>(obj, "season"), JsonRpcClient.GetField <int>(obj, "episode"), JsonRpcClient.GetField <int>(obj, "playcount"), JsonRpcClient.GetField <string>(obj, "writer", string.Empty), JsonRpcClient.GetField <string>(obj, "studio", string.Empty), JsonRpcClient.GetField <string>(obj, "mpaa", string.Empty), JsonRpcClient.GetField <string>(obj, "premiered", string.Empty))); } catch (Exception ex) { return(null); } }
internal static new XbmcMovie FromJson(JObject obj) { if (obj == null) { return(null); } try { return(new XbmcMovie(JsonRpcClient.GetField <int>(obj, "movieid"), JsonRpcClient.GetField <string>(obj, "thumbnail"), JsonRpcClient.GetField <string>(obj, "fanart"), JsonRpcClient.GetField <string>(obj, "file"), JsonRpcClient.GetField <string>(obj, "title"), JsonRpcClient.GetField <string>(obj, "genre", string.Empty), JsonRpcClient.GetField <int>(obj, "year"), JsonRpcClient.GetField <double>(obj, "rating"), JsonRpcClient.GetField <string>(obj, "director", string.Empty), JsonRpcClient.GetField <string>(obj, "trailer", string.Empty), JsonRpcClient.GetField <string>(obj, "tagline", string.Empty), JsonRpcClient.GetField <string>(obj, "plot", string.Empty), JsonRpcClient.GetField <string>(obj, "plotoutline", string.Empty), JsonRpcClient.GetField <string>(obj, "originaltitle", string.Empty), JsonRpcClient.GetField <string>(obj, "lastplayed", string.Empty), JsonRpcClient.GetField <int>(obj, "duration"), JsonRpcClient.GetField <int>(obj, "playcount"), JsonRpcClient.GetField <string>(obj, "writer", string.Empty), JsonRpcClient.GetField <string>(obj, "studio", string.Empty), JsonRpcClient.GetField <string>(obj, "mpaa", string.Empty))); } catch (Exception ex) { return(null); } }
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 XbmcAlbum FromJson(JObject obj, JsonRpcClient logger) { if (obj == null) { return(null); } try { return(new XbmcAlbum(JsonRpcClient.GetField <int>(obj, "albumid"), JsonRpcClient.GetField <string>(obj, "thumbnail"), JsonRpcClient.GetField <string>(obj, "fanart"), JsonRpcClient.GetField <string>(obj, "album_title"), JsonRpcClient.GetField <string>(obj, "album_artist"), JsonRpcClient.GetField <int>(obj, "year"), JsonRpcClient.GetField <int>(obj, "album_rating"), JsonRpcClient.GetField <string>(obj, "album_genre", string.Empty), JsonRpcClient.GetField <string>(obj, "album_mood", string.Empty), JsonRpcClient.GetField <string>(obj, "album_theme", string.Empty), JsonRpcClient.GetField <string>(obj, "album_style", string.Empty), JsonRpcClient.GetField <string>(obj, "album_type", string.Empty), JsonRpcClient.GetField <string>(obj, "album_label", string.Empty), JsonRpcClient.GetField <string>(obj, "album_description", string.Empty))); } catch (Exception ex) { if (logger != null) { logger.LogErrorMessage("EXCEPTION in XbmcAlbum.FromJson()!!!", ex); } return(null); } }
internal static new XbmcTvSeason FromJson(JObject obj, JsonRpcClient logger) { if (obj == null) { return(null); } try { return(new XbmcTvSeason(JsonRpcClient.GetField <string>(obj, "thumbnail"), JsonRpcClient.GetField <string>(obj, "fanart"), JsonRpcClient.GetField <string>(obj, "title"), JsonRpcClient.GetField <string>(obj, "genre", string.Empty), JsonRpcClient.GetField <double>(obj, "rating"), JsonRpcClient.GetField <string>(obj, "showtitle"), JsonRpcClient.GetField <int>(obj, "season"), JsonRpcClient.GetField <int>(obj, "episode"), JsonRpcClient.GetField <int>(obj, "playcount"), JsonRpcClient.GetField <string>(obj, "studio", string.Empty), JsonRpcClient.GetField <string>(obj, "mpaa", string.Empty))); } catch (Exception ex) { if (logger != null) { logger.LogErrorMessage("EXCEPTION in XbmcTvSeason.FromJson()!!!", ex); } return(null); } }
internal static XbmcAlbum FromJson(JObject obj) { if (obj == null) { return(null); } try { return(new XbmcAlbum(JsonRpcClient.GetField <int>(obj, "albumid"), JsonRpcClient.GetField <string>(obj, "thumbnail"), JsonRpcClient.GetField <string>(obj, "fanart"), JsonRpcClient.GetField <string>(obj, "album_title"), JsonRpcClient.GetField <string>(obj, "album_artist"), JsonRpcClient.GetField <int>(obj, "year"), JsonRpcClient.GetField <int>(obj, "album_rating"), JsonRpcClient.GetField <string>(obj, "album_genre", string.Empty), JsonRpcClient.GetField <string>(obj, "album_mood", string.Empty), JsonRpcClient.GetField <string>(obj, "album_theme", string.Empty), JsonRpcClient.GetField <string>(obj, "album_style", string.Empty), JsonRpcClient.GetField <string>(obj, "album_type", string.Empty), JsonRpcClient.GetField <string>(obj, "album_label", string.Empty), JsonRpcClient.GetField <string>(obj, "album_description", string.Empty))); } catch (Exception ex) { return(null); } }
internal static XbmcSong FromJson(JObject obj, JsonRpcClient logger) { if (obj == null) { return(null); } try { return(new XbmcSong(JsonRpcClient.GetField <int>(obj, "songid"), JsonRpcClient.GetField <string>(obj, "thumbnail"), JsonRpcClient.GetField <string>(obj, "fanart"), JsonRpcClient.GetField <string>(obj, "file"), JsonRpcClient.GetField <string>(obj, "title"), JsonRpcClient.GetField <string>(obj, "artist"), JsonRpcClient.GetField <string>(obj, "genre", string.Empty), JsonRpcClient.GetField <int>(obj, "year"), JsonRpcClient.GetField <int>(obj, "rating"), JsonRpcClient.GetField <string>(obj, "album", string.Empty), JsonRpcClient.GetField <int>(obj, "track"), //JsonRpcClient.GetField<int>(obj, "tracknumber"), //JsonRpcClient.GetField<int>(obj, "discnumber"), JsonRpcClient.GetField <int>(obj, "duration"), JsonRpcClient.GetField <string>(obj, "comment", string.Empty), JsonRpcClient.GetField <string>(obj, "lyrics", string.Empty))); } catch (Exception ex) { if (logger != null) { logger.LogErrorMessage("EXCEPTION in XbmcSong.FromJson()!!!", ex); } return(null); } }
internal static new XbmcTvShow FromJson(JObject obj) { if (obj == null) { return(null); } try { return(new XbmcTvShow(JsonRpcClient.GetField <int>(obj, "tvshowid"), JsonRpcClient.GetField <string>(obj, "thumbnail"), JsonRpcClient.GetField <string>(obj, "fanart"), JsonRpcClient.GetField <string>(obj, "title"), JsonRpcClient.GetField <string>(obj, "genre", string.Empty), JsonRpcClient.GetField <int>(obj, "year"), JsonRpcClient.GetField <double>(obj, "rating"), JsonRpcClient.GetField <string>(obj, "plot", string.Empty), JsonRpcClient.GetField <int>(obj, "episode"), JsonRpcClient.GetField <int>(obj, "playcount"), JsonRpcClient.GetField <string>(obj, "studio", string.Empty), JsonRpcClient.GetField <string>(obj, "mpaa", string.Empty), JsonRpcClient.GetField <string>(obj, "premiered", string.Empty))); } catch (Exception ex) { return(null); } }
internal static XbmcSong FromJson(JObject obj) { if (obj == null) { return(null); } try { return(new XbmcSong(JsonRpcClient.GetField <int>(obj, "songid"), JsonRpcClient.GetField <string>(obj, "thumbnail"), JsonRpcClient.GetField <string>(obj, "fanart"), JsonRpcClient.GetField <string>(obj, "file"), JsonRpcClient.GetField <string>(obj, "title"), JsonRpcClient.GetField <string>(obj, "artist"), JsonRpcClient.GetField <string>(obj, "genre", string.Empty), JsonRpcClient.GetField <int>(obj, "year"), JsonRpcClient.GetField <int>(obj, "rating"), JsonRpcClient.GetField <string>(obj, "album", string.Empty), JsonRpcClient.GetField <int>(obj, "tracknumber"), JsonRpcClient.GetField <int>(obj, "discnumber"), JsonRpcClient.GetField <int>(obj, "duration"), JsonRpcClient.GetField <string>(obj, "comment", string.Empty), JsonRpcClient.GetField <string>(obj, "lyrics", string.Empty))); } catch (Exception ex) { return(null); } }
internal static new XbmcMusicVideo FromJson(JObject obj, JsonRpcClient logger) { if (obj == null) { throw new ArgumentNullException("obj"); } try { return(new XbmcMusicVideo(JsonRpcClient.GetField <int>(obj, "musicvideoid"), JsonRpcClient.GetField <string>(obj, "thumbnail"), JsonRpcClient.GetField <string>(obj, "fanart"), JsonRpcClient.GetField <string>(obj, "file"), JsonRpcClient.GetField <string>(obj, "title"), JsonRpcClient.GetField <string>(obj, "genre", string.Empty), JsonRpcClient.GetField <int>(obj, "year"), JsonRpcClient.GetField <double>(obj, "rating"), JsonRpcClient.GetField <string>(obj, "director", string.Empty), JsonRpcClient.GetField <string>(obj, "plot", string.Empty), JsonRpcClient.GetField <string>(obj, "lastplayed", string.Empty), JsonRpcClient.GetField <int>(obj, "duration"), JsonRpcClient.GetField <int>(obj, "playcount"), JsonRpcClient.GetField <string>(obj, "studio", string.Empty), JsonRpcClient.GetField <string>(obj, "artist"), JsonRpcClient.GetField <string>(obj, "album", string.Empty))); } catch (Exception ex) { if (logger != null) { logger.LogErrorMessage("EXCEPTION in XbmcMusicVideo.FromJson()!!!", 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); } }
protected TType getInfo <TType>(string label, TType defaultValue) { this.client.LogMessage("System.GetInfoLabels(" + label + ")"); JObject result = this.client.Call("System.GetInfoLabels", new string[] { label }) as JObject; if (result == null || result[label] == null) { this.client.LogErrorMessage("System.GetInfoLabels(" + label + "): Invalid response"); return(defaultValue); } return(JsonRpcClient.GetField <TType>(result, label, defaultValue)); }
internal static XbmcArtist FromJson(JObject obj) { if (obj == null) { return(null); } try { return(new XbmcArtist(JsonRpcClient.GetField <int>(obj, "artistid"), JsonRpcClient.GetField <string>(obj, "artist"), JsonRpcClient.GetField <string>(obj, "thumbnail"), JsonRpcClient.GetField <string>(obj, "fanart"))); } catch (Exception ex) { return(null); } }
internal static new XbmcMovie FromJson(JObject obj, JsonRpcClient logger) { if (obj == null) { return(null); } try { // TODO: Remove unsupported label (e.g. 'movieid') return(new XbmcMovie(JsonRpcClient.GetField <int>(obj, "movieid"), JsonRpcClient.GetField <string>(obj, "thumbnail"), JsonRpcClient.GetField <string>(obj, "fanart"), JsonRpcClient.GetField <string>(obj, "file"), JsonRpcClient.GetField <string>(obj, "title"), JsonRpcClient.GetField <string>(obj, "genre", string.Empty), JsonRpcClient.GetField <int>(obj, "year"), JsonRpcClient.GetField <double>(obj, "rating"), JsonRpcClient.GetField <string>(obj, "director", string.Empty), JsonRpcClient.GetField <string>(obj, "trailer", string.Empty), JsonRpcClient.GetField <string>(obj, "tagline", string.Empty), JsonRpcClient.GetField <string>(obj, "plot", string.Empty), JsonRpcClient.GetField <string>(obj, "plotoutline", string.Empty), JsonRpcClient.GetField <string>(obj, "originaltitle", string.Empty), JsonRpcClient.GetField <string>(obj, "lastplayed", string.Empty), JsonRpcClient.GetField <int>(obj, "duration"), JsonRpcClient.GetField <int>(obj, "playcount"), JsonRpcClient.GetField <string>(obj, "writer", string.Empty), JsonRpcClient.GetField <string>(obj, "studio", string.Empty), JsonRpcClient.GetField <string>(obj, "mpaa", string.Empty))); } catch (Exception ex) { if (logger != null) { logger.LogErrorMessage("EXCEPTION in XbmcMovie.FromJson()!!!", ex); } return(null); } }
internal static new XbmcTvEpisode FromJson(JObject obj, JsonRpcClient logger) { if (obj == null) { return(null); } try { //return new XbmcTvEpisode(JsonRpcClient.GetField<int>(obj, "episodeid"), return(new XbmcTvEpisode(JsonRpcClient.GetField <int>(obj, "id"), JsonRpcClient.GetField <string>(obj, "thumbnail"), JsonRpcClient.GetField <string>(obj, "fanart"), JsonRpcClient.GetField <string>(obj, "file"), JsonRpcClient.GetField <string>(obj, "title"), JsonRpcClient.GetField <int>(obj, "year"), JsonRpcClient.GetField <double>(obj, "rating"), JsonRpcClient.GetField <string>(obj, "director", string.Empty), JsonRpcClient.GetField <string>(obj, "plot", string.Empty), JsonRpcClient.GetField <string>(obj, "lastplayed", string.Empty), JsonRpcClient.GetField <string>(obj, "showtitle"), JsonRpcClient.GetField <string>(obj, "firstaired"), JsonRpcClient.GetField <int>(obj, "duration"), JsonRpcClient.GetField <int>(obj, "season"), JsonRpcClient.GetField <int>(obj, "episode"), JsonRpcClient.GetField <int>(obj, "playcount"), JsonRpcClient.GetField <string>(obj, "writer", string.Empty), JsonRpcClient.GetField <string>(obj, "studio", string.Empty), JsonRpcClient.GetField <string>(obj, "mpaa", string.Empty), JsonRpcClient.GetField <string>(obj, "premiered", string.Empty))); } catch (Exception ex) { if (logger != null) { logger.LogErrorMessage("EXCEPTION in XbmcTvEpisode.FromJson()!!!", ex); } return(null); } }
internal static XbmcArtist FromJson(JObject obj, JsonRpcClient logger) { if (obj == null) { return(null); } try { return(new XbmcArtist(JsonRpcClient.GetField <int>(obj, "artistid"), JsonRpcClient.GetField <string>(obj, "artist"), JsonRpcClient.GetField <string>(obj, "thumbnail"), JsonRpcClient.GetField <string>(obj, "fanart"))); } catch (Exception ex) { if (logger != null) { logger.LogErrorMessage("EXCEPTION in XbmcArtist.FromJson()!!!", ex); } return(null); } }