@@ -17,7 +17,7 @@ export class OMDbAPI extends APIModel {
1717 this . plugin = plugin ;
1818 this . apiName = 'OMDbAPI' ;
1919 this . apiDescription = 'A free API for Movies, Series and Games.' ;
20- this . apiUrl = 'http ://www.omdbapi.com/' ;
20+ this . apiUrl = 'https ://www.omdbapi.com/' ;
2121 this . types = [ MediaType . Movie , MediaType . Series , MediaType . Game ] ;
2222 this . typeMappings = new Map < string , string > ( ) ;
2323 this . typeMappings . set ( 'movie' , 'movie' ) ;
@@ -28,7 +28,11 @@ export class OMDbAPI extends APIModel {
2828 async searchByTitle ( title : string ) : Promise < MediaTypeModel [ ] > {
2929 console . log ( `MDB | api "${ this . apiName } " queried by Title` ) ;
3030
31- const searchUrl = `http://www.omdbapi.com/?s=${ encodeURIComponent ( title ) } &apikey=${ this . plugin . settings . OMDbKey } ` ;
31+ if ( ! this . plugin . settings . OMDbKey ) {
32+ throw Error ( `MDB | ${ this . apiName } API key missing.` ) ;
33+ }
34+
35+ const searchUrl = `https://www.omdbapi.com/?s=${ encodeURIComponent ( title ) } &apikey=${ this . plugin . settings . OMDbKey } ` ;
3236 const fetchData = await fetch ( searchUrl ) ;
3337
3438 if ( fetchData . status === 401 ) {
@@ -102,7 +106,11 @@ export class OMDbAPI extends APIModel {
102106 async getById ( id : string ) : Promise < MediaTypeModel > {
103107 console . log ( `MDB | api "${ this . apiName } " queried by ID` ) ;
104108
105- const searchUrl = `http://www.omdbapi.com/?i=${ encodeURIComponent ( id ) } &apikey=${ this . plugin . settings . OMDbKey } ` ;
109+ if ( ! this . plugin . settings . OMDbKey ) {
110+ throw Error ( `MDB | ${ this . apiName } API key missing.` ) ;
111+ }
112+
113+ const searchUrl = `https://www.omdbapi.com/?i=${ encodeURIComponent ( id ) } &apikey=${ this . plugin . settings . OMDbKey } ` ;
106114 const fetchData = await fetch ( searchUrl ) ;
107115
108116 if ( fetchData . status === 401 ) {
0 commit comments