Improved openlibrary API + updated readme
Fixed missing ratings, page numbers and also added an option to add specific editions using search by ID, this method also enables you to search by isbn ID.
This commit is contained in:
parent
9518ede41c
commit
8a392e5e4e
2 changed files with 7 additions and 5 deletions
|
|
@ -162,9 +162,11 @@ Now you select the result you want and the plugin will cast it's magic and creat
|
|||
- you can find this ID in the URL
|
||||
- e.g. for "Factorio" the URL looks like this `https://store.steampowered.com/app/427520/Factorio/` so the ID is `427520`
|
||||
- [Open Library](https://openlibrary.org)
|
||||
- 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
|
||||
- e.g. for "Fantastic Mr. Fox" the URL looks like this `https://openlibrary.org/works/OL45804W` so the ID is `/works/OL45804W`
|
||||
- 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
|
||||
- e.g. for "Fantastic Mr. Fox" the "/works/" 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) `
|
||||
- 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`
|
||||
- This URL is located in the editions section`
|
||||
- [Moby Games](https://www.mobygames.com)
|
||||
- you can find this ID in the URL
|
||||
- e.g. for "Bioshock 2" the URL looks like this `https://www.mobygames.com/game/45089/bioshock-2/` so the ID is `45089`
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ export class OpenLibraryAPI extends APIModel {
|
|||
async getById(id: string): Promise<MediaTypeModel> {
|
||||
console.log(`MDB | api "${this.apiName}" queried by ID`);
|
||||
|
||||
const searchUrl = `https://openlibrary.org/search.json?q=key:${encodeURIComponent(id)}`;
|
||||
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`;
|
||||
const fetchData = await fetch(searchUrl);
|
||||
// console.debug(fetchData);
|
||||
|
||||
|
|
@ -68,8 +68,8 @@ export class OpenLibraryAPI extends APIModel {
|
|||
title: result.title,
|
||||
year: result.first_publish_year,
|
||||
dataSource: this.apiName,
|
||||
url: `https://openlibrary.org` + result.key,
|
||||
id: result.key,
|
||||
url: `https://openlibrary.org` + data.q,
|
||||
id: data.q,
|
||||
isbn: (result.isbn ?? []).find((el: string | any[]) => el.length <= 10) ?? 'unknown',
|
||||
isbn13: (result.isbn ?? []).find((el: string | any[]) => el.length == 13) ?? 'unknown',
|
||||
englishTitle: result.title_english ?? result.title,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue