Exemplo n.º 1
0
        public bool IsEpisodeAvailable(string theTvDbId, int season, int episode)
        {
            var ep = EpisodeRepo.Custom(
                connection =>
            {
                connection.Open();
                var result = connection.Query <PlexEpisodes>("select * from PlexEpisodes where ProviderId = @ProviderId", new { ProviderId = theTvDbId });

                return(result);
            }).ToList();

            if (!ep.Any())
            {
                Log.Info("Episode cache info is not available. tvdbid: {0}, season: {1}, episode: {2}", theTvDbId, season, episode);
                return(false);
            }
            foreach (var result in ep)
            {
                if (result.ProviderId.Equals(theTvDbId) && result.EpisodeNumber == episode && result.SeasonNumber == season)
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the episode's db in the cache.
        /// </summary>
        /// <returns></returns>
        public async Task <IEnumerable <PlexEpisodes> > GetEpisodes()
        {
            var episodes = await EpisodeRepo.GetAllAsync();

            if (episodes == null)
            {
                return(new HashSet <PlexEpisodes>());
            }
            return(episodes);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the episode's stored in the db and then filters on the TheTvDBId.
        /// </summary>
        /// <param name="theTvDbId">The tv database identifier.</param>
        /// <returns></returns>
        public async Task <IEnumerable <PlexEpisodes> > GetEpisodes(int theTvDbId)
        {
            var ep = await EpisodeRepo.CustomAsync(async connection =>
            {
                connection.Open();
                var result = await connection.QueryAsync <PlexEpisodes>("select * from PlexEpisodes where ProviderId = @ProviderId", new { ProviderId = theTvDbId });

                return(result);
            });

            var plexEpisodeses = ep as PlexEpisodes[] ?? ep.ToArray();

            if (!plexEpisodeses.Any())
            {
                Log.Info("Episode db info is not available.");
                return(new List <PlexEpisodes>());
            }

            return(plexEpisodeses);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets the episode's stored in the db and then filters on the TheTvDBId.
        /// </summary>
        /// <param name="theTvDbId">The tv database identifier.</param>
        /// <returns></returns>
        public async Task <IEnumerable <EmbyEpisodes> > GetEpisodes(int theTvDbId)
        {
            var ep = await EpisodeRepo.CustomAsync(async connection =>
            {
                connection.Open();
                var result = await connection.QueryAsync <EmbyEpisodes>(@"select ee.* from EmbyEpisodes ee inner join EmbyContent ec
					on ee.ParentId = ec.EmbyId
					where ec.ProviderId = @ProviderId"                    , new { ProviderId = theTvDbId });

                return(result);
            });

            var embyEpisodes = ep as EmbyEpisodes[] ?? ep.ToArray();

            if (!embyEpisodes.Any())
            {
                Log.Info("Episode db info is not available.");
                return(new List <EmbyEpisodes>());
            }

            return(embyEpisodes);
        }