mirror of
https://github.com/sakaljurgis/kodi-api-server.git
synced 2026-07-09 04:47:41 +00:00
migrations; torr search, dl, seed, delete; files scan, delete; configs
This commit is contained in:
@@ -3,6 +3,7 @@ import { TypeOrmModuleOptions } from '@nestjs/typeorm';
|
||||
import { TypeOrmConfig } from './type-orm.config';
|
||||
import { PathsConfig } from './paths.config';
|
||||
import { VideoFilesConfig } from './video-files.config';
|
||||
import { RecentSearchesConfig } from './recent-searches.config';
|
||||
|
||||
env.config();
|
||||
|
||||
@@ -10,6 +11,7 @@ export class ConfigService {
|
||||
private typeOrmConfig: TypeOrmConfig = new TypeOrmConfig(this);
|
||||
private pathsConfig: PathsConfig = new PathsConfig(this);
|
||||
private videoFilesConfig: VideoFilesConfig = new VideoFilesConfig(this);
|
||||
private recentSearches: RecentSearchesConfig = new RecentSearchesConfig(this);
|
||||
|
||||
public getEnv(key: string): any {
|
||||
return process.env[key];
|
||||
@@ -32,6 +34,10 @@ export class ConfigService {
|
||||
public getVideoFilesConfig(): VideoFilesConfig {
|
||||
return this.videoFilesConfig;
|
||||
}
|
||||
|
||||
public getRecentSearchesConfig(): RecentSearchesConfig {
|
||||
return this.recentSearches;
|
||||
}
|
||||
}
|
||||
|
||||
export const configService = new ConfigService();
|
||||
|
||||
@@ -14,10 +14,6 @@ export class PathsConfig {
|
||||
return this.getPathByEnvKey('STATIC_SERVE_FOLDER');
|
||||
}
|
||||
|
||||
public getRecentSearchesFolder(): string {
|
||||
return this.getPathByEnvKey('RECENT_SEARCHES_FOLDER');
|
||||
}
|
||||
|
||||
public getPathByEnvKey(key: string) {
|
||||
const relPath = this.configService.getEnv(key);
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import { ConfigService } from './config.service';
|
||||
|
||||
export class RecentSearchesConfig {
|
||||
constructor(private readonly configService: ConfigService) {
|
||||
this.configService = configService;
|
||||
}
|
||||
|
||||
public getRecentSearchesFolder(): string {
|
||||
return this.configService
|
||||
.getPaths()
|
||||
.getPathByEnvKey('RECENT_SEARCHES_FOLDER');
|
||||
}
|
||||
|
||||
public getRecentSearchesLimit(): number {
|
||||
return parseInt(this.configService.getEnv('RECENT_SEARCHES_LIMIT'));
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,15 @@
|
||||
import { LrtCategory } from '../KodiApi/LRT/LrtApiClient/Entity/lrt-category.entity';
|
||||
import { ConfigService } from './config.service';
|
||||
import { EntityClassOrSchema } from '@nestjs/typeorm/dist/interfaces/entity-class-or-schema.type';
|
||||
import { TitleEntity } from '../VideoFiles/Entity/title.entity';
|
||||
import { FileEntity } from '../VideoFiles/Entity/file.entity';
|
||||
import { TitleEntity } from '../Shared/Entity/title.entity';
|
||||
import { FileEntity } from '../Shared/Entity/file.entity';
|
||||
import { TorrentEntity } from '../Shared/Entity/torrent.entity';
|
||||
|
||||
export class TypeOrmConfig {
|
||||
constructor(configService: ConfigService) {
|
||||
this.type = 'sqlite';
|
||||
this.database = configService.getEnv('DB_PATH');
|
||||
this.entities = [LrtCategory, TitleEntity, FileEntity];
|
||||
this.entities = [LrtCategory, TitleEntity, FileEntity, TorrentEntity];
|
||||
}
|
||||
type: 'sqlite';
|
||||
database: string;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { ConfigService } from './config.service';
|
||||
import { join } from 'path';
|
||||
|
||||
export class VideoFilesConfig {
|
||||
constructor(private readonly configService: ConfigService) {
|
||||
@@ -13,4 +12,25 @@ export class VideoFilesConfig {
|
||||
public getVideoFilesExt(): string[] {
|
||||
return JSON.parse(this.configService.getEnv('VIDEO_FILES_EXT'));
|
||||
}
|
||||
|
||||
public getPathPatternsToIgnore(): string[] {
|
||||
return JSON.parse(this.configService.getEnv('PATTERNS_TO_IGNORE'));
|
||||
}
|
||||
|
||||
public getTorrentDownloadDir(): string {
|
||||
return this.configService
|
||||
.getPaths()
|
||||
.getPathByEnvKey('TORRENT_DOWNLOAD_DIR');
|
||||
}
|
||||
|
||||
public getTransmissionOptions() {
|
||||
return {
|
||||
host: this.configService.getEnv('TRANSMISSION_CLIENT_HOST'), // # default 'localhost'
|
||||
//port: 9091, // # default 9091
|
||||
//username: "username", // # default blank
|
||||
//password: "password", // # default blank
|
||||
//ssl: true, //# default false use https
|
||||
//url: "/my/other/url" // # default '/transmission/rpc'
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user