コード例 #1
0
        public async Task AnalyseFilmFile(int filmFileId, int libraryId)
        {
            var filmFile = await _databaseContext.FilmFiles.SingleAsync(ff => ff.Id == filmFileId);

            var fileInfo = new FileInfo(filmFile.Path);

            filmFile.LastWrite       = fileInfo.LastWriteTimeUtc;
            filmFile.FileSizeBytes   = fileInfo.Length;
            filmFile.PartOfLibraryId = libraryId;
            filmFile.MediaDetails    = await AnalyseMedia(filmFile.Path);

            filmFile.Subtitles = FileIndexer.IndexSubtitles(filmFile.Path);
            await _databaseContext.SaveChangesAsync();
        }
コード例 #2
0
        public async Task AnalyseEpisodeFiles(IReadOnlyCollection <int> episodeFileIds, int libraryId)
        {
            var episodeFiles = await _databaseContext.EpisodeFiles.Where(e => episodeFileIds.Contains(e.Id)).ToListAsync();

            foreach (var episodeFile in episodeFiles)
            {
                var fileInfo = new FileInfo(episodeFile.Path);
                episodeFile.LastWrite       = fileInfo.LastWriteTimeUtc;
                episodeFile.FileSizeBytes   = fileInfo.Length;
                episodeFile.PartOfLibraryId = libraryId;
                episodeFile.MediaDetails    = await AnalyseMedia(episodeFile.Path);

                episodeFile.Subtitles = FileIndexer.IndexSubtitles(episodeFile.Path);
            }
            await _databaseContext.SaveChangesAsync();
        }
コード例 #3
0
ファイル: IndexingService.cs プロジェクト: rosenbjerg/NxPlx
        private async Task IndexNewMovies(string[] newFiles, Library library)
        {
            var newFilm = FileIndexer.IndexFilmFiles(newFiles, library.Id).ToList();
            var details = await _metadataService.FindFilmDetails(newFilm, library) !;

            if (details.Any())
            {
                await _deduplicationService.DeduplicateEntities(details, d => d.Genres);

                await _deduplicationService.DeduplicateEntities(details, d => d.ProductionCountries, pc => pc.Iso3166_1,
                                                                ids => entity => ids.Contains(entity.Iso3166_1));

                await _deduplicationService.DeduplicateEntities(details, d => d.SpokenLanguages, sl => sl.Iso639_1,
                                                                ids => entity => ids.Contains(entity.Iso639_1));

                var newProductionCompanyIds =
                    await _deduplicationService.DeduplicateEntities(details, d => d.ProductionCompanies);

                var newMovieCollectionIds = await _deduplicationService.DeduplicateMovieCollections(details);

                await _deduplicationService.DeduplicateFilmMetadata(details);

                _context.FilmFiles.AddRange(newFilm);
                await _context.SaveChangesAsync();

                await _distributedCache.ClearList("overview", "sys");

                foreach (var detail in details)
                {
                    _backgroundJobClient.Enqueue <ImageProcessor>(service => service.ProcessFilmDetails(detail.Id));
                }
                foreach (var movieCollectionId in newMovieCollectionIds)
                {
                    _backgroundJobClient.Enqueue <ImageProcessor>(service => service.ProcessMovieCollection(movieCollectionId));
                }
                if (newProductionCompanyIds.Any())
                {
                    _backgroundJobClient.Enqueue <ImageProcessor>(service =>
                                                                  service.ProcessProductionCompanies(newProductionCompanyIds));
                }
                foreach (var filmFile in newFilm)
                {
                    _backgroundJobClient.Enqueue <FileAnalysisService>(
                        service => service.AnalyseFilmFile(filmFile.Id, library.Id));
                }
            }
        }
コード例 #4
0
ファイル: IndexingService.cs プロジェクト: rosenbjerg/NxPlx
        private async Task IndexNewEpisodes(string[] newFiles, Library library)
        {
            var newEpisodes = FileIndexer.IndexEpisodeFiles(newFiles, library.Id).ToList();
            var details     = await _metadataService.FindSeriesDetails(newEpisodes, library);

            if (!details.Any())
            {
                return;
            }

            await _deduplicationService.DeduplicateEntities(details, d => d.Genres);

            await _deduplicationService.DeduplicateEntities(details, d => d.CreatedBy);

            var newProductionCompanyIds =
                await _deduplicationService.DeduplicateEntities(details, d => d.ProductionCompanies);

            var newNetworkIds = await _deduplicationService.DeduplicateEntities(details, d => d.Networks);

            await _deduplicationService.DeduplicateSeriesMetadata(details);

            _context.AddRange(newEpisodes);
            await _context.SaveChangesAsync();

            await _distributedCache.ClearList("overview", "sys");

            foreach (var detail in details)
            {
                _backgroundJobClient.Enqueue <ImageProcessor>(service => service.ProcessSeries(detail.Id));
            }
            if (newNetworkIds.Any())
            {
                _backgroundJobClient.Enqueue <ImageProcessor>(service => service.ProcessNetworks(newNetworkIds));
            }
            if (newProductionCompanyIds.Any())
            {
                _backgroundJobClient.Enqueue <ImageProcessor>(service =>
                                                              service.ProcessProductionCompanies(newProductionCompanyIds));
            }

            foreach (var episodes in newEpisodes.GroupBy(e => e.SeriesDetailsId))
            {
                _backgroundJobClient.Enqueue <FileAnalysisService>(service =>
                                                                   service.AnalyseEpisodeFiles(episodes.Select(e => e.Id).ToArray(), library.Id));
            }
        }