Beispiel #1
0
    public static string CalculateWithSubfolders(string folder, ILocalFileSystem localFileSystem)
    {
        IEnumerable <string> allFiles = localFileSystem.ListFiles(folder);

        var sb = new StringBuilder();

        foreach (string file in allFiles.OrderBy(identity))
        {
            sb.Append(file);
            sb.Append(localFileSystem.GetLastWriteTime(file).Ticks);
        }

        foreach (string subfolder in localFileSystem.ListSubdirectories(folder).OrderBy(identity))
        {
            sb.Append(subfolder);
            sb.Append(Calculate(subfolder, localFileSystem));
        }

        var hash = new StringBuilder();

        byte[] bytes = Crypto.ComputeHash(Encoding.UTF8.GetBytes(sb.ToString()));
        foreach (byte t in bytes)
        {
            hash.Append(t.ToString("x2"));
        }

        return(hash.ToString());
    }
 public JellyfinMovieLibraryScanner(
     IJellyfinApiClient jellyfinApiClient,
     ISearchIndex searchIndex,
     IMediator mediator,
     IJellyfinMovieRepository jellyfinMovieRepository,
     ISearchRepository searchRepository,
     IJellyfinPathReplacementService pathReplacementService,
     IMediaSourceRepository mediaSourceRepository,
     ILocalFileSystem localFileSystem,
     ILocalStatisticsProvider localStatisticsProvider,
     ILocalSubtitlesProvider localSubtitlesProvider,
     ILogger <JellyfinMovieLibraryScanner> logger)
     : base(
         localStatisticsProvider,
         localSubtitlesProvider,
         localFileSystem,
         mediator,
         searchIndex,
         searchRepository,
         logger)
 {
     _jellyfinApiClient       = jellyfinApiClient;
     _jellyfinMovieRepository = jellyfinMovieRepository;
     _pathReplacementService  = pathReplacementService;
     _mediaSourceRepository   = mediaSourceRepository;
 }
Beispiel #3
0
    public async Task StartAsync(CancellationToken cancellationToken)
    {
        using IServiceScope scope       = _serviceScopeFactory.CreateScope();
        await using TvContext dbContext = scope.ServiceProvider.GetRequiredService <TvContext>();

        if (Directory.Exists(FileSystemLayout.LegacyImageCacheFolder))
        {
            _logger.LogInformation("Migrating channel logos from legacy image cache folder");

            List <string> logos = await dbContext.Channels
                                  .SelectMany(c => c.Artwork)
                                  .Where(a => a.ArtworkKind == ArtworkKind.Logo)
                                  .Map(a => a.Path)
                                  .ToListAsync(cancellationToken);

            ILocalFileSystem localFileSystem = scope.ServiceProvider.GetRequiredService <ILocalFileSystem>();
            foreach (string logo in logos)
            {
                string legacyPath = Path.Combine(FileSystemLayout.LegacyImageCacheFolder, logo);
                if (File.Exists(legacyPath))
                {
                    string subfolder = logo.Substring(0, 2);
                    string newPath   = Path.Combine(FileSystemLayout.LogoCacheFolder, subfolder, logo);
                    await localFileSystem.CopyFile(legacyPath, newPath);
                }
            }

            _logger.LogInformation("Deleting legacy image cache folder");
            Directory.Delete(FileSystemLayout.LegacyImageCacheFolder, true);
        }
    }
Beispiel #4
0
 public PlexMovieLibraryScanner(
     IPlexServerApiClient plexServerApiClient,
     IMovieRepository movieRepository,
     IMetadataRepository metadataRepository,
     ISearchIndex searchIndex,
     ISearchRepository searchRepository,
     IMediator mediator,
     IMediaSourceRepository mediaSourceRepository,
     IPlexMovieRepository plexMovieRepository,
     IPlexPathReplacementService plexPathReplacementService,
     ILocalFileSystem localFileSystem,
     ILocalStatisticsProvider localStatisticsProvider,
     ILocalSubtitlesProvider localSubtitlesProvider,
     ILogger <PlexMovieLibraryScanner> logger)
     : base(
         localStatisticsProvider,
         localSubtitlesProvider,
         localFileSystem,
         mediator,
         searchIndex,
         searchRepository,
         logger)
 {
     _plexServerApiClient        = plexServerApiClient;
     _movieRepository            = movieRepository;
     _metadataRepository         = metadataRepository;
     _mediaSourceRepository      = mediaSourceRepository;
     _plexMovieRepository        = plexMovieRepository;
     _plexPathReplacementService = plexPathReplacementService;
     _logger = logger;
 }
