@@ -3,7 +3,7 @@ import { MediaTypeModel } from '../../models/MediaTypeModel';
33import { MovieModel } from '../../models/MovieModel' ;
44import MediaDbPlugin from '../../main' ;
55import { SeriesModel } from '../../models/SeriesModel' ;
6- import { debugLog } from '../../utils/Utils ' ;
6+ import { MediaType } from '../../utils/MediaType ' ;
77
88export class MALAPI extends APIModel {
99 plugin : MediaDbPlugin ;
@@ -16,7 +16,7 @@ export class MALAPI extends APIModel {
1616 this . apiName = 'MALAPI' ;
1717 this . apiDescription = 'A free API for Anime. Some results may take a long time to load.' ;
1818 this . apiUrl = 'https://jikan.moe/' ;
19- this . types = [ 'movie' , 'series' , 'anime' ] ;
19+ this . types = [ MediaType . Movie , MediaType . Series ] ;
2020 this . typeMappings = new Map < string , string > ( ) ;
2121 this . typeMappings . set ( 'movie' , 'movie' ) ;
2222 this . typeMappings . set ( 'special' , 'special' ) ;
@@ -30,13 +30,13 @@ export class MALAPI extends APIModel {
3030 const searchUrl = `https://api.jikan.moe/v4/anime?q=${ encodeURIComponent ( title ) } &limit=20${ this . plugin . settings . sfwFilter ? '&sfw' : '' } ` ;
3131
3232 const fetchData = await fetch ( searchUrl ) ;
33- debugLog ( fetchData ) ;
33+ console . debug ( fetchData ) ;
3434 if ( fetchData . status !== 200 ) {
3535 throw Error ( `MDB | Received status code ${ fetchData . status } from an API.` ) ;
3636 }
3737 const data = await fetchData . json ( ) ;
3838
39- debugLog ( data ) ;
39+ console . debug ( data ) ;
4040
4141 let ret : MediaTypeModel [ ] = [ ] ;
4242
@@ -85,15 +85,15 @@ export class MALAPI extends APIModel {
8585 async getById ( id : string ) : Promise < MediaTypeModel > {
8686 console . log ( `MDB | api "${ this . apiName } " queried by ID` ) ;
8787
88- const searchUrl = `https://api.jikan.moe/v4/anime/${ encodeURIComponent ( id ) } ` ;
88+ const searchUrl = `https://api.jikan.moe/v4/anime/${ encodeURIComponent ( id ) } /full ` ;
8989 const fetchData = await fetch ( searchUrl ) ;
9090
9191 if ( fetchData . status !== 200 ) {
9292 throw Error ( `MDB | Received status code ${ fetchData . status } from an API.` ) ;
9393 }
9494
9595 const data = await fetchData . json ( ) ;
96- debugLog ( data ) ;
96+ console . debug ( data ) ;
9797 const result = data . data ;
9898
9999 const type = this . typeMappings . get ( result . type ?. toLowerCase ( ) ) ;
@@ -111,10 +111,12 @@ export class MALAPI extends APIModel {
111111 producer : result . studios ?. map ( ( x : any ) => x . name ) . join ( ', ' ) ?? 'unknown' ,
112112 duration : result . duration ?? 'unknown' ,
113113 onlineRating : result . score ?? 0 ,
114+ actors : [ ] ,
114115 image : result . images ?. jpg ?. image_url ?? '' ,
115116
116117 released : true ,
117118 premiere : new Date ( result . aired ?. from ) . toLocaleDateString ( ) ?? 'unknown' ,
119+ streamingServices : result . streaming ?. map ( ( x : any ) => x . name ) ?? [ ] ,
118120
119121 userData : {
120122 watched : false ,
@@ -140,10 +142,12 @@ export class MALAPI extends APIModel {
140142 producer : result . studios ?. map ( ( x : any ) => x . name ) . join ( ', ' ) ?? 'unknown' ,
141143 duration : result . duration ?? 'unknown' ,
142144 onlineRating : result . score ?? 0 ,
145+ actors : [ ] ,
143146 image : result . images ?. jpg ?. image_url ?? '' ,
144147
145148 released : true ,
146149 premiere : new Date ( result . aired ?. from ) . toLocaleDateString ( ) ?? 'unknown' ,
150+ streamingServices : result . streaming ?. map ( ( x : any ) => x . name ) ?? [ ] ,
147151
148152 userData : {
149153 watched : false ,
@@ -168,6 +172,7 @@ export class MALAPI extends APIModel {
168172 episodes : result . episodes ,
169173 duration : result . duration ?? 'unknown' ,
170174 onlineRating : result . score ?? 0 ,
175+ streamingServices : result . streaming ?. map ( ( x : any ) => x . name ) ?? [ ] ,
171176 image : result . images ?. jpg ?. image_url ?? '' ,
172177
173178 released : true ,
0 commit comments