Skip to content

Commit 4968c49

Browse files
committed
Added online rating
1 parent 03d1c1d commit 4968c49

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/api/apis/OpenLibraryAPI.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import { APIModel } from '../APIModel';
22
import { MediaTypeModel } from '../../models/MediaTypeModel';
33
import MediaDbPlugin from '../../main';
44
import { BookModel } from 'src/models/BookModel';
5-
import { requestUrl } from 'obsidian';
6-
import { contactEmail, mediaDbVersion, pluginName } from '../../utils/Utils';
75
import { MediaType } from '../../utils/MediaType';
86

97
export class OpenLibraryAPI extends APIModel {
@@ -75,6 +73,7 @@ export class OpenLibraryAPI extends APIModel {
7573

7674
author: result.author_name ?? 'unknown',
7775
pages: result.number_of_pages_median ?? 'unknown',
76+
onlineRating: Number.parseFloat(result.ratings_average.toFixed(2)) ?? 0,
7877
image: `https://covers.openlibrary.org/b/OLID/` + result.cover_edition_key + `-L.jpg` ?? '',
7978

8079
released: true,

src/models/BookModel.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import { MediaType } from '../utils/MediaType';
44

55
export class BookModel extends MediaTypeModel {
66
author: string;
7-
pages: string;
7+
pages: number;
88
image: string;
9+
onlineRating: number;
910
english_title: string;
1011

1112
released: boolean;
@@ -22,6 +23,7 @@ export class BookModel extends MediaTypeModel {
2223
this.author = undefined;
2324
this.pages = undefined;
2425
this.image = undefined;
26+
this.onlineRating = undefined;
2527

2628
this.released = undefined;
2729

0 commit comments

Comments
 (0)