release year in title
This commit is contained in:
parent
6dc813a14c
commit
99980028d0
5 changed files with 6 additions and 5 deletions
|
|
@ -36,7 +36,7 @@ export class OMDbAPI extends APIModel {
|
||||||
|
|
||||||
for (const value of data.Search) {
|
for (const value of data.Search) {
|
||||||
if (value.Type === 'movie') {
|
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();
|
const data = await fetchData.json();
|
||||||
if (data.Type === 'movie') {
|
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
|
// TODO: mapping
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ export class MediaDbSearchResultModal extends SuggestModal<MediaTypeModel> {
|
||||||
|
|
||||||
// Renders each suggestion item.
|
// Renders each suggestion item.
|
||||||
renderSuggestion(item: MediaTypeModel, el: HTMLElement) {
|
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}`});
|
el.createEl('small', {text: `${item.type} from ${item.dataSource}`});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
export abstract class MediaTypeModel {
|
export abstract class MediaTypeModel {
|
||||||
type: string;
|
type: string;
|
||||||
title: string;
|
title: string;
|
||||||
|
premiere: string;
|
||||||
dataSource: string;
|
dataSource: string;
|
||||||
id: string;
|
id: string;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import {stringifyYaml} from 'obsidian';
|
||||||
export class MovieModel extends MediaTypeModel {
|
export class MovieModel extends MediaTypeModel {
|
||||||
type: string;
|
type: string;
|
||||||
title: string;
|
title: string;
|
||||||
|
premiere: string;
|
||||||
dataSource: string;
|
dataSource: string;
|
||||||
id: string;
|
id: string;
|
||||||
|
|
||||||
|
|
@ -15,7 +16,6 @@ export class MovieModel extends MediaTypeModel {
|
||||||
image: string;
|
image: string;
|
||||||
|
|
||||||
released: boolean;
|
released: boolean;
|
||||||
premiere: string;
|
|
||||||
|
|
||||||
watched: boolean;
|
watched: boolean;
|
||||||
lastWatched: string;
|
lastWatched: string;
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ export function sleep(ms: number) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getFileName(item: MediaTypeModel) {
|
export function getFileName(item: MediaTypeModel) {
|
||||||
return replaceIllegalFileNameCharactersInString(item.title);
|
return replaceIllegalFileNameCharactersInString(item.premiere ? `${item.title} (${item.premiere})` : `${item.title}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function replaceIllegalFileNameCharactersInString(string: string) {
|
export function replaceIllegalFileNameCharactersInString(string: string) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue