@@ -28,8 +28,8 @@ export class OMDbAPI extends APIModel {
2828 async searchByTitle ( title : string ) : Promise < MediaTypeModel [ ] > {
2929 console . log ( `MDB | api "${ this . apiName } " queried by Title` ) ;
3030
31- if ( ! this . plugin . settings . OMDbKey ) {
32- throw Error ( `MDB | ${ this . apiName } API key missing.` ) ;
31+ if ( ! this . plugin . settings . OMDbKey ) {
32+ throw Error ( `MDB | API key for ${ this . apiName } missing.` ) ;
3333 }
3434
3535 const searchUrl = `https://www.omdbapi.com/?s=${ encodeURIComponent ( title ) } &apikey=${ this . plugin . settings . OMDbKey } ` ;
@@ -39,7 +39,7 @@ export class OMDbAPI extends APIModel {
3939 throw Error ( `MDB | Authentication for ${ this . apiName } failed. Check the API key.` ) ;
4040 }
4141 if ( fetchData . status !== 200 ) {
42- throw Error ( `MDB | Received status code ${ fetchData . status } from an API .` ) ;
42+ throw Error ( `MDB | Received status code ${ fetchData . status } from ${ this . apiName } .` ) ;
4343 }
4444
4545 const data = await fetchData . json ( ) ;
@@ -55,7 +55,7 @@ export class OMDbAPI extends APIModel {
5555 return [ ] ;
5656 }
5757
58- console . debug ( data . Search ) ;
58+ // console.debug(data.Search);
5959
6060 const ret : MediaTypeModel [ ] = [ ] ;
6161
@@ -106,8 +106,8 @@ export class OMDbAPI extends APIModel {
106106 async getById ( id : string ) : Promise < MediaTypeModel > {
107107 console . log ( `MDB | api "${ this . apiName } " queried by ID` ) ;
108108
109- if ( ! this . plugin . settings . OMDbKey ) {
110- throw Error ( `MDB | ${ this . apiName } API key missing.` ) ;
109+ if ( ! this . plugin . settings . OMDbKey ) {
110+ throw Error ( `MDB | API key for ${ this . apiName } missing.` ) ;
111111 }
112112
113113 const searchUrl = `https://www.omdbapi.com/?i=${ encodeURIComponent ( id ) } &apikey=${ this . plugin . settings . OMDbKey } ` ;
@@ -117,7 +117,7 @@ export class OMDbAPI extends APIModel {
117117 throw Error ( `MDB | Authentication for ${ this . apiName } failed. Check the API key.` ) ;
118118 }
119119 if ( fetchData . status !== 200 ) {
120- throw Error ( `MDB | Received status code ${ fetchData . status } from an API .` ) ;
120+ throw Error ( `MDB | Received status code ${ fetchData . status } from ${ this . apiName } .` ) ;
121121 }
122122
123123 const result = await fetchData . json ( ) ;
@@ -133,7 +133,7 @@ export class OMDbAPI extends APIModel {
133133 }
134134
135135 if ( type === 'movie' ) {
136- const model = new MovieModel ( {
136+ return new MovieModel ( {
137137 type : type ,
138138 title : result . Title ,
139139 englishTitle : result . Title ,
@@ -162,10 +162,8 @@ export class OMDbAPI extends APIModel {
162162 personalRating : 0 ,
163163 } ,
164164 } as MovieModel ) ;
165-
166- return model ;
167165 } else if ( type === 'series' ) {
168- const model = new SeriesModel ( {
166+ return new SeriesModel ( {
169167 type : type ,
170168 title : result . Title ,
171169 englishTitle : result . Title ,
@@ -196,10 +194,8 @@ export class OMDbAPI extends APIModel {
196194 personalRating : 0 ,
197195 } ,
198196 } as SeriesModel ) ;
199-
200- return model ;
201197 } else if ( type === 'game' ) {
202- const model = new GameModel ( {
198+ return new GameModel ( {
203199 type : type ,
204200 title : result . Title ,
205201 englishTitle : result . Title ,
@@ -222,8 +218,6 @@ export class OMDbAPI extends APIModel {
222218 personalRating : 0 ,
223219 } ,
224220 } as GameModel ) ;
225-
226- return model ;
227221 }
228222
229223 return ;
0 commit comments