Beispiel #5
0
        private static Unit CleanCache(TvContext context, IServiceProvider provider)
        {
            if (Directory.Exists(FileSystemLayout.LegacyImageCacheFolder))
            {
                ILogger <Program> logger = provider.GetRequiredService <ILogger <Program> >();
                logger.LogInformation("Migrating channel logos from legacy image cache folder");

                var logos = context.Channels
                            .SelectMany(c => c.Artwork)
                            .Where(a => a.ArtworkKind == ArtworkKind.Logo)
                            .Map(a => a.Path)
                            .ToList();

                ILocalFileSystem localFileSystem = provider.GetRequiredService <ILocalFileSystem>();
                foreach (string logo in logos)
                {
                    string legacyPath = Path.Combine(FileSystemLayout.LegacyImageCacheFolder, logo);
                    if (File.Exists(legacyPath))
                    {
                        string subfolder = logo.Substring(0, 2);
                        string newPath   = Path.Combine(FileSystemLayout.LogoCacheFolder, subfolder, logo);
                        localFileSystem.CopyFile(legacyPath, newPath);
                    }
                }

                logger.LogInformation("Deleting legacy image cache folder");
                Directory.Delete(FileSystemLayout.LegacyImageCacheFolder, true);
            }

            return(Unit.Default);
        }
Beispiel #6
0
 public PlexTelevisionLibraryScanner(
     IPlexServerApiClient plexServerApiClient,
     ITelevisionRepository televisionRepository,
     IMetadataRepository metadataRepository,
     ISearchIndex searchIndex,
     ISearchRepository searchRepository,
     IMediator mediator,
     IMediaSourceRepository mediaSourceRepository,
     IPlexPathReplacementService plexPathReplacementService,
     IPlexTelevisionRepository plexTelevisionRepository,
     ILocalFileSystem localFileSystem,
     ILocalStatisticsProvider localStatisticsProvider,
     ILocalSubtitlesProvider localSubtitlesProvider,
     ILogger <PlexTelevisionLibraryScanner> logger)
     : base(metadataRepository, logger)
 {
     _plexServerApiClient        = plexServerApiClient;
     _televisionRepository       = televisionRepository;
     _metadataRepository         = metadataRepository;
     _searchIndex                = searchIndex;
     _searchRepository           = searchRepository;
     _mediator                   = mediator;
     _mediaSourceRepository      = mediaSourceRepository;
     _plexPathReplacementService = plexPathReplacementService;
     _plexTelevisionRepository   = plexTelevisionRepository;
     _localFileSystem            = localFileSystem;
     _localStatisticsProvider    = localStatisticsProvider;
     _localSubtitlesProvider     = localSubtitlesProvider;
     _logger = logger;
 }
Beispiel #7
0
 public EmbyMovieLibraryScanner(
     IEmbyApiClient embyApiClient,
     ISearchIndex searchIndex,
     IMediator mediator,
     IMediaSourceRepository mediaSourceRepository,
     IEmbyMovieRepository embyMovieRepository,
     ISearchRepository searchRepository,
     IEmbyPathReplacementService pathReplacementService,
     ILocalFileSystem localFileSystem,
     ILocalStatisticsProvider localStatisticsProvider,
     ILocalSubtitlesProvider localSubtitlesProvider,
     ILogger <EmbyMovieLibraryScanner> logger)
     : base(
         localStatisticsProvider,
         localSubtitlesProvider,
         localFileSystem,
         mediator,
         searchIndex,
         searchRepository,
         logger)
 {
     _embyApiClient          = embyApiClient;
     _mediaSourceRepository  = mediaSourceRepository;
     _embyMovieRepository    = embyMovieRepository;
     _pathReplacementService = pathReplacementService;
 }
Beispiel #8
0
 public EmbyTelevisionLibraryScanner(
     IEmbyApiClient embyApiClient,
     IMediaSourceRepository mediaSourceRepository,
     IEmbyTelevisionRepository televisionRepository,
     ISearchIndex searchIndex,
     ISearchRepository searchRepository,
     IEmbyPathReplacementService pathReplacementService,
     ILocalFileSystem localFileSystem,
     ILocalStatisticsProvider localStatisticsProvider,
     ILocalSubtitlesProvider localSubtitlesProvider,
     IMediator mediator,
     ILogger <EmbyTelevisionLibraryScanner> logger)
 {
     _embyApiClient           = embyApiClient;
     _mediaSourceRepository   = mediaSourceRepository;
     _televisionRepository    = televisionRepository;
     _searchIndex             = searchIndex;
     _searchRepository        = searchRepository;
     _pathReplacementService  = pathReplacementService;
     _localFileSystem         = localFileSystem;
     _localStatisticsProvider = localStatisticsProvider;
     _localSubtitlesProvider  = localSubtitlesProvider;
     _mediator = mediator;
     _logger   = logger;
 }
 public UpdateFFmpegSettingsHandler(
     IConfigElementRepository configElementRepository,
     ILocalFileSystem localFileSystem)
 {
     _configElementRepository = configElementRepository;
     _localFileSystem         = localFileSystem;
 }
