obsidian-media-db-sync/packages/obsidian/src/models/SeasonModel.ts
2026-05-06 16:26:59 +02:00

80 lines
1.6 KiB
TypeScript

import { MediaTypeModel } from 'packages/obsidian/src/models/MediaTypeModel';
import { MediaType } from 'packages/obsidian/src/utils/MediaType';
import type { ModelToData } from 'packages/obsidian/src/utils/Utils';
import { mediaDbTag, migrateObject } from 'packages/obsidian/src/utils/Utils';
export type SeasonData = ModelToData<SeasonModel>;
export class SeasonModel extends MediaTypeModel {
seasonNumber: number;
seasonTitle: string;
episodes: number;
plot: string;
genres: string[];
writer: string[];
studio: string[];
duration: string;
onlineRating: number;
actors: string[];
image: string;
released: boolean;
streamingServices: string[];
airing: boolean;
airedFrom: string;
airedTo: string;
userData: {
watched: boolean;
lastWatched: string;
personalRating: number;
};
constructor(obj: SeasonData) {
super();
this.seasonTitle = '';
this.seasonNumber = 0;
this.episodes = 0;
this.plot = '';
this.genres = [];
this.writer = [];
this.studio = [];
this.duration = '';
this.onlineRating = 0;
this.actors = [];
this.image = '';
this.released = false;
this.streamingServices = [];
this.airing = false;
this.airedFrom = '';
this.airedTo = '';
this.userData = {
watched: false,
lastWatched: '',
personalRating: 0,
};
migrateObject(this, obj, this);
if (!Object.hasOwn(obj, 'userData')) {
migrateObject(this.userData, obj, this.userData);
}
this.type = this.getMediaType();
}
getTags(): string[] {
return [mediaDbTag, 'tv', 'season'];
}
getMediaType(): MediaType {
return MediaType.Season;
}
getSummary(): string {
return this.seasonNumber + ' seasons';
}
}