added basic MAL api

This commit is contained in:
mProjectsCode 2022-05-06 11:36:22 +02:00
parent 30d07f79f3
commit 413a855e07
6 changed files with 114 additions and 7 deletions

View file

@ -37,7 +37,13 @@ export class OMDbAPI extends APIModel {
for (const value of data.Search) {
if (value.Type === 'movie') {
ret.push(new MovieModel({title: value.Title, id: value.imdbID, dataSource: this.apiName, type: 'movie', premiere: value.Year} as MovieModel));
ret.push(new MovieModel({
type: 'movie',
title: value.Title,
year: value.Year,
dataSource: this.apiName,
id: value.imdbID,
} as MovieModel));
}
}
@ -54,10 +60,29 @@ export class OMDbAPI extends APIModel {
}
const data = await fetchData.json();
if (data.Type === 'movie') {
const model = new MovieModel({title: data.Title, id: data.imdbID, dataSource: this.apiName, type: 'movie', premiere: data.Year} as MovieModel);
console.log(data);
// TODO: mapping
if (data.Type === 'movie') {
const model = new MovieModel({
type: 'movie',
title: data.Title,
year: data.Year,
dataSource: this.apiName,
id: data.imdbID,
genres: data.Genre?.split(', ') ?? [],
producer: data.Director ?? 'unknown',
duration: data.Runtime ?? 'unknown',
onlineRating: Number.parseFloat(data.imdbRating ?? 0),
image: data.Poster ?? '',
released: true,
premiere: data.Released ?? 'unknown',
watched: false,
lastWatched: '',
personalRating: 0,
} as MovieModel);
return model;
}