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}");
            }
        }
 public AddedContentRepository(DinContext context) : base(context)
 {
 }
Exemplo n.º 3
0
 public TvShowService(DinContext context, ITvShowClient tvShowClient, ITMDBClientConfig config, IMapper mapper) : base(context, mapper)
 {
     _tvShowClient = tvShowClient;
     _tmdbKey      = config.Key;
 }
Exemplo n.º 4
0
 public LoginAttemptRepository(DinContext context) : base(context)
 {
 }
Exemplo n.º 5
0
 public TransactionProcessorBehaviour(DinContext context)
 {
     _context = context;
 }
Exemplo n.º 6
0
 public AuthorizationCodeRepository(DinContext context) : base(context)
 {
 }
Exemplo n.º 7
0
 protected BaseRepository(DinContext context)
 {
     Context = context;
 }
Exemplo n.º 8
0
 protected ContentService(DinContext context, IMapper mapper)
 {
     _context = context;
     Mapper   = mapper;
 }
Exemplo n.º 9
0
 public AuthService(DinContext context, IIpStackClient ipStackClient, IMapper mapper)
 {
     _context       = context;
     _ipStackClient = ipStackClient;
     _mapper        = mapper;
 }
Exemplo n.º 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}");
            }
        }
Exemplo n.º 11
0
 public MovieService(DinContext context, IMovieClient movieClient, ITMDBClientConfig config, IMapper mapper) :
     base(context, mapper)
 {
     _movieClient = movieClient;
     _tmdbKey     = config.Key;
 }
Exemplo n.º 12
0
 public AccountService(DinContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
Exemplo n.º 13
0
 public AccountRepository(DinContext context) : base(context)
 {
 }