Skip to content

Commit f3ffc19

Browse files
committed
feat(api): Made supported subs configurable
1 parent c32ccfb commit f3ffc19

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

apps/api/src/shared/config/config.service.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export class ConfigService {
1818
public static readonly DOWNLOAD_LOCATION: string = 'DOWNLOAD_LOCATION'
1919
public static readonly OPENSUBTITLES_USERNAME: string = 'OPENSUBTITLES_USERNAME'
2020
public static readonly OPENSUBTITLES_PASSWORD: string = 'OPENSUBTITLES_PASSWORD'
21+
public static readonly SUBTITLES_LANGUAGES: string = 'SUBTITLES_LANGUAGES'
2122
public static readonly MAX_CONCURRENT_DOWNLOADS: string = 'MAX_CONCURRENT_DOWNLOADS'
2223
public static readonly TRAKT_KEY: string = 'TRAKT_KEY'
2324

@@ -103,7 +104,11 @@ export class ConfigService {
103104

104105
[ConfigService.OPENSUBTITLES_USERNAME]: Joi.string(),
105106

106-
[ConfigService.OPENSUBTITLES_PASSWORD]: Joi.string()
107+
[ConfigService.OPENSUBTITLES_PASSWORD]: Joi.string(),
108+
109+
[ConfigService.SUBTITLES_LANGUAGES]: Joi.string()
110+
.default('en'),
111+
107112
[ConfigService.MAX_CONCURRENT_DOWNLOADS]: Joi.number()
108113
.default(1),
109114
})

apps/api/src/shared/subtitles/subtitles.service.ts

+3-8
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,15 @@ export class SubtitlesService {
1818

1919
private readonly enabled: boolean = true
2020

21-
/**
22-
* TODO:: Get from ENV
23-
*/
24-
private readonly supportedLanguages = [
25-
'en',
26-
'nl'
27-
]
21+
private readonly supportedLanguages
2822

2923
constructor(
3024
private readonly httpService: HttpService,
3125
private readonly configService: ConfigService
3226
) {
3327
const username = this.configService.get(ConfigService.OPENSUBTITLES_USERNAME)
3428
const password = this.configService.get(ConfigService.OPENSUBTITLES_PASSWORD)
29+
this.supportedLanguages = this.configService.get(ConfigService.SUBTITLES_LANGUAGES)
3530

3631
if (username && password) {
3732
this.client = new OpenSubtitles({
@@ -52,7 +47,7 @@ export class SubtitlesService {
5247
* @param {TorrentFile} torrent - The torrent to search subtitles for.
5348
* @param {boolean} retry - Are we allowed to retry or not.
5449
*/
55-
public async searchForSubtitles(download: Model<Download>, torrent: TorrentFile, retry = true) {
50+
public async searchForSubtitles(download: Model<Download>, torrent: TorrentFile, retry = true): Promise<void> {
5651
// Only search for subtitles when it's enabled
5752
if (!this.enabled) {
5853
return

0 commit comments

Comments
 (0)