示例#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}");
            }
        }
示例#2
0
 public MovieService(IMovieClient movieClient)
 {
     _movieClient = movieClient;
 }
 public MovieController(IMovieClient movieClient)
 {
     _movieClient = movieClient;
 }
示例#4
0
 public MovieService(IMovieClient client, IMovieMapper mapper)
 {
     _client = client;
     _mapper = mapper;
 }
示例#5
0
 public MovieService(IMovieClient movieClient)
 {
     this.movieClient = movieClient;
 }
示例#6
0
 public MovieController(IFindService findService, IMovieClient movieClient, IMapper mapper)
 {
     _findService = findService;
     _movieClient = movieClient;
     _mapper      = mapper;
 }
示例#7
0
 public SearchService(IMovieClient movieClient)
 {
     _movieClient = movieClient;
 }
示例#8
0
 public RandomService(IMovieClient movieClient, IFindService findService)
 {
     _movieClient = movieClient;
     _findService = findService;
 }
示例#9
0
 public MovieController(IMovieClient movieClient, IAuthorizationProvider authorizationProvider)
 {
     this.movieClient           = movieClient;
     this.authorizationProvider = authorizationProvider;
 }
示例#10
0
 public SettingsService(IMovieClient movieClient)
 {
     _movieClient = movieClient;
 }
示例#11
0
 public FindService(IMovieClient movieClient)
 {
     _movieClient = movieClient;
 }
示例#12
0
 public MovieService(DinContext context, IMovieClient movieClient, ITMDBClientConfig config, IMapper mapper) :
     base(context, mapper)
 {
     _movieClient = movieClient;
     _tmdbKey     = config.Key;
 }