Tags
This commit is contained in:
parent
003c568099
commit
344c1ebf6c
8 changed files with 39 additions and 7 deletions
|
|
@ -3,6 +3,7 @@ import {MediaTypeModel} from '../../models/MediaTypeModel';
|
||||||
import MediaDbPlugin from '../../main';
|
import MediaDbPlugin from '../../main';
|
||||||
import {requestUrl} from 'obsidian';
|
import {requestUrl} from 'obsidian';
|
||||||
import {MusicReleaseModel} from '../../models/MusicReleaseModel';
|
import {MusicReleaseModel} from '../../models/MusicReleaseModel';
|
||||||
|
import {contactEmail, pluginName} from '../../utils/Utils';
|
||||||
// import {MusicBrainzApi} from 'musicbrainz-api';
|
// import {MusicBrainzApi} from 'musicbrainz-api';
|
||||||
|
|
||||||
// WIP
|
// WIP
|
||||||
|
|
@ -27,7 +28,7 @@ export class MusicBrainzAPI extends APIModel {
|
||||||
const fetchData = await requestUrl({
|
const fetchData = await requestUrl({
|
||||||
url: searchUrl,
|
url: searchUrl,
|
||||||
headers: {
|
headers: {
|
||||||
'User-Agent': 'obsidian-media-db-plugin/0.1.7 ( m.projects.code@gmail.com )',
|
'User-Agent': `${pluginName}/0.1.7 (${contactEmail})`,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -68,7 +69,7 @@ export class MusicBrainzAPI extends APIModel {
|
||||||
const fetchData = await requestUrl({
|
const fetchData = await requestUrl({
|
||||||
url: searchUrl,
|
url: searchUrl,
|
||||||
headers: {
|
headers: {
|
||||||
'User-Agent': 'MyAwesomeTagger/1.2.0 ( me@example.com )',
|
'User-Agent': `${pluginName}/0.1.7 (${contactEmail})`,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import {MediaTypeModel} from './MediaTypeModel';
|
import {MediaTypeModel} from './MediaTypeModel';
|
||||||
import {stringifyYaml} from 'obsidian';
|
import {stringifyYaml} from 'obsidian';
|
||||||
|
import {mediaDbTag} from '../utils/Utils';
|
||||||
|
|
||||||
|
|
||||||
export class GameModel extends MediaTypeModel {
|
export class GameModel extends MediaTypeModel {
|
||||||
|
|
@ -29,11 +30,15 @@ export class GameModel extends MediaTypeModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
toMetaData(): string {
|
toMetaData(): string {
|
||||||
return stringifyYaml(this);
|
return stringifyYaml({...this, tags: '#' + this.getTags().join('/')});
|
||||||
}
|
}
|
||||||
|
|
||||||
getFileName(): string {
|
getFileName(): string {
|
||||||
return this.title + (this.year ? ` (${this.year})` : '');
|
return this.title + (this.year ? ` (${this.year})` : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getTags(): string[] {
|
||||||
|
return [mediaDbTag, 'game'];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,4 +10,6 @@ export abstract class MediaTypeModel {
|
||||||
abstract toMetaData(): string;
|
abstract toMetaData(): string;
|
||||||
|
|
||||||
abstract getFileName(): string;
|
abstract getFileName(): string;
|
||||||
|
|
||||||
|
abstract getTags(): string[];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import {MediaTypeModel} from './MediaTypeModel';
|
import {MediaTypeModel} from './MediaTypeModel';
|
||||||
import {stringifyYaml} from 'obsidian';
|
import {stringifyYaml} from 'obsidian';
|
||||||
|
import {mediaDbTag} from '../utils/Utils';
|
||||||
|
|
||||||
|
|
||||||
export class MovieModel extends MediaTypeModel {
|
export class MovieModel extends MediaTypeModel {
|
||||||
|
|
@ -32,11 +33,15 @@ export class MovieModel extends MediaTypeModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
toMetaData(): string {
|
toMetaData(): string {
|
||||||
return stringifyYaml(this);
|
return stringifyYaml({...this, tags: '#' + this.getTags().join('/')});
|
||||||
}
|
}
|
||||||
|
|
||||||
getFileName(): string {
|
getFileName(): string {
|
||||||
return this.title + (this.year ? ` (${this.year})` : '');
|
return this.title + (this.year ? ` (${this.year})` : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getTags(): string[] {
|
||||||
|
return [mediaDbTag, 'tv', 'movie'];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import {MediaTypeModel} from './MediaTypeModel';
|
import {MediaTypeModel} from './MediaTypeModel';
|
||||||
import {stringifyYaml} from 'obsidian';
|
import {stringifyYaml} from 'obsidian';
|
||||||
|
import {mediaDbTag} from '../utils/Utils';
|
||||||
|
|
||||||
|
|
||||||
export class MusicReleaseModel extends MediaTypeModel {
|
export class MusicReleaseModel extends MediaTypeModel {
|
||||||
|
|
@ -25,11 +26,15 @@ export class MusicReleaseModel extends MediaTypeModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
toMetaData(): string {
|
toMetaData(): string {
|
||||||
return stringifyYaml(this);
|
return stringifyYaml({...this, tags: '#' + this.getTags().join('/')});
|
||||||
}
|
}
|
||||||
|
|
||||||
getFileName(): string {
|
getFileName(): string {
|
||||||
return this.title + ' (' + this.artists.join(', ') + ' - ' + this.year + ' - ' + this.subType + ')';
|
return this.title + ' (' + this.artists.join(', ') + ' - ' + this.year + ' - ' + this.subType + ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getTags(): string[] {
|
||||||
|
return [mediaDbTag, 'music', 'album'];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import {MediaTypeModel} from './MediaTypeModel';
|
import {MediaTypeModel} from './MediaTypeModel';
|
||||||
import {stringifyYaml} from 'obsidian';
|
import {stringifyYaml} from 'obsidian';
|
||||||
|
import {mediaDbTag} from '../utils/Utils';
|
||||||
|
|
||||||
|
|
||||||
export class SeriesModel extends MediaTypeModel {
|
export class SeriesModel extends MediaTypeModel {
|
||||||
|
|
@ -35,11 +36,15 @@ export class SeriesModel extends MediaTypeModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
toMetaData(): string {
|
toMetaData(): string {
|
||||||
return stringifyYaml(this);
|
return stringifyYaml({...this, tags: '#' + this.getTags().join('/')});
|
||||||
}
|
}
|
||||||
|
|
||||||
getFileName(): string {
|
getFileName(): string {
|
||||||
return this.title + ' (' + this.year + ')';
|
return this.title + ' (' + this.year + ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getTags(): string[] {
|
||||||
|
return [mediaDbTag, 'tv', 'series'];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import {MediaTypeModel} from './MediaTypeModel';
|
import {MediaTypeModel} from './MediaTypeModel';
|
||||||
import {stringifyYaml} from 'obsidian';
|
import {stringifyYaml} from 'obsidian';
|
||||||
|
import {mediaDbTag} from '../utils/Utils';
|
||||||
|
|
||||||
|
|
||||||
export class WikiModel extends MediaTypeModel {
|
export class WikiModel extends MediaTypeModel {
|
||||||
|
|
@ -23,11 +24,15 @@ export class WikiModel extends MediaTypeModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
toMetaData(): string {
|
toMetaData(): string {
|
||||||
return stringifyYaml(this);
|
return stringifyYaml({...this, tags: '#' + this.getTags().join('/')});
|
||||||
}
|
}
|
||||||
|
|
||||||
getFileName(): string {
|
getFileName(): string {
|
||||||
return this.title;
|
return this.title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getTags(): string[] {
|
||||||
|
return [mediaDbTag, 'wiki'];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -79,3 +79,7 @@ function traverseMetaData(path: Array<string>, mediaTypeModel: MediaTypeModel):
|
||||||
|
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const pluginName = 'obsidian-media-db-plugin';
|
||||||
|
export const contactEmail = 'm.projects.code@gmail.com';
|
||||||
|
export const mediaDbTag = 'mediaDB';
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue