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:
parent
01b56c9be5
commit
a07e549ea4
8 changed files with 128 additions and 93 deletions
74
src/models/ComicMangaModel.ts
Normal file
74
src/models/ComicMangaModel.ts
Normal 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 + ')';
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue