Exemplo n.º 1
0
        private async Task ProcessMovies()
        {
            var movies = _movieRepo.GetAll().Include(x => x.RequestedUser).Where(x => !x.Available || (!x.Available4K && x.Has4KRequest));

            foreach (var movie in movies)
            {
                var             has4kRequest    = movie.Has4KRequest;
                JellyfinContent jellyfinContent = null;
                if (movie.TheMovieDbId > 0)
                {
                    jellyfinContent = await _repo.GetByTheMovieDbId(movie.TheMovieDbId.ToString());
                }
                else if (movie.ImdbId.HasValue())
                {
                    jellyfinContent = await _repo.GetByImdbId(movie.ImdbId);
                }

                if (jellyfinContent == null)
                {
                    // We don't have this yet
                    continue;
                }

                _log.LogInformation("We have found the request {0} on Jellyfin, sending the notification", movie?.Title ?? string.Empty);

                var notify = false;

                if (has4kRequest && jellyfinContent.Has4K && !movie.Available4K)
                {
                    movie.Available4K         = true;
                    movie.MarkedAsAvailable4K = DateTime.Now;
                    notify = true;
                }

                // If we have a non-4k versison then mark as available
                if (jellyfinContent.Quality != null && !movie.Available)
                {
                    movie.Available         = true;
                    movie.MarkedAsAvailable = DateTime.Now;
                    notify = true;
                }

                if (notify)
                {
                    var recipient = movie.RequestedUser.Email.HasValue() ? movie.RequestedUser.Email : string.Empty;

                    _log.LogDebug("MovieId: {0}, RequestUser: {1}", movie.Id, recipient);

                    await _notificationService.Notify(new NotificationOptions
                    {
                        DateTime         = DateTime.Now,
                        NotificationType = NotificationType.RequestAvailable,
                        RequestId        = movie.Id,
                        RequestType      = RequestType.Movie,
                        Recipient        = recipient,
                    });
                }
            }
            await _movieRepo.Save();
        }
Exemplo n.º 2
0
        private async Task ProcessMovies()
        {
            var movies = _movieRepo.GetAll().Include(x => x.RequestedUser).Where(x => !x.Available);

            foreach (var movie in movies)
            {
                var embyContent = await _repo.Get(movie.ImdbId);

                if (embyContent == null)
                {
                    // We don't have this yet
                    continue;
                }

                _log.LogInformation("We have found the request {0} on Emby, sending the notification", movie?.Title ?? string.Empty);

                movie.Available = true;
                if (movie.Available)
                {
                    var recipient = movie.RequestedUser.Email.HasValue() ? movie.RequestedUser.Email : string.Empty;

                    _log.LogDebug("MovieId: {0}, RequestUser: {1}", movie.Id, recipient);

                    BackgroundJob.Enqueue(() => _notificationService.Publish(new NotificationOptions
                    {
                        DateTime         = DateTime.Now,
                        NotificationType = NotificationType.RequestAvailable,
                        RequestId        = movie.Id,
                        RequestType      = RequestType.Movie,
                        Recipient        = recipient,
                    }));
                }
            }
            await _movieRepo.Save();
        }
Exemplo n.º 3
0
        private async Task ProcessMovies()
        {
            // Get all non available
            var movies = _movieRepo.GetAll().Include(x => x.RequestedUser).Where(x => !x.Available);

            foreach (var movie in movies)
            {
                PlexServerContent item = null;
                if (movie.ImdbId.HasValue())
                {
                    item = await _repo.Get(movie.ImdbId);
                }
                if (item == null)
                {
                    if (movie.TheMovieDbId.ToString().HasValue())
                    {
                        item = await _repo.Get(movie.TheMovieDbId.ToString());
                    }
                }
                if (item == null)
                {
                    // We don't yet have this
                    continue;
                }

                movie.Available         = true;
                movie.MarkedAsAvailable = DateTime.Now;
                item.RequestId          = movie.Id;

                _log.LogInformation("[PAC] - Movie request {0} is now available, sending notification", $"{movie.Title} - {movie.Id}");
                await _notificationService.Notify(new NotificationOptions
                {
                    DateTime         = DateTime.Now,
                    NotificationType = NotificationType.RequestAvailable,
                    RequestId        = movie.Id,
                    RequestType      = RequestType.Movie,
                    Recipient        = movie.RequestedUser != null ? movie.RequestedUser.Email : string.Empty
                });
            }

            await _movieRepo.Save();

            await _repo.SaveChangesAsync();
        }
Exemplo n.º 4
0
        private async Task ProcessMovies()
        {
            // Get all non available
            var movies = _movieRepo.GetAll().Include(x => x.RequestedUser).Where(x => !x.Available);

            foreach (var movie in movies)
            {
                PlexServerContent item = null;
                if (movie.ImdbId.HasValue())
                {
                    item = await _repo.Get(movie.ImdbId);
                }
                if (item == null)
                {
                    if (movie.TheMovieDbId.ToString().HasValue())
                    {
                        item = await _repo.Get(movie.TheMovieDbId.ToString());
                    }
                }
                if (item == null)
                {
                    // We don't yet have this
                    continue;
                }

                movie.Available         = true;
                movie.MarkedAsAvailable = DateTime.Now;
                if (movie.Available)
                {
                    _backgroundJobClient.Enqueue(() => _notificationService.Publish(new NotificationOptions
                    {
                        DateTime         = DateTime.Now,
                        NotificationType = NotificationType.RequestAvailable,
                        RequestId        = movie.Id,
                        RequestType      = RequestType.Movie,
                        Recipient        = movie.RequestedUser != null ? movie.RequestedUser.Email : string.Empty
                    }));
                }
            }

            await _movieRepo.Save();
        }