예제 #1
0
        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);
            }
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        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);
            }
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
        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);
            }
        }
예제 #6
0
 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);
     }
 }
예제 #7
0
        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);
            }
        }
예제 #8
0
        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);
            }
        }
예제 #9
0
        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);
            }
        }