Skip to content

Commit 1d76bb8

Browse files
committed
maintenance
1 parent 846f7de commit 1d76bb8

File tree

7 files changed

+80
-55
lines changed

7 files changed

+80
-55
lines changed

README.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,14 @@ Now you select the result you want and the plugin will cast it's magic and creat
111111
112112
### Currently supported APIs:
113113
114-
| Name | Description | Supported formats | Authentification | Rate limiting | SFW filter support |
115-
| ---------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------ | ---------------------------------------------------------------------------- | ------------------------------ | ------------------ |
116-
| [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 |
117-
| [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 |
118-
| [MusicBrainz](https://musicbrainz.org/) | MusicBrainz is an API that offers information about music releases. | music releases | No | 50 per second | No |
119-
| [Wikipedia](https://en.wikipedia.org/wiki/Main_Page) | The Wikipedia API allows access to all Wikipedia articles. | wiki articles | No | None | No |
120-
| [Steam](https://store.steampowered.com/) | The Steam API offers information on all steam games. | games | No | 10000 per day | No |
121-
| [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 |
122-
114+
| Name | Description | Supported formats | Authentification | Rate limiting | SFW filter support |
115+
| ---------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ----------------------------------------------------- | ---------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ |
116+
| [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 |
117+
| [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 |
118+
| [MusicBrainz](https://musicbrainz.org/) | MusicBrainz is an API that offers information about music releases. | music releases | No | 50 per second | No |
119+
| [Wikipedia](https://en.wikipedia.org/wiki/Main_Page) | The Wikipedia API allows access to all Wikipedia articles. | wiki articles | No | None | No |
120+
| [Steam](https://store.steampowered.com/) | The Steam API offers information on all steam games. | games | No | 10000 per day | No |
121+
| [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 |
123122
124123
#### Notes
125124
@@ -154,7 +153,6 @@ Now you select the result you want and the plugin will cast it's magic and creat
154153
- e.g. for "Fantastic Mr. Fox" the URL looks like this `https://openlibrary.org/works/OL45804W` so the ID is `/works/OL45804W`
155154
- This URL is located near the top of the page above the title, see `An edition of Fantastic Mr Fox (1970) `
156155
157-
158156
### Problems, unexpected behavior or improvement suggestions?
159157
160158
You are more than welcome to open an issue on [GitHub](https://github.com/mProjectsCode/obsidian-media-db-plugin/issues).

src/api/APIManager.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ export class APIManager {
88
this.apis = [];
99
}
1010

11+
/**
12+
* Queries the basic info for one query string and multiple APIs.
13+
*
14+
* @param query
15+
* @param apisToQuery
16+
*/
1117
async query(query: string, apisToQuery: string[]): Promise<MediaTypeModel[]> {
1218
console.debug(`MDB | api manager queried with "${query}"`);
1319

@@ -23,10 +29,21 @@ export class APIManager {
2329
return res;
2430
}
2531

32+
/**
33+
* Queries detailed information for a MediaTypeModel.
34+
*
35+
* @param item
36+
*/
2637
async queryDetailedInfo(item: MediaTypeModel): Promise<MediaTypeModel> {
2738
return await this.queryDetailedInfoById(item.id, item.dataSource);
2839
}
2940

41+
/**
42+
* Queries detailed info for an id from an API.
43+
*
44+
* @param id
45+
* @param apiName
46+
*/
3047
async queryDetailedInfoById(id: string, apiName: string): Promise<MediaTypeModel> {
3148
for (const api of this.apis) {
3249
if (api.apiName === apiName) {

src/api/apis/MALAPIManga.ts

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -44,37 +44,37 @@ export class MALAPIManga extends APIModel {
4444

4545
for (const result of data.data) {
4646
const type = this.typeMappings.get(result.type?.toLowerCase());
47-
ret.push(
48-
new MangaModel({
49-
subType: type,
50-
title: result.title,
51-
synopsis: result.synopsis,
52-
englishTitle: result.title_english ?? result.title,
53-
alternateTitles: result.titles?.map((x: any) => x.title) ?? [],
54-
year: result.year ?? result.published?.prop?.from?.year ?? '',
55-
dataSource: this.apiName,
56-
url: result.url,
57-
id: result.mal_id,
58-
59-
genres: result.genres?.map((x: any) => x.name) ?? [],
60-
authors: result.authors?.map((x: any) => x.name) ?? [],
61-
chapters: result.chapters,
62-
volumes: result.volumes,
63-
onlineRating: result.score ?? 0,
64-
image: result.images?.jpg?.image_url ?? '',
65-
66-
released: true,
67-
publishedFrom: new Date(result.published?.from).toLocaleDateString() ?? 'unknown',
68-
publishedTo: new Date(result.published?.to).toLocaleDateString() ?? 'unknown',
69-
status: result.status,
70-
71-
userData: {
72-
watched: false,
73-
lastWatched: '',
74-
personalRating: 0,
75-
},
76-
} as MangaModel)
77-
)
47+
ret.push(
48+
new MangaModel({
49+
subType: type,
50+
title: result.title,
51+
synopsis: result.synopsis,
52+
englishTitle: result.title_english ?? result.title,
53+
alternateTitles: result.titles?.map((x: any) => x.title) ?? [],
54+
year: result.year ?? result.published?.prop?.from?.year ?? '',
55+
dataSource: this.apiName,
56+
url: result.url,
57+
id: result.mal_id,
58+
59+
genres: result.genres?.map((x: any) => x.name) ?? [],
60+
authors: result.authors?.map((x: any) => x.name) ?? [],
61+
chapters: result.chapters,
62+
volumes: result.volumes,
63+
onlineRating: result.score ?? 0,
64+
image: result.images?.jpg?.image_url ?? '',
65+
66+
released: true,
67+
publishedFrom: new Date(result.published?.from).toLocaleDateString() ?? 'unknown',
68+
publishedTo: new Date(result.published?.to).toLocaleDateString() ?? 'unknown',
69+
status: result.status,
70+
71+
userData: {
72+
watched: false,
73+
lastWatched: '',
74+
personalRating: 0,
75+
},
76+
} as MangaModel)
77+
);
7878
}
7979

8080
return ret;

src/api/apis/OpenLibraryAPI.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class OpenLibraryAPI extends APIModel {
1515
this.apiDescription = 'A free API for books';
1616
this.apiUrl = 'https://openlibrary.org/';
1717
this.types = [MediaType.Book];
18-
}
18+
}
1919

2020
async searchByTitle(title: string): Promise<MediaTypeModel[]> {
2121
console.log(`MDB | api "${this.apiName}" queried by Title`);
@@ -34,15 +34,15 @@ export class OpenLibraryAPI extends APIModel {
3434
const ret: MediaTypeModel[] = [];
3535

3636
for (const result of data.docs) {
37-
ret.push(
38-
new BookModel({
39-
title: result.title,
40-
englishTitle: result.title_english ?? result.title,
41-
year: result.first_publish_year,
42-
dataSource: this.apiName,
43-
id: result.key,
44-
} as BookModel)
45-
);
37+
ret.push(
38+
new BookModel({
39+
title: result.title,
40+
englishTitle: result.title_english ?? result.title,
41+
year: result.first_publish_year,
42+
dataSource: this.apiName,
43+
id: result.key,
44+
} as BookModel)
45+
);
4646
}
4747

4848
return ret;
@@ -87,4 +87,4 @@ export class OpenLibraryAPI extends APIModel {
8787

8888
return model;
8989
}
90-
}
90+
}

src/modals/MediaDbPreviewModal.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ export class MediaDbPreviewModal extends Modal {
5757
fileContent = `\n${fileContent}\n`;
5858

5959
try {
60-
await MarkdownRenderer.renderMarkdown(fileContent, fileDiv, '', this.markdownComponent);
60+
// TODO: fix this not rendering the frontmatter any more
61+
await MarkdownRenderer.render(this.app, fileContent, fileDiv, '', this.markdownComponent);
6162
} catch (e) {
6263
console.warn(`mdb | error during rendering of preview`, e);
6364
}

src/utils/MediaTypeManager.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,16 @@ import { MusicReleaseModel } from '../models/MusicReleaseModel';
1212
import { BoardGameModel } from '../models/BoardGameModel';
1313
import { BookModel } from '../models/BookModel';
1414

15-
export const MEDIA_TYPES: MediaType[] = [MediaType.Movie, MediaType.Series, MediaType.Manga, MediaType.Game, MediaType.Wiki, MediaType.MusicRelease, MediaType.BoardGame, MediaType.Book];
15+
export const MEDIA_TYPES: MediaType[] = [
16+
MediaType.Movie,
17+
MediaType.Series,
18+
MediaType.Manga,
19+
MediaType.Game,
20+
MediaType.Wiki,
21+
MediaType.MusicRelease,
22+
MediaType.BoardGame,
23+
MediaType.Book,
24+
];
1625

1726
export class MediaTypeManager {
1827
mediaFileNameTemplateMap: Map<MediaType, string>;

src/utils/ModalHelper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ export class ModalHelper {
440440
* then executes the `submitCallback` returning the callbacks result and closing the modal.
441441
*
442442
* @param selectModalOptions the options for the modal, see {@link SELECT_MODAL_OPTIONS_DEFAULT}
443-
* @param submitCallback the callback that gets executed after the modal has been submitted, but after it has been closed
443+
* @param submitCallback the callback that gets executed after the modal has been submitted, but before it has been closed
444444
* @returns the user input or nothing and a reference to the modal.
445445
*/
446446
async openSelectModal(selectModalOptions: SelectModalOptions, submitCallback: (selectModalData: SelectModalData) => Promise<MediaTypeModel[]>): Promise<MediaTypeModel[]> {

0 commit comments

Comments
 (0)