File tree 2 files changed +13
-5
lines changed
apps/graphql-api/src/shared
2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,14 @@ export class SubtitlesService {
18
18
19
19
private readonly enabled : boolean = true
20
20
21
+ /**
22
+ * TODO:: Get from ENV
23
+ */
24
+ private readonly supportedLanguages = [
25
+ 'en' ,
26
+ 'nl'
27
+ ]
28
+
21
29
constructor (
22
30
private readonly httpService : HttpService ,
23
31
private readonly configService : ConfigService
@@ -83,7 +91,7 @@ export class SubtitlesService {
83
91
limit : 'best'
84
92
} )
85
93
86
- const subtitleLanguages = Object . keys ( subtitles )
94
+ const subtitleLanguages = Object . keys ( subtitles ) . filter ( lang => this . supportedLanguages . includes ( lang ) )
87
95
88
96
if ( subtitleLanguages . length > 0 ) {
89
97
const formattedSubs = [ ]
@@ -92,9 +100,9 @@ export class SubtitlesService {
92
100
93
101
await Promise . all (
94
102
subtitleLanguages . map ( async ( language ) => {
95
- try {
96
- const subtitle : SubtitleInterface = subtitles [ language ]
103
+ const subtitle : SubtitleInterface = subtitles [ language ]
97
104
105
+ try {
98
106
const subLocation = await this . downloadSubtitle ( download , subtitle , location )
99
107
100
108
formattedSubs . push ( {
@@ -104,7 +112,7 @@ export class SubtitlesService {
104
112
score : subtitle . score
105
113
} )
106
114
} catch ( err ) {
107
- this . logger . error ( `[${ download . _id } ]: Could not download subtitle "${ language } "` , err )
115
+ this . logger . error ( `[${ download . _id } ]: Could not download subtitle "${ language } " ( ${ subtitle . url } ) ` , err )
108
116
}
109
117
} )
110
118
)
Original file line number Diff line number Diff line change @@ -561,7 +561,7 @@ export class TorrentService {
561
561
/**
562
562
* Cleans up a download
563
563
*/
564
- public cleanUpDownload ( download : Model < Download > , deleteDownload = false ) {
564
+ public cleanUpDownload ( download : Model < Download > , deleteDownload = false ) : Promise < void > {
565
565
return new Promise ( async ( resolve ) => {
566
566
if ( deleteDownload ) {
567
567
// Delete the download
You can’t perform that action at this time.
0 commit comments