maintenance

This commit is contained in:
mProjectsCode 2023-09-28 11:50:39 +02:00
parent 846f7de184
commit 1d76bb8981
7 changed files with 80 additions and 55 deletions

View file

@ -112,7 +112,7 @@ 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 |
@ -120,7 +120,6 @@ Now you select the result you want and the plugin will cast it's magic and creat
| [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
- [Jikan](https://jikan.moe/)
@ -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).

View file

@ -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) {

View file

@ -74,7 +74,7 @@ export class MALAPIManga extends APIModel {
personalRating: 0,
},
} as MangaModel)
)
);
}
return ret;

View file

@ -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`);

View file

@ -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);
}

View file

@ -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>;

View file

@ -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[]> {