Skip to content

Commit bb663cd

Browse files
Merge pull request #190 from ltctceplrm/openlibrary
Openlibrary improvements
2 parents 9518ede + 74acf7f commit bb663cd

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
## Obsidian Media DB Plugin
22

3-
A plugin that can query multiple APIs for movies, series, anime, manga, books, games, music and wiki articles, and import them into your vault.
3+
A plugin that can query multiple APIs for movies, series, anime, manga, books, comics, games, music and wiki articles, and import them into your vault.
44

55
### Features
66

77
#### Search by Title
88

9-
Search a movie, series, anime, game, music release or wiki article by its name across multiple APIs.
9+
Search a movie, series, anime, manga, book, comic, game, music release or wiki articles by its name across multiple APIs.
1010

1111
#### Search by ID
1212

@@ -162,9 +162,11 @@ Now you select the result you want and the plugin will cast it's magic and creat
162162
- you can find this ID in the URL
163163
- e.g. for "Factorio" the URL looks like this `https://store.steampowered.com/app/427520/Factorio/` so the ID is `427520`
164164
- [Open Library](https://openlibrary.org)
165-
- The ID you need is the "work" ID and not the "book" ID, it needs to start with `/works/`. You can find this ID in the URL
166-
- e.g. for "Fantastic Mr. Fox" the URL looks like this `https://openlibrary.org/works/OL45804W` so the ID is `/works/OL45804W`
167-
- This URL is located near the top of the page above the title, see `An edition of Fantastic Mr Fox (1970) `
165+
- The ID can either be the "/work/" ID, the "/book/" ID, or the "/isbn/" ID it needs to start with `/works/`. You can find this ID in the URL
166+
- e.g. for "Fantastic Mr. Fox" the "/works/" URL looks like this `https://openlibrary.org/works/OL45804W` so the ID is `/works/OL45804W`
167+
- This URL is located near the top of the page above the title, see `An edition of Fantastic Mr Fox (1970) `
168+
- For a specific edition of "Fantastic Mr. Fox" the "/books/" URL looks like this `https://openlibrary.org/books/OL3567303M/` so the ID is `/books/OL3567303M`
169+
- This URL is located in the editions section`
168170
- [Moby Games](https://www.mobygames.com)
169171
- you can find this ID in the URL
170172
- e.g. for "Bioshock 2" the URL looks like this `https://www.mobygames.com/game/45089/bioshock-2/` so the ID is `45089`

src/api/apis/MusicBrainzAPI.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class MusicBrainzAPI extends APIModel {
5151
dataSource: this.apiName,
5252
url: 'https://musicbrainz.org/release-group/' + result.id,
5353
id: result.id,
54-
image: 'https://coverartarchive.org/release-group/' + result.id + '/front',
54+
image: 'https://coverartarchive.org/release-group/' + result.id + '/front.jpg',
5555

5656
artists: result['artist-credit'].map((a: any) => a.name),
5757
subType: result['primary-type'],
@@ -87,7 +87,7 @@ export class MusicBrainzAPI extends APIModel {
8787
dataSource: this.apiName,
8888
url: 'https://musicbrainz.org/release-group/' + result.id,
8989
id: result.id,
90-
image: 'https://coverartarchive.org/release-group/' + result.id + '/front',
90+
image: 'https://coverartarchive.org/release-group/' + result.id + '/front.jpg',
9191

9292
artists: result['artist-credit'].map((a: any) => a.name),
9393
genres: result.genres.map((g: any) => g.name),

src/api/apis/OpenLibraryAPI.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class OpenLibraryAPI extends APIModel {
5252
async getById(id: string): Promise<MediaTypeModel> {
5353
console.log(`MDB | api "${this.apiName}" queried by ID`);
5454

55-
const searchUrl = `https://openlibrary.org/search.json?q=key:${encodeURIComponent(id)}`;
55+
const searchUrl = `https://openlibrary.org/search.json?q=${encodeURIComponent(id)}&fields=key,title,author_name,number_of_pages_median,first_publish_year,isbn,ratings_score,first_sentence,title_suggest,rating*,cover_edition_key`;
5656
const fetchData = await fetch(searchUrl);
5757
// console.debug(fetchData);
5858

@@ -68,8 +68,8 @@ export class OpenLibraryAPI extends APIModel {
6868
title: result.title,
6969
year: result.first_publish_year,
7070
dataSource: this.apiName,
71-
url: `https://openlibrary.org` + result.key,
72-
id: result.key,
71+
url: `https://openlibrary.org` + data.q,
72+
id: data.q,
7373
isbn: (result.isbn ?? []).find((el: string | any[]) => el.length <= 10) ?? 'unknown',
7474
isbn13: (result.isbn ?? []).find((el: string | any[]) => el.length == 13) ?? 'unknown',
7575
englishTitle: result.title_english ?? result.title,

0 commit comments

Comments
 (0)