release year in title

This commit is contained in:
mProjectsCode 2022-05-05 21:03:47 +02:00
parent 6dc813a14c
commit 99980028d0
5 changed files with 6 additions and 5 deletions

View file

@ -36,7 +36,7 @@ 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'} as MovieModel));
ret.push(new MovieModel({title: value.Title, id: value.imdbID, dataSource: this.apiName, type: 'movie', premiere: value.Year} as MovieModel));
}
}
@ -54,7 +54,7 @@ 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'} as MovieModel);
const model = new MovieModel({title: data.Title, id: data.imdbID, dataSource: this.apiName, type: 'movie', premiere: data.Year} as MovieModel);
// TODO: mapping

View file

@ -20,7 +20,7 @@ export class MediaDbSearchResultModal extends SuggestModal<MediaTypeModel> {
// Renders each suggestion item.
renderSuggestion(item: MediaTypeModel, el: HTMLElement) {
el.createEl('div', {text: item.title});
el.createEl('div', {text: item.premiere ? `${item.title} (${item.premiere})` : `${item.title}`});
el.createEl('small', {text: `${item.type} from ${item.dataSource}`});
}

View file

@ -1,6 +1,7 @@
export abstract class MediaTypeModel {
type: string;
title: string;
premiere: string;
dataSource: string;
id: string;

View file

@ -5,6 +5,7 @@ import {stringifyYaml} from 'obsidian';
export class MovieModel extends MediaTypeModel {
type: string;
title: string;
premiere: string;
dataSource: string;
id: string;
@ -15,7 +16,6 @@ export class MovieModel extends MediaTypeModel {
image: string;
released: boolean;
premiere: string;
watched: boolean;
lastWatched: string;

View file

@ -9,7 +9,7 @@ export function sleep(ms: number) {
}
export function getFileName(item: MediaTypeModel) {
return replaceIllegalFileNameCharactersInString(item.title);
return replaceIllegalFileNameCharactersInString(item.premiere ? `${item.title} (${item.premiere})` : `${item.title}`);
}
export function replaceIllegalFileNameCharactersInString(string: string) {