Beispiel #10
0
 public SearchIndex(
     ILocalFileSystem localFileSystem,
     ISearchRepository searchRepository,
     ILogger <SearchIndex> logger)
 {
     _localFileSystem  = localFileSystem;
     _searchRepository = searchRepository;
     _logger           = logger;
 }
Beispiel #11
0
 public LocalStatisticsProvider(
     IMetadataRepository metadataRepository,
     ILocalFileSystem localFileSystem,
     ILogger <LocalStatisticsProvider> logger)
 {
     _metadataRepository = metadataRepository;
     _localFileSystem    = localFileSystem;
     _logger             = logger;
 }
 public EventLogStorageFactory(
     IJsonSerializerFacade jsonSerializerFacade,
     ISystemClock systemClock,
     ILocalFileSystem localFileSystem
     )
 {
     this._JsonSerializerFacade = jsonSerializerFacade;
     this._SystemClock          = systemClock;
     this._LocalFileSystem      = localFileSystem;
 }
 public StartFFmpegSessionHandler(
     ILocalFileSystem localFileSystem,
     ILogger <StartFFmpegSessionHandler> logger,
     IServiceScopeFactory serviceScopeFactory,
     IFFmpegSegmenterService ffmpegSegmenterService,
     IConfigElementRepository configElementRepository)
 {
     _localFileSystem         = localFileSystem;
     _logger                  = logger;
     _serviceScopeFactory     = serviceScopeFactory;
     _ffmpegSegmenterService  = ffmpegSegmenterService;
     _configElementRepository = configElementRepository;
 }
Beispiel #14
0
 public GetLastPtsDurationHandler(
     IClient client,
     ILocalFileSystem localFileSystem,
     ITempFilePool tempFilePool,
     IConfigElementRepository configElementRepository,
     ILogger <GetLastPtsDurationHandler> logger)
 {
     _client                  = client;
     _localFileSystem         = localFileSystem;
     _tempFilePool            = tempFilePool;
     _configElementRepository = configElementRepository;
     _logger                  = logger;
 }
Beispiel #15
0
 public EventLogStorage(
     EventLogStorageOptions options,
     IJsonSerializerFacade jsonSerializerFacade,
     ILocalFileSystem?localFileSystem = default,
     ISystemClock?systemClock         = default
     )
 {
     this._BaseFolder           = options.BaseFolder;
     this._JsonSerializerFacade = jsonSerializerFacade;
     this._LocalFileSystem      = localFileSystem ?? new LocalFileSystem();
     this._SystemClock          = systemClock ?? new SystemClock();
     this._LastWrite            = AsyncQueue.Create();
 }
 public RebuildSearchIndexHandler(
     ISearchIndex searchIndex,
     ISearchRepository searchRepository,
     IConfigElementRepository configElementRepository,
     ILocalFileSystem localFileSystem,
     ILogger <RebuildSearchIndexHandler> logger)
 {
     _searchIndex             = searchIndex;
     _logger                  = logger;
     _searchRepository        = searchRepository;
     _configElementRepository = configElementRepository;
     _localFileSystem         = localFileSystem;
 }
Beispiel #17
0
 public ExtractEmbeddedSubtitlesHandler(
     IDbContextFactory <TvContext> dbContextFactory,
     ILocalFileSystem localFileSystem,
     IPlexPathReplacementService plexPathReplacementService,
     IJellyfinPathReplacementService jellyfinPathReplacementService,
     IEmbyPathReplacementService embyPathReplacementService,
     ILogger <ExtractEmbeddedSubtitlesHandler> logger)
 {
     _dbContextFactory               = dbContextFactory;
     _localFileSystem                = localFileSystem;
     _plexPathReplacementService     = plexPathReplacementService;
     _jellyfinPathReplacementService = jellyfinPathReplacementService;
     _embyPathReplacementService     = embyPathReplacementService;
     _logger = logger;
 }
