@@ -3,6 +3,7 @@ import {MediaTypeModel} from '../../models/MediaTypeModel';
33import { MovieModel } from '../../models/MovieModel' ;
44import MediaDbPlugin from '../../main' ;
55import { SeriesModel } from '../../models/SeriesModel' ;
6+ import { GameModel } from '../../models/GameModel' ;
67
78export class OMDbAPI extends APIModel {
89 plugin : MediaDbPlugin ;
@@ -12,7 +13,7 @@ export class OMDbAPI extends APIModel {
1213
1314 this . plugin = plugin ;
1415 this . apiName = 'OMDbAPI' ;
15- this . apiDescription = 'A free API for Movies and Series .' ;
16+ this . apiDescription = 'A free API for Movies, Series and Games .' ;
1617 this . apiUrl = 'http://www.omdbapi.com/' ;
1718 this . types = [ 'movie' , 'series' ] ;
1819 }
@@ -44,23 +45,34 @@ export class OMDbAPI extends APIModel {
4445
4546 let ret : MediaTypeModel [ ] = [ ] ;
4647
47- for ( const value of data . Search ) {
48- if ( value . Type === 'movie' ) {
48+ for ( const result of data . Search ) {
49+ if ( result . Type === 'movie' ) {
4950 ret . push ( new MovieModel ( {
5051 type : 'movie' ,
51- title : value . Title ,
52- year : value . Year ,
52+ title : result . Title ,
53+ englishTitle : result . Title ,
54+ year : result . Year ,
5355 dataSource : this . apiName ,
54- id : value . imdbID ,
56+ id : result . imdbID ,
5557 } as MovieModel ) ) ;
56- } else if ( value . Type === 'series' ) {
58+ } else if ( result . Type === 'series' ) {
5759 ret . push ( new SeriesModel ( {
5860 type : 'series' ,
59- title : value . Title ,
60- year : value . Year ,
61+ title : result . Title ,
62+ englishTitle : result . Title ,
63+ year : result . Year ,
6164 dataSource : this . apiName ,
62- id : value . imdbID ,
65+ id : result . imdbID ,
6366 } as SeriesModel ) ) ;
67+ } else if ( result . Type === 'game' ) {
68+ ret . push ( new GameModel ( {
69+ type : 'game' ,
70+ title : result . Title ,
71+ englishTitle : result . Title ,
72+ year : result . Year ,
73+ dataSource : this . apiName ,
74+ id : result . imdbID ,
75+ } as GameModel ) ) ;
6476 }
6577 }
6678
@@ -91,6 +103,7 @@ export class OMDbAPI extends APIModel {
91103 const model = new MovieModel ( {
92104 type : 'movie' ,
93105 title : result . Title ,
106+ englishTitle : result . Title ,
94107 year : result . Year ,
95108 dataSource : this . apiName ,
96109 url : `https://www.imdb.com/title/${ result . imdbID } /` ,
@@ -115,6 +128,7 @@ export class OMDbAPI extends APIModel {
115128 const model = new SeriesModel ( {
116129 type : 'series' ,
117130 title : result . Title ,
131+ englishTitle : result . Title ,
118132 year : result . Year ,
119133 dataSource : this . apiName ,
120134 url : `https://www.imdb.com/title/${ result . imdbID } /` ,
@@ -137,6 +151,28 @@ export class OMDbAPI extends APIModel {
137151 personalRating : 0 ,
138152 } as SeriesModel ) ;
139153
154+ return model ;
155+ } else if ( result . Type === 'game' ) {
156+ const model = new GameModel ( {
157+ type : 'game' ,
158+ title : result . Title ,
159+ englishTitle : result . Title ,
160+ year : result . Year ,
161+ dataSource : this . apiName ,
162+ url : `https://www.imdb.com/title/${ result . imdbID } /` ,
163+ id : result . imdbID ,
164+
165+ genres : result . Genre ?. split ( ', ' ) ?? [ ] ,
166+ onlineRating : Number . parseFloat ( result . imdbRating ?? 0 ) ,
167+ image : result . Poster ?? '' ,
168+
169+ released : true ,
170+ releaseDate : ( new Date ( result . Released ) ) . toLocaleDateString ( ) ?? 'unknown' ,
171+
172+ played : false ,
173+ personalRating : 0 ,
174+ } as GameModel ) ;
175+
140176 return model ;
141177 }
142178
0 commit comments