Пример #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();
        }