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 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 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 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 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, 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 XbmcPlayer(JsonRpcClient client) : base(client) { this.audio = new XbmcAudioPlayer(client); this.video = new XbmcVideoPlayer(client); this.pictures = new XbmcPicturePlayer(client); }
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 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 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 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 XbmcJsonRpcNamespace(JsonRpcClient client) { if (client == null) { throw new ArgumentNullException("client"); } this.client = client; }
protected XbmcMediaPlaylist(string playlistName, JsonRpcClient client) : base(client) { if (string.IsNullOrEmpty(playlistName)) { throw new ArgumentException(); } this.playlistName = playlistName; }
protected XbmcMediaLibrary(string libraryName, JsonRpcClient client) : base(client) { if (string.IsNullOrEmpty(libraryName)) { throw new ArgumentException(); } this.libraryName = libraryName; }
public XbmcJsonRpcConnection(Uri uri, string username, string password) { this.client = new JsonRpcClient(uri, username, password); this.client.Log += onLog; this.client.LogError += onLogError; this.jsonRpc = new XbmcJsonRpc(this.client); this.player = new XbmcPlayer(this.client); this.system = new XbmcSystem(this.client); this.xbmc = new XbmcGeneral(this.client); this.files = new XbmcFiles(this.client); this.playlist = new XbmcPlaylist(this.client); this.library = new XbmcLibrary(this.client); }
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 XbmcPlaylist <TMediaType> FromJson(JObject obj, JsonRpcClient logger) { try { return(new XbmcPlaylist <TMediaType>((int)obj["current"], (int)obj["start"], (int)obj["total"])); } catch (Exception ex) { if (logger != null) { logger.LogErrorMessage("EXCEPTION in XbmcPlaylist.FromJson()!!!", ex); } return(null); } }
protected XbmcMediaPlayer(string playerName, string infoLabelName, JsonRpcClient client) : base(client) { if (string.IsNullOrEmpty(playerName)) { throw new ArgumentException(); } if (string.IsNullOrEmpty(infoLabelName)) { infoLabelName = playerName; } this.playerName = playerName; this.infoLabelName = infoLabelName; }
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); } }
internal XbmcAudioLibrary(JsonRpcClient client) : base("AudioLibrary", client) { }
internal XbmcPicturePlayer(JsonRpcClient client) : base("PicturePlayer", client, 2) { }
internal XbmcJsonRpc(JsonRpcClient client) : base(client) { }
internal XbmcVideoLibrary(JsonRpcClient client) : base("VideoLibrary", client) { }
internal XbmcPlaylist(JsonRpcClient client) : base(client) { this.audio = new XbmcAudioPlaylist(client); this.video = new XbmcVideoPlaylist(client); }
internal XbmcAudioPlayer(JsonRpcClient client) : base("AudioPlayer", "MusicPlayer", client, 0) { }
internal XbmcVideoPlayer(JsonRpcClient client) : base("VideoPlayer", client) { }