Beispiel #18
0
 public GetPlayoutItemProcessByChannelNumberHandler(
     IChannelRepository channelRepository,
     IConfigElementRepository configElementRepository,
     IPlayoutRepository playoutRepository,
     IMediaSourceRepository mediaSourceRepository,
     FFmpegProcessService ffmpegProcessService,
     ILocalFileSystem localFileSystem,
     ILogger <GetPlayoutItemProcessByChannelNumberHandler> logger)
     : base(channelRepository, configElementRepository)
 {
     _configElementRepository = configElementRepository;
     _playoutRepository       = playoutRepository;
     _mediaSourceRepository   = mediaSourceRepository;
     _ffmpegProcessService    = ffmpegProcessService;
     _localFileSystem         = localFileSystem;
     _logger = logger;
 }
 public MovieFolderScanner(
     ILocalFileSystem localFileSystem,
     IMovieRepository movieRepository,
     ILocalStatisticsProvider localStatisticsProvider,
     ILocalMetadataProvider localMetadataProvider,
     IMetadataRepository metadataRepository,
     IImageCache imageCache,
     ISearchIndex searchIndex,
     ILogger <MovieFolderScanner> logger)
     : base(localFileSystem, localStatisticsProvider, metadataRepository, imageCache, logger)
 {
     _localFileSystem       = localFileSystem;
     _movieRepository       = movieRepository;
     _localMetadataProvider = localMetadataProvider;
     _searchIndex           = searchIndex;
     _logger = logger;
 }
 protected MediaServerMovieLibraryScanner(
     ILocalStatisticsProvider localStatisticsProvider,
     ILocalSubtitlesProvider localSubtitlesProvider,
     ILocalFileSystem localFileSystem,
     IMediator mediator,
     ISearchIndex searchIndex,
     ISearchRepository searchRepository,
     ILogger logger)
 {
     _localStatisticsProvider = localStatisticsProvider;
     _localSubtitlesProvider  = localSubtitlesProvider;
     _localFileSystem         = localFileSystem;
     _mediator         = mediator;
     _searchIndex      = searchIndex;
     _searchRepository = searchRepository;
     _logger           = logger;
 }
Beispiel #21
0
    public Task <bool> Initialize(ILocalFileSystem localFileSystem)
    {
        if (!_initialized)
        {
            localFileSystem.EnsureFolderExists(FileSystemLayout.SearchIndexFolder);

            _directory = FSDirectory.Open(FileSystemLayout.SearchIndexFolder);
            var analyzer    = new StandardAnalyzer(AppLuceneVersion);
            var indexConfig = new IndexWriterConfig(AppLuceneVersion, analyzer)
            {
                OpenMode = OpenMode.CREATE_OR_APPEND
            };
            _writer      = new IndexWriter(_directory, indexConfig);
            _initialized = true;
        }

        return(Task.FromResult(_initialized));
    }
Beispiel #22
0
 public EventLogStorageFileBase(
     string dtPart,
     int nbrVersion,
     string filePath,
     FileMode fileMode,
     List <string>?filesToDelete,
     IJsonSerializerFacade jsonSerializerFacade,
     ILocalFileSystem localFileSystem,
     ISystemClock systemClock
     )
 {
     this._DtPart               = dtPart;
     this._NbrVersion           = nbrVersion;
     this._FilePath             = filePath;
     this._FileMode             = fileMode;
     this._FilesToDelete        = filesToDelete;
     this._JsonSerializerFacade = jsonSerializerFacade;
     this._LocalFileSystem      = localFileSystem;
     this._SystemClock          = systemClock;
 }
Beispiel #23
0
    public async Task StartAsync(CancellationToken cancellationToken)
    {
        using IServiceScope scope       = _serviceScopeFactory.CreateScope();
        await using TvContext dbContext = scope.ServiceProvider.GetRequiredService <TvContext>();

        IRuntimeInfo runtimeInfo = scope.ServiceProvider.GetRequiredService <IRuntimeInfo>();

        if (runtimeInfo != null && runtimeInfo.IsOSPlatform(OSPlatform.Linux) &&
            Directory.Exists("/dev/dri"))
        {
            ILocalFileSystem localFileSystem = scope.ServiceProvider.GetRequiredService <ILocalFileSystem>();
            IMemoryCache     memoryCache     = scope.ServiceProvider.GetRequiredService <IMemoryCache>();

            var devices = localFileSystem.ListFiles("/dev/dri")
                          .Filter(s => s.StartsWith("/dev/dri/render"))
                          .ToList();

            memoryCache.Set("ffmpeg.render_devices", devices);
        }
    }
 public TelevisionFolderScanner(
     ILocalFileSystem localFileSystem,
     ITelevisionRepository televisionRepository,
     ILocalStatisticsProvider localStatisticsProvider,
     ILocalMetadataProvider localMetadataProvider,
     IMetadataRepository metadataRepository,
     IImageCache imageCache,
     ISearchIndex searchIndex,
     ILogger <TelevisionFolderScanner> logger) : base(
         localFileSystem,
         localStatisticsProvider,
         metadataRepository,
         imageCache,
         logger)
 {
     _localFileSystem       = localFileSystem;
     _televisionRepository  = televisionRepository;
     _localMetadataProvider = localMetadataProvider;
     _searchIndex           = searchIndex;
     _logger = logger;
 }
