예제 #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}");
            }
        }
 public AddedContentRepository(DinContext context) : base(context)
 {
 }
예제 #3
0
파일: TvShowService.cs 프로젝트: saltz/Din
 public TvShowService(DinContext context, ITvShowClient tvShowClient, ITMDBClientConfig config, IMapper mapper) : base(context, mapper)
 {
     _tvShowClient = tvShowClient;
     _tmdbKey      = config.Key;
 }
예제 #4
0
 public LoginAttemptRepository(DinContext context) : base(context)
 {
 }
예제 #5
0
 public TransactionProcessorBehaviour(DinContext context)
 {
     _context = context;
 }
예제 #6
0
 public AuthorizationCodeRepository(DinContext context) : base(context)
 {
 }
예제 #7
0
 protected BaseRepository(DinContext context)
 {
     Context = context;
 }
예제 #8
0
파일: ContentService.cs 프로젝트: saltz/Din
 protected ContentService(DinContext context, IMapper mapper)
 {
     _context = context;
     Mapper   = mapper;
 }
예제 #9
0
파일: AuthService.cs 프로젝트: saltz/Din
 public AuthService(DinContext context, IIpStackClient ipStackClient, IMapper mapper)
 {
     _context       = context;
     _ipStackClient = ipStackClient;
     _mapper        = mapper;
 }
예제 #10
0
        private async Task UpdateStatusTvShowObjects(DinContext context, ITvShowClient tvShowClient)
        {
            try
            {
                var content = await context.AddedContent
                              .Where(c => c.Type.Equals(ContentType.TvShow) && !c.Status.Equals(ContentStatus.Done))
                              .ToListAsync();

                var now = DateTime.Now;

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

                foreach (var c in content)
                {
                    var show = await tvShowClient.GetTvShowByIdAsync(c.SystemId);

                    var pilotSeason = show.Seasons.FirstOrDefault(s => s.SeasonsNumber.Equals(0));

                    if (pilotSeason != null)
                    {
                        show.Seasons.Remove(pilotSeason);
                    }

                    var seasonsDone      = 0;
                    var seasonPercentage = new List <double>();

                    foreach (var s in show.Seasons)
                    {
                        if (s.Statistics.EpisodeCount.Equals(s.Statistics.TotalEpisodeCount))
                        {
                            seasonsDone++;
                            continue;
                        }

                        seasonPercentage.Add(Convert.ToDouble(s.Statistics.EpisodeCount) /
                                             (Convert.ToDouble(s.Statistics.TotalEpisodeCount) / 100));
                    }

                    if (seasonsDone.Equals(show.Seasons.Count))
                    {
                        c.Status = ContentStatus.Done;
                        continue;
                    }

                    var showPercentage = Math.Round((seasonPercentage.Sum() / seasonPercentage.Count) / 100, 2);

                    if (showPercentage > 0.0)
                    {
                        c.Status     = ContentStatus.Downloading;
                        c.Percentage = showPercentage;
                    }

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

                    if (now >= c.DateAdded.AddDays(5))
                    {
                        c.Status = ContentStatus.NotAvailable;
                    }
                }
            }
            catch (Exception e)
            {
                _logger.LogInformation($"Updating tvshows encounterd error: {e.Message}");
            }
        }
예제 #11
0
 public MovieService(DinContext context, IMovieClient movieClient, ITMDBClientConfig config, IMapper mapper) :
     base(context, mapper)
 {
     _movieClient = movieClient;
     _tmdbKey     = config.Key;
 }
예제 #12
0
 public AccountService(DinContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
예제 #13
0
 public AccountRepository(DinContext context) : base(context)
 {
 }