예제 #1
0
        public void CacheContent()
        {
            var embySettings = Emby.GetSettings();

            if (!embySettings.Enable)
            {
                return;
            }
            if (!ValidateSettings(embySettings))
            {
                Log.Debug("Validation of emby settings failed.");
                return;
            }
            CachedLibraries(embySettings);
        }
예제 #2
0
        public void Execute(IJobExecutionContext context)
        {
            try
            {
                var s = Emby.GetSettings();
                if (!s.EnableEpisodeSearching)
                {
                    return;
                }

                Job.SetRunning(true, JobNames.EmbyEpisodeCacher);
                CacheEpisodes(s);
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
            finally
            {
                Job.Record(JobNames.EmbyEpisodeCacher);
                Job.SetRunning(false, JobNames.EmbyEpisodeCacher);
            }
        }
예제 #3
0
        public List <EmbyMovieItem> GetMovies()
        {
            var settings = Emby.GetSettings();

            return(EmbyApi.GetAllMovies(settings.ApiKey, settings.AdministratorId, settings.FullUri).Items);
        }
예제 #4
0
        public List <EmbySeriesItem> GetTvShows()
        {
            var settings = Emby.GetSettings();

            return(EmbyApi.GetAllShows(settings.ApiKey, settings.AdministratorId, settings.FullUri).Items);
        }
예제 #5
0
        public void CheckAndUpdateAll()
        {
            var embySettings = Emby.GetSettings();

            if (!embySettings.Enable)
            {
                return;
            }
            if (!ValidateSettings(embySettings))
            {
                Log.Debug("Validation of the Emby settings failed.");
                return;
            }

            var content = EmbyContent.GetAll().ToList();

            var movies = GetEmbyMovies(content).ToArray();
            var shows  = GetEmbyTvShows(content).ToArray();
            var albums = GetEmbyMusic(content).ToArray();

            var requests        = RequestService.GetAll();
            var requestedModels = requests as RequestedModel[] ?? requests.Where(x => !x.Available).ToArray();

            if (!requestedModels.Any())
            {
                Log.Debug("There are no requests to check.");
                return;
            }

            var modifiedModel = new List <RequestedModel>();

            foreach (var r in requestedModels)
            {
                var  releaseDate = r.ReleaseDate == DateTime.MinValue ? string.Empty : r.ReleaseDate.ToString("yyyy");
                bool matchResult;

                switch (r.Type)
                {
                case RequestType.Movie:
                    matchResult = IsMovieAvailable(movies, r.Title, releaseDate, r.ImdbId);
                    break;

                case RequestType.TvShow:
                    if (!embySettings.EnableEpisodeSearching)
                    {
                        matchResult = IsTvShowAvailable(shows, r.Title, releaseDate, r.TvDbId, r.SeasonList);
                    }
                    else
                    {
                        matchResult = r.Episodes.Any() ?
                                      r.Episodes.All(x => IsEpisodeAvailable(r.TvDbId, x.SeasonNumber, x.EpisodeNumber)) :
                                      IsTvShowAvailable(shows, r.Title, releaseDate, r.TvDbId, r.SeasonList);
                    }
                    break;

                case RequestType.Album:
                    //matchResult = IsAlbumAvailable(albums, r.Title, r.ReleaseDate.Year.ToString(), r.ArtistName); // TODO Emby
                    matchResult = false;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }


                if (matchResult)
                {
                    r.Available = true;
                    modifiedModel.Add(r);
                    continue;
                }
            }

            Log.Debug("Requests that will be updated count {0}", modifiedModel.Count);

            if (modifiedModel.Any())
            {
                NotificationEngine.NotifyUsers(modifiedModel, NotificationType.RequestAvailable);
                RequestService.BatchUpdate(modifiedModel);
            }
        }