Merged comic book models with manga models into comicmanga model

Updated both MALAPI Manga and ComicVine API to be more consistent with eachother.
This commit is contained in:
ltctceplrm 2025-02-11 21:51:08 +01:00
parent 01b56c9be5
commit a07e549ea4
8 changed files with 128 additions and 93 deletions

View file

@ -0,0 +1,74 @@
import { MediaType } from '../utils/MediaType';
import type { ModelToData } from '../utils/Utils';
import { mediaDbTag, migrateObject } from '../utils/Utils';
import { MediaTypeModel } from './MediaTypeModel';
export type ComicMangaData = ModelToData<ComicMangaModel>;
export class ComicMangaModel extends MediaTypeModel {
plot: string;
alternateTitles: string[];
genres: string[];
authors: string[];
chapters: number;
volumes: number;
onlineRating: number;
image: string;
released: boolean;
status: string;
publishers: string[];
publishedFrom: string;
publishedTo: string;
userData: {
read: boolean;
lastRead: string;
personalRating: number;
};
constructor(obj: ComicMangaData) {
super();
this.plot = '';
this.alternateTitles = [];
this.genres = [];
this.authors = [];
this.chapters = 0;
this.volumes = 0;
this.onlineRating = 0;
this.image = '';
this.released = false;
this.status = '';
this.publishers = [];
this.publishedFrom = '';
this.publishedTo = '';
this.userData = {
read: false,
lastRead: '',
personalRating: 0,
};
migrateObject(this, obj, this);
if (!obj.hasOwnProperty('userData')) {
migrateObject(this.userData, obj, this.userData);
}
this.type = this.getMediaType();
}
getTags(): string[] {
return [mediaDbTag, 'manga', 'light-novel', 'comicbook'];
}
getMediaType(): MediaType {
return MediaType.ComicManga;
}
getSummary(): string {
return this.title + ' (' + this.year + ')';
}
}