public PagingSpec <Episode> EpisodesWhereCutoffUnmet(PagingSpec <Episode> pagingSpec) { var qualitiesBelowCutoff = new List <QualitiesBelowCutoff>(); var languagesBelowCutoff = new List <LanguagesBelowCutoff>(); var profiles = _profileService.All(); var languageProfiles = _languageProfileService.All(); //Get all items less than the cutoff foreach (var profile in profiles) { var cutoffIndex = profile.GetIndex(profile.Cutoff); var belowCutoff = profile.Items.Take(cutoffIndex.Index).ToList(); if (belowCutoff.Any()) { qualitiesBelowCutoff.Add(new QualitiesBelowCutoff(profile.Id, belowCutoff.SelectMany(i => i.GetQualities().Select(q => q.Id)))); } } foreach (var profile in languageProfiles) { var languageCutoffIndex = profile.Languages.FindIndex(v => v.Language == profile.Cutoff); var belowLanguageCutoff = profile.Languages.Take(languageCutoffIndex).ToList(); if (belowLanguageCutoff.Any()) { languagesBelowCutoff.Add(new LanguagesBelowCutoff(profile.Id, belowLanguageCutoff.Select(l => l.Language.Id))); } } return(_episodeRepository.EpisodesWhereCutoffUnmet(pagingSpec, qualitiesBelowCutoff, languagesBelowCutoff, false)); }
public PagingSpec <Movie> MoviesWhereCutoffUnmet(PagingSpec <Movie> pagingSpec) { var qualitiesBelowCutoff = new List <QualitiesBelowCutoff>(); var profiles = _profileService.All(); //Get all items less than the cutoff foreach (var profile in profiles) { var cutoffIndex = profile.Items.FindIndex(v => v.Quality == profile.Cutoff); var belowCutoff = profile.Items.Take(cutoffIndex).ToList(); if (belowCutoff.Any()) { qualitiesBelowCutoff.Add(new QualitiesBelowCutoff(profile.Id, belowCutoff.Select(i => i.Quality.Id))); } } return(_movieRepository.MoviesWhereCutoffUnmet(pagingSpec, qualitiesBelowCutoff)); }
public PagingSpec <Album> AlbumsWhereCutoffUnmet(PagingSpec <Album> pagingSpec) { var qualitiesBelowCutoff = new List <QualitiesBelowCutoff>(); var profiles = _profileService.All(); //Get all items less than the cutoff foreach (var profile in profiles) { var cutoffIndex = profile.GetIndex(profile.Cutoff); var belowCutoff = profile.Items.Take(cutoffIndex.Index).ToList(); if (belowCutoff.Any()) { qualitiesBelowCutoff.Add(new QualitiesBelowCutoff(profile.Id, belowCutoff.SelectMany(i => i.GetQualities().Select(q => q.Id)))); } } return(_albumRepository.AlbumsWhereCutoffUnmet(pagingSpec, qualitiesBelowCutoff)); }
private List <QualityProfileResource> GetAll() { return(_profileService.All().ToResource()); }
private Response Search() { if (Request.Query.Id == 0) { //Todo error handling } Profile tempProfile = _profileService.All().First(); RootFolder rootFolder = _rootFolderService.Get(Request.Query.Id); int page = Request.Query.page; int per_page = Request.Query.per_page; int min = (page - 1) * per_page; int max = page * per_page; var unmapped = rootFolder.UnmappedFolders.OrderBy(f => f.Name).ToList(); int total_count = unmapped.Count; if (Request.Query.total_entries.HasValue) { total_count = Request.Query.total_entries; } max = total_count >= max ? max : total_count; var paged = unmapped.GetRange(min, max - min); var mapped = paged.Select(f => { Core.Movies.Movie m = null; var mappedMovie = _mappedMovies.Find(f.Name); if (mappedMovie != null) { return(mappedMovie); } var parsedTitle = _parsingService.ParseMinimalPathMovieInfo(f.Name); if (parsedTitle == null) { m = new Core.Movies.Movie { Title = f.Name.Replace(".", " ").Replace("-", " "), Path = f.Path, Profile = tempProfile }; } else { parsedTitle.ImdbId = Parser.ParseImdbId(parsedTitle.SimpleReleaseTitle); m = new Core.Movies.Movie { Title = parsedTitle.MovieTitle, Year = parsedTitle.Year, ImdbId = parsedTitle.ImdbId, Path = f.Path, Profile = tempProfile }; } var files = _diskScanService.GetVideoFiles(f.Path); var decisions = _importDecisionMaker.GetImportDecisions(files.ToList(), m, true); var decision = decisions.Where(d => d.Approved && !d.Rejections.Any()).FirstOrDefault(); if (decision != null) { var local = decision.LocalMovie; m.MovieFile = new MovieFile { Path = local.Path, Edition = local.ParsedMovieInfo.Edition, Quality = local.Quality, MediaInfo = local.MediaInfo, ReleaseGroup = local.ParsedMovieInfo.ReleaseGroup, RelativePath = f.Path.GetRelativePath(local.Path) }; } mappedMovie = _searchProxy.MapMovieToTmdbMovie(m); if (mappedMovie != null) { mappedMovie.Monitored = true; _mappedMovies.Set(f.Name, mappedMovie, TimeSpan.FromDays(2)); return(mappedMovie); } return(null); }); return(new PagingResource <MovieResource> { Page = page, PageSize = per_page, SortDirection = SortDirection.Ascending, SortKey = Request.Query.sort_by, TotalRecords = total_count - mapped.Where(m => m == null).Count(), Records = MapToResource(mapped.Where(m => m != null)).ToList() }.AsResponse()); }
public List <AppProfileResource> GetAll() { return(_profileService.All().ToResource()); }
private List <ProfileResource> GetAll() { var profiles = _profileService.All().InjectTo <List <ProfileResource> >(); return(profiles); }