Add subjects as genres to OpenLibraryAPI
This commit is contained in:
parent
84214a1c3c
commit
732fc74d19
2 changed files with 5 additions and 1 deletions
|
|
@ -24,6 +24,7 @@ interface SearchResponse {
|
|||
first_publish_year?: number;
|
||||
key: string;
|
||||
description?: string;
|
||||
subject?: string[];
|
||||
|
||||
number_of_pages_median?: number;
|
||||
isbn?: string[];
|
||||
|
|
@ -94,7 +95,7 @@ export class OpenLibraryAPI extends APIModel {
|
|||
params: {
|
||||
query: {
|
||||
q: `${id}`,
|
||||
fields: 'key,title,author_name,number_of_pages_median,first_publish_year,isbn,ratings_score,first_sentence,title_suggest,rating*,cover*,editions,description',
|
||||
fields: 'key,title,author_name,number_of_pages_median,first_publish_year,isbn,ratings_score,first_sentence,title_suggest,rating*,cover*,editions,description,subject*',
|
||||
},
|
||||
},
|
||||
fetch: obsidianFetch,
|
||||
|
|
@ -142,6 +143,7 @@ export class OpenLibraryAPI extends APIModel {
|
|||
|
||||
author: result.author_name?.join(', '),
|
||||
plot: result.description ?? undefined,
|
||||
genres: result.subject ?? undefined,
|
||||
pages: Number.isNaN(pages) ? undefined : pages,
|
||||
onlineRating: result.ratings_average,
|
||||
image: cover_i ? `https://covers.openlibrary.org/b/id/` + cover_i + `-L.jpg` : undefined,
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ export type BookData = ModelToData<BookModel>;
|
|||
export class BookModel extends MediaTypeModel {
|
||||
author: string;
|
||||
plot: string;
|
||||
genres: string[];
|
||||
pages: number;
|
||||
image: string;
|
||||
onlineRating: number;
|
||||
|
|
@ -27,6 +28,7 @@ export class BookModel extends MediaTypeModel {
|
|||
|
||||
this.author = '';
|
||||
this.plot = '';
|
||||
this.genres= [];
|
||||
this.pages = 0;
|
||||
this.image = '';
|
||||
this.onlineRating = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue