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) { }
public TvShowService(DinContext context, ITvShowClient tvShowClient, ITMDBClientConfig config, IMapper mapper) : base(context, mapper) { _tvShowClient = tvShowClient; _tmdbKey = config.Key; }
public LoginAttemptRepository(DinContext context) : base(context) { }
public TransactionProcessorBehaviour(DinContext context) { _context = context; }
public AuthorizationCodeRepository(DinContext context) : base(context) { }
protected BaseRepository(DinContext context) { Context = context; }
protected ContentService(DinContext context, IMapper mapper) { _context = context; Mapper = mapper; }
public AuthService(DinContext context, IIpStackClient ipStackClient, IMapper mapper) { _context = context; _ipStackClient = ipStackClient; _mapper = mapper; }
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}"); } }
public MovieService(DinContext context, IMovieClient movieClient, ITMDBClientConfig config, IMapper mapper) : base(context, mapper) { _movieClient = movieClient; _tmdbKey = config.Key; }
public AccountService(DinContext context, IMapper mapper) { _context = context; _mapper = mapper; }
public AccountRepository(DinContext context) : base(context) { }