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;
|
first_publish_year?: number;
|
||||||
key: string;
|
key: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
|
subject?: string[];
|
||||||
|
|
||||||
number_of_pages_median?: number;
|
number_of_pages_median?: number;
|
||||||
isbn?: string[];
|
isbn?: string[];
|
||||||
|
|
@ -94,7 +95,7 @@ export class OpenLibraryAPI extends APIModel {
|
||||||
params: {
|
params: {
|
||||||
query: {
|
query: {
|
||||||
q: `${id}`,
|
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,
|
fetch: obsidianFetch,
|
||||||
|
|
@ -142,6 +143,7 @@ export class OpenLibraryAPI extends APIModel {
|
||||||
|
|
||||||
author: result.author_name?.join(', '),
|
author: result.author_name?.join(', '),
|
||||||
plot: result.description ?? undefined,
|
plot: result.description ?? undefined,
|
||||||
|
genres: result.subject ?? undefined,
|
||||||
pages: Number.isNaN(pages) ? undefined : pages,
|
pages: Number.isNaN(pages) ? undefined : pages,
|
||||||
onlineRating: result.ratings_average,
|
onlineRating: result.ratings_average,
|
||||||
image: cover_i ? `https://covers.openlibrary.org/b/id/` + cover_i + `-L.jpg` : undefined,
|
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 {
|
export class BookModel extends MediaTypeModel {
|
||||||
author: string;
|
author: string;
|
||||||
plot: string;
|
plot: string;
|
||||||
|
genres: string[];
|
||||||
pages: number;
|
pages: number;
|
||||||
image: string;
|
image: string;
|
||||||
onlineRating: number;
|
onlineRating: number;
|
||||||
|
|
@ -27,6 +28,7 @@ export class BookModel extends MediaTypeModel {
|
||||||
|
|
||||||
this.author = '';
|
this.author = '';
|
||||||
this.plot = '';
|
this.plot = '';
|
||||||
|
this.genres= [];
|
||||||
this.pages = 0;
|
this.pages = 0;
|
||||||
this.image = '';
|
this.image = '';
|
||||||
this.onlineRating = 0;
|
this.onlineRating = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue