mirror of
https://github.com/sakaljurgis/kodi-api-server.git
synced 2026-07-09 04:47:41 +00:00
start local fs video files scanner service
This commit is contained in:
@@ -2,12 +2,14 @@ import * as env from 'dotenv';
|
||||
import { TypeOrmModuleOptions } from '@nestjs/typeorm';
|
||||
import { TypeOrmConfig } from './type-orm.config';
|
||||
import { PathsConfig } from './paths.config';
|
||||
import { VideoFilesConfig } from './video-files.config';
|
||||
|
||||
env.config();
|
||||
|
||||
export class ConfigService {
|
||||
private typeOrmConfig: TypeOrmConfig = new TypeOrmConfig(this);
|
||||
private pathsConfig: PathsConfig = new PathsConfig(this);
|
||||
private videoFilesConfig: VideoFilesConfig = new VideoFilesConfig(this);
|
||||
|
||||
public getEnv(key: string): any {
|
||||
return process.env[key];
|
||||
@@ -26,6 +28,10 @@ export class ConfigService {
|
||||
public getPaths(): PathsConfig {
|
||||
return this.pathsConfig;
|
||||
}
|
||||
|
||||
public getVideoFilesConfig(): VideoFilesConfig {
|
||||
return this.videoFilesConfig;
|
||||
}
|
||||
}
|
||||
|
||||
export const configService = new ConfigService();
|
||||
|
||||
@@ -18,7 +18,7 @@ export class PathsConfig {
|
||||
return this.getPathByEnvKey('RECENT_SEARCHES_FOLDER');
|
||||
}
|
||||
|
||||
private getPathByEnvKey(key: string) {
|
||||
public getPathByEnvKey(key: string) {
|
||||
const relPath = this.configService.getEnv(key);
|
||||
|
||||
return this.getPath(relPath);
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { ConfigService } from './config.service';
|
||||
import { join } from 'path';
|
||||
|
||||
export class VideoFilesConfig {
|
||||
constructor(private readonly configService: ConfigService) {
|
||||
this.configService = configService;
|
||||
}
|
||||
|
||||
public getVideoFilesFolders(): string[] {
|
||||
return JSON.parse(this.configService.getEnv('VIDEO_FILES_FOLDERS'));
|
||||
}
|
||||
|
||||
public getVideoFilesExt(): string[] {
|
||||
return JSON.parse(this.configService.getEnv('VIDEO_FILES_EXT'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user