Exemple #1
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);
        }
Exemple #2
0
        public Collection <ApiTvEpisode> GetTvEpisodes()
        {
            var          episodes = new Collection <ApiTvEpisode>();
            const string req      = "SELECT idEpisode,c00,c01,c03,c05,c10,c12,c13,idFile,strFileName,strPath,playCount,strTitle,strStudio,idShow,mpaa FROM episodeview ";

            var dblines = _parent.DBCommand("video", req);

            if (dblines == null)
            {
                return(episodes);
            }
            foreach (var dbline in dblines)
            {
                if (dbline.Length < 15)
                {
                    _parent.Log("Invalid request DATA : " + dbline);
                    continue;
                }
                dbline[3] = dbline[3].Length > 3 ? dbline[3] : "0.0";
                var episode = new ApiTvEpisode
                {
                    IdEpisode = Xbmc.StringToNumber(dbline[0]),
                    Title     = dbline[1],
                    Plot      = dbline[2],
                    Rating    = dbline[3].Substring(0, 3).Trim('.'),
                    Date      = dbline[4],
                    Director  = dbline[5],
                    Season    = Xbmc.StringToNumber(dbline[6]),
                    Episode   = Xbmc.StringToNumber(dbline[7]),
                    IdFile    = Xbmc.StringToNumber(dbline[8]),
                    FileName  = dbline[9],
                    Path      = dbline[10],
                    PlayCount = Xbmc.StringToNumber(dbline[11]),
                    ShowTitle = dbline[12],
                    Studio    = dbline[13],
                    IdShow    = Xbmc.StringToNumber(dbline[14]),
                    Mpaa      = dbline[15]
                };
                if (episode.FileName.StartsWith("stack://", StringComparison.OrdinalIgnoreCase))
                {
                    var temp = episode.FileName.Split(new[] { " , " }, StringSplitOptions.None);
                    episode.IsStack = 1;
                    episode.Hash    = Xbmc.Hash(temp[0].Replace("stack://", ""));
                    episode.Thumb   = @"special://profile/Thumbnails/Video/" + episode.Hash[0] + "/" + episode.Hash + ".tbn";
                    episode.Fanart  = @"special://profile/Thumbnails/Video/Fanart/" + Xbmc.Hash(episode.Path) + ".tbn";
                }
                else
                {
                    episode.IsStack = 0;
                    episode.Hash    = Xbmc.Hash(episode.Path + episode.FileName);
                    episode.Thumb   = @"special://profile/Thumbnails/Video/" + episode.Hash[0] + "/" + episode.Hash + ".tbn";
                    episode.Fanart  = @"special://profile/Thumbnails/Video/Fanart/" + Xbmc.Hash(episode.Path) + ".tbn";
                }
                episodes.Add(episode);
            }
            return(episodes);
        }
Exemple #3
0
        public Collection <ApiAudioArtist> GetArtists()
        {
            var artists = new Collection <ApiAudioArtist>();
            var dblines = _parent.DBCommand("music", "SELECT idArtist,strArtist FROM artist");

            if (dblines == null)
            {
                return(artists);
            }
            foreach (var dbline in dblines)
            {
                if (dbline.Length < 2)
                {
                    _parent.Log("Invalid request DATA : " + dbline);
                    continue;
                }
                var hash  = Xbmc.Hash(dbline[1]);
                var hash2 = Xbmc.Hash("artist" + dbline[1]);
                var genre = new ApiAudioArtist
                {
                    IdArtist = Xbmc.StringToNumber(dbline[0]),
                    Name     = dbline[1],
                    Thumb    = @"special://profile/Thumbnails/Music/Artists/" + hash2 + ".tbn",
                    Fanart   = @"special://profile/Thumbnails/Music/Fanart/" + hash + ".tbn",
                    Hash     = hash2
                };
                artists.Add(genre);
            }

            dblines = _parent.DBCommand("music", "SELECT idArtist,strBiography FROM artistinfo");
            if (dblines == null)
            {
                return(artists);
            }

            foreach (var dbline in dblines)
            {
                if (dbline.Length < 2)
                {
                    _parent.Log("Invalid request DATA : " + dbline);
                    continue;
                }
                foreach (var artist in artists)
                {
                    if (artist.IdArtist.ToString(CultureInfo.InvariantCulture) == dbline[0])
                    {
                        artist.Biography = dbline[1];
                    }
                }
            }

            return(artists);
        }
Exemple #4
0
        public Collection <ApiTvShow> GetTvShows()
        {
            var shows   = new Collection <ApiTvShow>();
            var dblines = _parent.DBCommand("video", "SELECT idShow,c00,c01,c04,c05,c08,c12,c13,c14,strPath,totalCount FROM tvshowview");

            if (dblines == null)
            {
                return(shows);
            }
            foreach (var dbline in dblines)
            {
                if (dbline.Length < 11)
                {
                    _parent.Log("Invalid request DATA : " + dbline);
                    continue;
                }
                dbline[3] = dbline[3].Length > 3 ? dbline[3] : "0.0";
                var show = new ApiTvShow
                {
                    IdShow     = Xbmc.StringToNumber(dbline[0]),
                    Title      = dbline[1],
                    Plot       = dbline[2],
                    Rating     = dbline[3].Substring(0, 3).Trim('.'),
                    Premiered  = dbline[4],
                    Genre      = dbline[5],
                    IdScraper  = dbline[6],
                    Mpaa       = dbline[7],
                    Studio     = dbline[8],
                    Path       = dbline[9],
                    TotalCount = Xbmc.StringToNumber(dbline[10])
                };
                show.Hash   = Xbmc.Hash(show.Path);
                show.Thumb  = @"special://profile/Thumbnails/Video/" + show.Hash[0] + "/" + show.Hash + ".tbn";
                show.Fanart = @"special://profile/Thumbnails/Video/Fanart/" + show.Hash + ".tbn";
                shows.Add(show);
            }
            return(shows);
        }
Exemple #5
0
        public Collection <ApiTvSeason> GetTvSeasons()
        {
            var          seasons = new Collection <ApiTvSeason>();
            const string req     = "SELECT idShow, COUNT(idShow), c12, strPath,strTitle FROM episodeview GROUP BY idShow,c12";

            var dblines = _parent.DBCommand("video", req);

            if (dblines == null)
            {
                return(seasons);
            }
            foreach (var dbline in dblines)
            {
                if (dbline.Length < 4)
                {
                    _parent.Log("Invalid request DATA : " + dbline);
                    continue;
                }
                var season = new ApiTvSeason
                {
                    EpisodeCount = Xbmc.StringToNumber(dbline[1]),
                    IdShow       = Xbmc.StringToNumber(dbline[0]),
                    SeasonNumber = Xbmc.StringToNumber(dbline[2]),
                    Show         = dbline[4]
                };

                var temp = dbline[3];
                season.Fanart = @"special://profile/Thumbnails/Video/Fanart/" + Xbmc.Hash(temp) + ".tbn";
                char[] charsToTrim = { '/' };
                temp = temp.TrimEnd(charsToTrim);
                var hash = Xbmc.Hash("season" + temp);
                season.Thumb = @"special://profile/Thumbnails/Video/" + hash[0] + "/" + hash + ".tbn";
                season.Hash  = temp;
                seasons.Add(season);
            }
            return(seasons);
        }