maintenance
This commit is contained in:
parent
846f7de184
commit
1d76bb8981
7 changed files with 80 additions and 55 deletions
18
README.md
18
README.md
|
|
@ -111,15 +111,14 @@ Now you select the result you want and the plugin will cast it's magic and creat
|
|||
|
||||
### Currently supported APIs:
|
||||
|
||||
| Name | Description | Supported formats | Authentification | Rate limiting | SFW filter support |
|
||||
| ---------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------ | ---------------------------------------------------------------------------- | ------------------------------ | ------------------ |
|
||||
| [Jikan](https://jikan.moe/) | Jikan is an API that uses [My Anime List](https://myanimelist.net) and offers metadata for anime. | series, movies, specials, OVAs, manga, manwha, novels | No | 60 per minute and 3 per second | Yes |
|
||||
| [OMDb](https://www.omdbapi.com/) | OMDb is an API that offers metadata for movie, series and games. | series, movies, games | Yes, you can get a free key here [here](https://www.omdbapi.com/apikey.aspx) | 1000 per day | No |
|
||||
| [MusicBrainz](https://musicbrainz.org/) | MusicBrainz is an API that offers information about music releases. | music releases | No | 50 per second | No |
|
||||
| [Wikipedia](https://en.wikipedia.org/wiki/Main_Page) | The Wikipedia API allows access to all Wikipedia articles. | wiki articles | No | None | No |
|
||||
| [Steam](https://store.steampowered.com/) | The Steam API offers information on all steam games. | games | No | 10000 per day | No |
|
||||
| [Open Library](https://openlibrary.org) | The OpenLibrary API offers metadata for books | books | No | Cover access is rate-limited when not using CoverID or OLID by max 100 requests/IP every 5 minutes. This plugin uses OLID so there shouldn't be a rate limit. | No |
|
||||
|
||||
| Name | Description | Supported formats | Authentification | Rate limiting | SFW filter support |
|
||||
| ---------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ----------------------------------------------------- | ---------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ |
|
||||
| [Jikan](https://jikan.moe/) | Jikan is an API that uses [My Anime List](https://myanimelist.net) and offers metadata for anime. | series, movies, specials, OVAs, manga, manwha, novels | No | 60 per minute and 3 per second | Yes |
|
||||
| [OMDb](https://www.omdbapi.com/) | OMDb is an API that offers metadata for movie, series and games. | series, movies, games | Yes, you can get a free key here [here](https://www.omdbapi.com/apikey.aspx) | 1000 per day | No |
|
||||
| [MusicBrainz](https://musicbrainz.org/) | MusicBrainz is an API that offers information about music releases. | music releases | No | 50 per second | No |
|
||||
| [Wikipedia](https://en.wikipedia.org/wiki/Main_Page) | The Wikipedia API allows access to all Wikipedia articles. | wiki articles | No | None | No |
|
||||
| [Steam](https://store.steampowered.com/) | The Steam API offers information on all steam games. | games | No | 10000 per day | No |
|
||||
| [Open Library](https://openlibrary.org) | The OpenLibrary API offers metadata for books | books | No | Cover access is rate-limited when not using CoverID or OLID by max 100 requests/IP every 5 minutes. This plugin uses OLID so there shouldn't be a rate limit. | No |
|
||||
|
||||
#### Notes
|
||||
|
||||
|
|
@ -154,7 +153,6 @@ Now you select the result you want and the plugin will cast it's magic and creat
|
|||
- e.g. for "Fantastic Mr. Fox" the URL looks like this `https://openlibrary.org/works/OL45804W` so the ID is `/works/OL45804W`
|
||||
- This URL is located near the top of the page above the title, see `An edition of Fantastic Mr Fox (1970) `
|
||||
|
||||
|
||||
### Problems, unexpected behavior or improvement suggestions?
|
||||
|
||||
You are more than welcome to open an issue on [GitHub](https://github.com/mProjectsCode/obsidian-media-db-plugin/issues).
|
||||
|
|
|
|||
|
|
@ -8,6 +8,12 @@ export class APIManager {
|
|||
this.apis = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Queries the basic info for one query string and multiple APIs.
|
||||
*
|
||||
* @param query
|
||||
* @param apisToQuery
|
||||
*/
|
||||
async query(query: string, apisToQuery: string[]): Promise<MediaTypeModel[]> {
|
||||
console.debug(`MDB | api manager queried with "${query}"`);
|
||||
|
||||
|
|
@ -23,10 +29,21 @@ export class APIManager {
|
|||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Queries detailed information for a MediaTypeModel.
|
||||
*
|
||||
* @param item
|
||||
*/
|
||||
async queryDetailedInfo(item: MediaTypeModel): Promise<MediaTypeModel> {
|
||||
return await this.queryDetailedInfoById(item.id, item.dataSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* Queries detailed info for an id from an API.
|
||||
*
|
||||
* @param id
|
||||
* @param apiName
|
||||
*/
|
||||
async queryDetailedInfoById(id: string, apiName: string): Promise<MediaTypeModel> {
|
||||
for (const api of this.apis) {
|
||||
if (api.apiName === apiName) {
|
||||
|
|
|
|||
|
|
@ -44,37 +44,37 @@ export class MALAPIManga extends APIModel {
|
|||
|
||||
for (const result of data.data) {
|
||||
const type = this.typeMappings.get(result.type?.toLowerCase());
|
||||
ret.push(
|
||||
new MangaModel({
|
||||
subType: type,
|
||||
title: result.title,
|
||||
synopsis: result.synopsis,
|
||||
englishTitle: result.title_english ?? result.title,
|
||||
alternateTitles: result.titles?.map((x: any) => x.title) ?? [],
|
||||
year: result.year ?? result.published?.prop?.from?.year ?? '',
|
||||
dataSource: this.apiName,
|
||||
url: result.url,
|
||||
id: result.mal_id,
|
||||
|
||||
genres: result.genres?.map((x: any) => x.name) ?? [],
|
||||
authors: result.authors?.map((x: any) => x.name) ?? [],
|
||||
chapters: result.chapters,
|
||||
volumes: result.volumes,
|
||||
onlineRating: result.score ?? 0,
|
||||
image: result.images?.jpg?.image_url ?? '',
|
||||
|
||||
released: true,
|
||||
publishedFrom: new Date(result.published?.from).toLocaleDateString() ?? 'unknown',
|
||||
publishedTo: new Date(result.published?.to).toLocaleDateString() ?? 'unknown',
|
||||
status: result.status,
|
||||
|
||||
userData: {
|
||||
watched: false,
|
||||
lastWatched: '',
|
||||
personalRating: 0,
|
||||
},
|
||||
} as MangaModel)
|
||||
)
|
||||
ret.push(
|
||||
new MangaModel({
|
||||
subType: type,
|
||||
title: result.title,
|
||||
synopsis: result.synopsis,
|
||||
englishTitle: result.title_english ?? result.title,
|
||||
alternateTitles: result.titles?.map((x: any) => x.title) ?? [],
|
||||
year: result.year ?? result.published?.prop?.from?.year ?? '',
|
||||
dataSource: this.apiName,
|
||||
url: result.url,
|
||||
id: result.mal_id,
|
||||
|
||||
genres: result.genres?.map((x: any) => x.name) ?? [],
|
||||
authors: result.authors?.map((x: any) => x.name) ?? [],
|
||||
chapters: result.chapters,
|
||||
volumes: result.volumes,
|
||||
onlineRating: result.score ?? 0,
|
||||
image: result.images?.jpg?.image_url ?? '',
|
||||
|
||||
released: true,
|
||||
publishedFrom: new Date(result.published?.from).toLocaleDateString() ?? 'unknown',
|
||||
publishedTo: new Date(result.published?.to).toLocaleDateString() ?? 'unknown',
|
||||
status: result.status,
|
||||
|
||||
userData: {
|
||||
watched: false,
|
||||
lastWatched: '',
|
||||
personalRating: 0,
|
||||
},
|
||||
} as MangaModel)
|
||||
);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ export class OpenLibraryAPI extends APIModel {
|
|||
this.apiDescription = 'A free API for books';
|
||||
this.apiUrl = 'https://openlibrary.org/';
|
||||
this.types = [MediaType.Book];
|
||||
}
|
||||
}
|
||||
|
||||
async searchByTitle(title: string): Promise<MediaTypeModel[]> {
|
||||
console.log(`MDB | api "${this.apiName}" queried by Title`);
|
||||
|
|
@ -34,15 +34,15 @@ export class OpenLibraryAPI extends APIModel {
|
|||
const ret: MediaTypeModel[] = [];
|
||||
|
||||
for (const result of data.docs) {
|
||||
ret.push(
|
||||
new BookModel({
|
||||
title: result.title,
|
||||
englishTitle: result.title_english ?? result.title,
|
||||
year: result.first_publish_year,
|
||||
dataSource: this.apiName,
|
||||
id: result.key,
|
||||
} as BookModel)
|
||||
);
|
||||
ret.push(
|
||||
new BookModel({
|
||||
title: result.title,
|
||||
englishTitle: result.title_english ?? result.title,
|
||||
year: result.first_publish_year,
|
||||
dataSource: this.apiName,
|
||||
id: result.key,
|
||||
} as BookModel)
|
||||
);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
@ -87,4 +87,4 @@ export class OpenLibraryAPI extends APIModel {
|
|||
|
||||
return model;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,8 @@ export class MediaDbPreviewModal extends Modal {
|
|||
fileContent = `\n${fileContent}\n`;
|
||||
|
||||
try {
|
||||
await MarkdownRenderer.renderMarkdown(fileContent, fileDiv, '', this.markdownComponent);
|
||||
// TODO: fix this not rendering the frontmatter any more
|
||||
await MarkdownRenderer.render(this.app, fileContent, fileDiv, '', this.markdownComponent);
|
||||
} catch (e) {
|
||||
console.warn(`mdb | error during rendering of preview`, e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,16 @@ import { MusicReleaseModel } from '../models/MusicReleaseModel';
|
|||
import { BoardGameModel } from '../models/BoardGameModel';
|
||||
import { BookModel } from '../models/BookModel';
|
||||
|
||||
export const MEDIA_TYPES: MediaType[] = [MediaType.Movie, MediaType.Series, MediaType.Manga, MediaType.Game, MediaType.Wiki, MediaType.MusicRelease, MediaType.BoardGame, MediaType.Book];
|
||||
export const MEDIA_TYPES: MediaType[] = [
|
||||
MediaType.Movie,
|
||||
MediaType.Series,
|
||||
MediaType.Manga,
|
||||
MediaType.Game,
|
||||
MediaType.Wiki,
|
||||
MediaType.MusicRelease,
|
||||
MediaType.BoardGame,
|
||||
MediaType.Book,
|
||||
];
|
||||
|
||||
export class MediaTypeManager {
|
||||
mediaFileNameTemplateMap: Map<MediaType, string>;
|
||||
|
|
|
|||
|
|
@ -440,7 +440,7 @@ export class ModalHelper {
|
|||
* then executes the `submitCallback` returning the callbacks result and closing the modal.
|
||||
*
|
||||
* @param selectModalOptions the options for the modal, see {@link SELECT_MODAL_OPTIONS_DEFAULT}
|
||||
* @param submitCallback the callback that gets executed after the modal has been submitted, but after it has been closed
|
||||
* @param submitCallback the callback that gets executed after the modal has been submitted, but before it has been closed
|
||||
* @returns the user input or nothing and a reference to the modal.
|
||||
*/
|
||||
async openSelectModal(selectModalOptions: SelectModalOptions, submitCallback: (selectModalData: SelectModalData) => Promise<MediaTypeModel[]>): Promise<MediaTypeModel[]> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue