@@ -39,6 +39,7 @@ export class ApiService {
39
39
API_URL_GENRES_MOVIE = '/api/genres/movie/' ;
40
40
API_URL_GENRES_TV = '/api/genres/tv/' ;
41
41
API_URL_MEDIA_CATEGORIES = '/api/media-categories/' ;
42
+ API_URL_QUALITIES = '/api/qualities/' ;
42
43
API_URL_QUALITY_PROFILES = '/api/quality-profile/' ;
43
44
API_URL_GIT_COMMIT = '/api/git-commit/' ;
44
45
API_URL_IMPORT_MEDIA_TV = '/api/import/media/tv/' ;
@@ -55,6 +56,7 @@ export class ApiService {
55
56
public userToken : string ;
56
57
public users : any ; // staff-only list of all users
57
58
public settings : any ;
59
+ public qualities : string [ ] = [ ] ;
58
60
public qualityProfiles : any [ ] = [ ] ;
59
61
public mediaCategories : string [ ] ;
60
62
public watchTVSeasons : any [ ] = [ ] ;
@@ -180,6 +182,7 @@ export class ApiService {
180
182
}
181
183
} )
182
184
) ,
185
+ this . fetchQualities ( ) ,
183
186
this . fetchQualityProfiles ( ) ,
184
187
this . fetchMediaCategories ( ) ,
185
188
] ) . pipe (
@@ -211,7 +214,7 @@ export class ApiService {
211
214
) ;
212
215
}
213
216
214
- public fetchSettings ( ) {
217
+ public fetchSettings ( ) : Observable < any > {
215
218
return this . http . get ( this . API_URL_SETTINGS , { headers : this . _requestHeaders ( ) } ) . pipe (
216
219
map ( ( data : any ) => {
217
220
if ( data . length ) {
@@ -224,7 +227,7 @@ export class ApiService {
224
227
) ;
225
228
}
226
229
227
- public fetchMediaCategories ( ) {
230
+ public fetchMediaCategories ( ) : Observable < string [ ] > {
228
231
return this . http . get ( this . API_URL_MEDIA_CATEGORIES , { headers : this . _requestHeaders ( ) } ) . pipe (
229
232
map ( ( data : any ) => {
230
233
if ( data . mediaCategories ) {
@@ -237,7 +240,20 @@ export class ApiService {
237
240
) ;
238
241
}
239
242
240
- public fetchQualityProfiles ( ) {
243
+ public fetchQualities ( ) : Observable < string [ ] > {
244
+ return this . http . get ( this . API_URL_QUALITIES , { headers : this . _requestHeaders ( ) } ) . pipe (
245
+ map ( ( data : any ) => {
246
+ if ( data . length ) {
247
+ this . qualities = data ;
248
+ } else {
249
+ console . error ( 'no qualities' ) ;
250
+ }
251
+ return this . qualities ;
252
+ } ) ,
253
+ ) ;
254
+ }
255
+
256
+ public fetchQualityProfiles ( ) : Observable < any [ ] > {
241
257
return this . http . get ( this . API_URL_QUALITY_PROFILES , { headers : this . _requestHeaders ( ) } ) . pipe (
242
258
map ( ( data : any ) => {
243
259
if ( data . length ) {
@@ -303,7 +319,7 @@ export class ApiService {
303
319
) ;
304
320
}
305
321
306
- public login ( user : string , pass : string ) {
322
+ public login ( user : string , pass : string ) : Observable < any > {
307
323
const params = {
308
324
username : user ,
309
325
password : pass ,
@@ -334,15 +350,27 @@ export class ApiService {
334
350
) ;
335
351
}
336
352
337
- public searchTorrents ( query : string , mediaType : string ) {
353
+ public updateQualityProfile ( id : number , params : any ) : Observable < any > {
354
+ return this . http . patch ( `${ this . API_URL_QUALITY_PROFILES } ${ id } /` , params , { headers : this . _requestHeaders ( ) } ) . pipe (
355
+ map ( ( data : any ) => {
356
+ this . qualityProfiles . forEach ( ( profile , index ) => {
357
+ if ( profile . id === id ) {
358
+ this . qualityProfiles [ index ] = params ;
359
+ }
360
+ } )
361
+ } ) ,
362
+ ) ;
363
+ }
364
+
365
+ public searchTorrents ( query : string , mediaType : string ) : Observable < any > {
338
366
return this . http . get ( `${ this . API_URL_SEARCH_TORRENTS } ?q=${ query } &media_type=${ mediaType } ` , { headers : this . _requestHeaders ( ) } ) . pipe (
339
367
map ( ( data : any ) => {
340
368
return data ;
341
369
} ) ,
342
370
) ;
343
371
}
344
372
345
- public download ( torrentResult : any , mediaType : string , tmdbMedia : any , params ?: any ) {
373
+ public download ( torrentResult : any , mediaType : string , tmdbMedia : any , params ?: any ) : Observable < any > {
346
374
// add extra params
347
375
Object . assign ( params || { } , {
348
376
torrent : torrentResult ,
@@ -377,7 +405,7 @@ export class ApiService {
377
405
) ;
378
406
}
379
407
380
- public searchMedia ( query : string , mediaType : string , page = 1 ) {
408
+ public searchMedia ( query : string , mediaType : string , page = 1 ) : Observable < any > {
381
409
let params = {
382
410
q : query ,
383
411
media_type : mediaType ,
@@ -392,7 +420,7 @@ export class ApiService {
392
420
) ;
393
421
}
394
422
395
- public searchSimilarMedia ( tmdbMediaId : string , mediaType : string ) {
423
+ public searchSimilarMedia ( tmdbMediaId : string , mediaType : string ) : Observable < any > {
396
424
let params = {
397
425
tmdb_media_id : tmdbMediaId ,
398
426
media_type : mediaType ,
@@ -407,7 +435,7 @@ export class ApiService {
407
435
) ;
408
436
}
409
437
410
- public searchRecommendedMedia ( tmdbMediaId : string , mediaType : string ) {
438
+ public searchRecommendedMedia ( tmdbMediaId : string , mediaType : string ) : Observable < any > {
411
439
let params = {
412
440
tmdb_media_id : tmdbMediaId ,
413
441
media_type : mediaType ,
@@ -422,7 +450,7 @@ export class ApiService {
422
450
) ;
423
451
}
424
452
425
- public searchMediaDetail ( mediaType : string , id : string ) {
453
+ public searchMediaDetail ( mediaType : string , id : string ) : Observable < any > {
426
454
const options = { headers : this . _requestHeaders ( ) , params : this . _defaultParams ( ) } ;
427
455
return this . http . get ( `${ this . API_URL_SEARCH_MEDIA } ${ mediaType } /${ id } /` , options ) . pipe (
428
456
map ( ( data : any ) => {
@@ -431,7 +459,7 @@ export class ApiService {
431
459
) ;
432
460
}
433
461
434
- public fetchMediaVideos ( mediaType : string , id : string ) {
462
+ public fetchMediaVideos ( mediaType : string , id : string ) : Observable < any > {
435
463
const options = { headers : this . _requestHeaders ( ) } ;
436
464
return this . http . get ( `${ this . API_URL_SEARCH_MEDIA } ${ mediaType } /${ id } /videos/` , options ) . pipe (
437
465
map ( ( data : any ) => {
@@ -440,7 +468,7 @@ export class ApiService {
440
468
) ;
441
469
}
442
470
443
- public fetchWatchTVShows ( params ?: any ) {
471
+ public fetchWatchTVShows ( params ?: any ) : Observable < any [ ] > {
444
472
params = params || { } ;
445
473
const httpParams = new HttpParams ( { fromObject : params } ) ;
446
474
return this . http . get ( this . API_URL_WATCH_TV_SHOW , { params : httpParams , headers : this . _requestHeaders ( ) } ) . pipe (
@@ -451,7 +479,7 @@ export class ApiService {
451
479
) ;
452
480
}
453
481
454
- public fetchWatchTVSeasons ( params ?: any ) {
482
+ public fetchWatchTVSeasons ( params ?: any ) : Observable < any [ ] > {
455
483
params = params || { } ;
456
484
const httpParams = new HttpParams ( { fromObject : params } ) ;
457
485
return this . http . get ( this . API_URL_WATCH_TV_SEASON , { params : httpParams , headers : this . _requestHeaders ( ) } ) . pipe (
@@ -467,7 +495,7 @@ export class ApiService {
467
495
) ;
468
496
}
469
497
470
- public fetchWatchTVSeasonRequests ( params ?: any ) {
498
+ public fetchWatchTVSeasonRequests ( params ?: any ) : Observable < any [ ] > {
471
499
params = params || { } ;
472
500
const httpParams = new HttpParams ( { fromObject : params } ) ;
473
501
return this . http . get ( this . API_URL_WATCH_TV_SEASON_REQUEST , { params : httpParams , headers : this . _requestHeaders ( ) } ) . pipe (
@@ -483,7 +511,7 @@ export class ApiService {
483
511
) ;
484
512
}
485
513
486
- public fetchWatchMovies ( params ?: any ) {
514
+ public fetchWatchMovies ( params ?: any ) : Observable < any [ ] > {
487
515
params = params || { } ;
488
516
const httpParams = new HttpParams ( { fromObject : params } ) ;
489
517
@@ -500,7 +528,7 @@ export class ApiService {
500
528
) ;
501
529
}
502
530
503
- public fetchWatchTVEpisodes ( params : any ) {
531
+ public fetchWatchTVEpisodes ( params : any ) : Observable < any [ ] > {
504
532
const httpParams = new HttpParams ( { fromObject : params } ) ;
505
533
return this . http . get ( this . API_URL_WATCH_TV_EPISODE , { headers : this . _requestHeaders ( ) , params : httpParams } ) . pipe (
506
534
map ( ( records : any ) => {
@@ -515,7 +543,7 @@ export class ApiService {
515
543
) ;
516
544
}
517
545
518
- public fetchCurrentTorrents ( params : any ) {
546
+ public fetchCurrentTorrents ( params : any ) : Observable < any [ ] > {
519
547
const httpParams = new HttpParams ( { fromObject : params } ) ;
520
548
return this . http . get ( this . API_URL_CURRENT_TORRENTS , { headers : this . _requestHeaders ( ) , params : httpParams } ) . pipe (
521
549
map ( ( data : any ) => {
@@ -734,7 +762,7 @@ export class ApiService {
734
762
) ;
735
763
}
736
764
737
- public verifySettings ( ) {
765
+ public verifySettings ( ) : Observable < any > {
738
766
return this . http . get ( `${ this . API_URL_SETTINGS } ${ this . settings . id } /verify/` , { headers : this . _requestHeaders ( ) } ) . pipe (
739
767
map ( ( data : any ) => {
740
768
return data ;
@@ -801,15 +829,15 @@ export class ApiService {
801
829
return this . _discoverMedia ( this . SEARCH_MEDIA_TYPE_TV , params ) ;
802
830
}
803
831
804
- public fetchMovieGenres ( ) {
832
+ public fetchMovieGenres ( ) : Observable < any > {
805
833
return this . _fetchGenres ( this . SEARCH_MEDIA_TYPE_MOVIE ) ;
806
834
}
807
835
808
- public fetchTVGenres ( ) {
836
+ public fetchTVGenres ( ) : Observable < any > {
809
837
return this . _fetchGenres ( this . SEARCH_MEDIA_TYPE_TV ) ;
810
838
}
811
839
812
- public verifyJackettIndexers ( ) {
840
+ public verifyJackettIndexers ( ) : Observable < any > {
813
841
return this . http . get ( `${ this . API_URL_SETTINGS } ${ this . settings . id } /verify-jackett-indexers/` , { headers : this . _requestHeaders ( ) } ) ;
814
842
}
815
843
@@ -837,7 +865,7 @@ export class ApiService {
837
865
return this . http . get ( url , { params : httpParams , headers : this . _requestHeaders ( ) } ) ;
838
866
}
839
867
840
- public openSubtitlesAuth ( ) {
868
+ public openSubtitlesAuth ( ) : Observable < any > {
841
869
const url = this . API_URL_OPEN_SUBTITLES_AUTH ;
842
870
return this . http . post ( url , null , { headers : this . _requestHeaders ( ) } ) ;
843
871
}
@@ -961,13 +989,13 @@ export class ApiService {
961
989
this . _updateStorage ( ) . subscribe ( ) ;
962
990
}
963
991
964
- protected _fetchGenres ( mediaType : string ) {
992
+ protected _fetchGenres ( mediaType : string ) : Observable < any > {
965
993
const url = mediaType === this . SEARCH_MEDIA_TYPE_MOVIE ? this . API_URL_GENRES_MOVIE : this . API_URL_GENRES_TV ;
966
994
const params = this . _defaultParams ( ) ;
967
995
return this . http . get ( url , { headers : this . _requestHeaders ( ) , params : params } ) ;
968
996
}
969
997
970
- protected _discoverMedia ( mediaType : string , params : any ) {
998
+ protected _discoverMedia ( mediaType : string , params : any ) : Observable < any > {
971
999
params = Object . assign ( params , this . _defaultParams ( ) ) ;
972
1000
const httpParams = new HttpParams ( { fromObject : params } ) ;
973
1001
const url = mediaType === this . SEARCH_MEDIA_TYPE_MOVIE ? this . API_URL_DISCOVER_MOVIES : this . API_URL_DISCOVER_TV ;
0 commit comments