obsidian-media-db-sync/src/models/BookModel.ts
ltctceplrm cf36d19e11 Fixed bugs
Added a header so it doesn't limit the rate of requests as fast
Fixed year missing from title
Replaced ID from isbn to OpenLibrary ID
Added ISBN10 as separate field
2023-09-22 23:10:52 +02:00

55 lines
1 KiB
TypeScript

import { MediaTypeModel } from './MediaTypeModel';
import { mediaDbTag, migrateObject } from '../utils/Utils';
import { MediaType } from '../utils/MediaType';
export class BookModel extends MediaTypeModel {
author: string;
pages: string;
isbn10: string;
image: string;
english_title: string;
released: boolean;
userData: {
read: boolean;
lastRead: string;
personalRating: number;
};
constructor(obj: any = {}) {
super();
this.author = undefined;
this.pages = undefined;
this.image = undefined;
this.released = undefined;
this.userData = {
read: undefined,
lastRead: undefined,
personalRating: undefined,
};
migrateObject(this, obj, this);
if (!obj.hasOwnProperty('userData')) {
migrateObject(this.userData, obj, this.userData);
}
this.type = this.getMediaType();
}
getTags(): string[] {
return [mediaDbTag, 'book'];
}
getMediaType(): MediaType {
return MediaType.Book;
}
getSummary(): string {
return this.englishTitle + ' (' + this.year + ')';
}
}