Beispiel #25
0
 public EventLogStorageFile(
     string dtPart,
     int nbrVersion,
     string filePath,
     FileMode fileMode,
     List <string>?filesToDelete,
     IJsonSerializerFacade jsonSerializerFacade,
     ILocalFileSystem localFileSystem,
     ISystemClock systemClock
     ) : base(
         dtPart,
         nbrVersion,
         filePath,
         fileMode,
         filesToDelete,
         jsonSerializerFacade,
         localFileSystem,
         systemClock
         )
 {
 }
Beispiel #26
0
 public MusicVideoFolderScanner(
     ILocalFileSystem localFileSystem,
     ILocalStatisticsProvider localStatisticsProvider,
     ILocalMetadataProvider localMetadataProvider,
     ILocalSubtitlesProvider localSubtitlesProvider,
     IMetadataRepository metadataRepository,
     IImageCache imageCache,
     ISearchIndex searchIndex,
     ISearchRepository searchRepository,
     IArtistRepository artistRepository,
     IMusicVideoRepository musicVideoRepository,
     ILibraryRepository libraryRepository,
     IMediaItemRepository mediaItemRepository,
     IMediator mediator,
     IFFmpegProcessService ffmpegProcessService,
     ITempFilePool tempFilePool,
     IClient client,
     ILogger <MusicVideoFolderScanner> logger) : base(
         localFileSystem,
         localStatisticsProvider,
         metadataRepository,
         mediaItemRepository,
         imageCache,
         ffmpegProcessService,
         tempFilePool,
         client,
         logger)
 {
     _localFileSystem        = localFileSystem;
     _localMetadataProvider  = localMetadataProvider;
     _localSubtitlesProvider = localSubtitlesProvider;
     _searchIndex            = searchIndex;
     _searchRepository       = searchRepository;
     _artistRepository       = artistRepository;
     _musicVideoRepository   = musicVideoRepository;
     _libraryRepository      = libraryRepository;
     _mediator = mediator;
     _client   = client;
     _logger   = logger;
 }
 public GetPlayoutItemProcessByChannelNumberHandler(
     IDbContextFactory <TvContext> dbContextFactory,
     IFFmpegProcessService ffmpegProcessService,
     ILocalFileSystem localFileSystem,
     IPlexPathReplacementService plexPathReplacementService,
     IJellyfinPathReplacementService jellyfinPathReplacementService,
     IEmbyPathReplacementService embyPathReplacementService,
     IMediaCollectionRepository mediaCollectionRepository,
     ITelevisionRepository televisionRepository,
     IArtistRepository artistRepository,
     ISongVideoGenerator songVideoGenerator)
     : base(dbContextFactory)
 {
     _ffmpegProcessService           = ffmpegProcessService;
     _localFileSystem                = localFileSystem;
     _plexPathReplacementService     = plexPathReplacementService;
     _jellyfinPathReplacementService = jellyfinPathReplacementService;
     _embyPathReplacementService     = embyPathReplacementService;
     _mediaCollectionRepository      = mediaCollectionRepository;
     _televisionRepository           = televisionRepository;
     _artistRepository               = artistRepository;
     _songVideoGenerator             = songVideoGenerator;
 }
Beispiel #28
0
 public ImageCache(ILocalFileSystem localFileSystem) => _localFileSystem = localFileSystem;
 public LibraryRepository(ILocalFileSystem localFileSystem, IDbContextFactory <TvContext> dbContextFactory)
 {
     _localFileSystem  = localFileSystem;
     _dbContextFactory = dbContextFactory;
 }
 public UploadPackageAction(IInternalPackageRepositoryFactory packageRepositoryFactory, ILocalFileSystem fileSystem, IStore store) : base(store)
 {
     _packageRepositoryFactory = packageRepositoryFactory;
     _fileSystem = fileSystem;
 }