Exemplo n.º 1
0
        private async Task UpdateStatusMovieObjects(DinContext context, IMovieClient movieClient)
        {
            try
            {
                var content = await context.AddedContent.Where(c =>
                                                               c.Type.Equals(ContentType.Movie) && !c.Status.Equals(ContentStatus.Done)).ToListAsync();

                var queue = (await movieClient.GetQueue()).ToList();
                var now   = DateTime.Now;

                _logger.LogInformation($"Updating: {content.Count} movies");

                foreach (var c in content)
                {
                    var movie = await movieClient.GetMovieByIdAsync(c.SystemId);

                    var item = queue.Find(q => q.Movie.SystemId.Equals(c.SystemId));


                    if (movie.Downloaded)
                    {
                        c.Status = ContentStatus.Done;
                        continue;
                    }

                    if (item != null)
                    {
                        c.Status     = ContentStatus.Downloading;
                        c.Percentage = Math.Round(1 - (item.SizeLeft / item.Size), 2);
                        c.Eta        = (int)item.TimeLeft.TotalSeconds;
                    }

                    if (now >= c.DateAdded.AddDays(2) && c.Percentage > 0.0)
                    {
                        c.Status = ContentStatus.Stuck;
                        continue;
                    }

                    if (now >= c.DateAdded.AddDays(3))
                    {
                        c.Status = ContentStatus.NotAvailable;
                    }
                }
            }
            catch (Exception e)
            {
                _logger.LogError($"Updating movies encounterd error: {e.Message}");
            }
        }
Exemplo n.º 2
0
 public MovieService(IMovieClient movieClient)
 {
     _movieClient = movieClient;
 }
Exemplo n.º 3
0
 public MovieController(IMovieClient movieClient)
 {
     _movieClient = movieClient;
 }
Exemplo n.º 4
0
 public MovieService(IMovieClient client, IMovieMapper mapper)
 {
     _client = client;
     _mapper = mapper;
 }
Exemplo n.º 5
0
 public MovieService(IMovieClient movieClient)
 {
     this.movieClient = movieClient;
 }
Exemplo n.º 6
0
 public MovieController(IFindService findService, IMovieClient movieClient, IMapper mapper)
 {
     _findService = findService;
     _movieClient = movieClient;
     _mapper      = mapper;
 }
Exemplo n.º 7
0
 public SearchService(IMovieClient movieClient)
 {
     _movieClient = movieClient;
 }
Exemplo n.º 8
0
 public RandomService(IMovieClient movieClient, IFindService findService)
 {
     _movieClient = movieClient;
     _findService = findService;
 }
Exemplo n.º 9
0
 public MovieController(IMovieClient movieClient, IAuthorizationProvider authorizationProvider)
 {
     this.movieClient           = movieClient;
     this.authorizationProvider = authorizationProvider;
 }
Exemplo n.º 10
0
 public SettingsService(IMovieClient movieClient)
 {
     _movieClient = movieClient;
 }
Exemplo n.º 11
0
 public FindService(IMovieClient movieClient)
 {
     _movieClient = movieClient;
 }
Exemplo n.º 12
0
 public MovieService(DinContext context, IMovieClient movieClient, ITMDBClientConfig config, IMapper mapper) :
     base(context, mapper)
 {
     _movieClient = movieClient;
     _tmdbKey     = config.Key;
 }