File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -19,9 +19,13 @@ export class OpenLibraryAPI extends APIModel {
1919
2020 async searchByTitle ( title : string ) : Promise < MediaTypeModel [ ] > {
2121 console . log ( `MDB | api "${ this . apiName } " queried by Title` ) ;
22-
23- const searchUrl = `https://openlibrary.org/search.json?title=${ encodeURIComponent ( title ) } ` ;
24-
22+ const titlesplit = title . split ( "++" )
23+ if ( titlesplit . length !== 1 ) {
24+ var searchUrl = `https://openlibrary.org/search.json?title=${ encodeURIComponent ( titlesplit [ 0 ] ) } &author=${ encodeURIComponent ( titlesplit [ 1 ] ) } ` ;
25+ }
26+ else {
27+ var searchUrl = `https://openlibrary.org/search.json?title=${ encodeURIComponent ( title ) } ` ;
28+ }
2529 const fetchData = await fetch ( searchUrl ) ;
2630 console . debug ( fetchData ) ;
2731 if ( fetchData . status !== 200 ) {
@@ -41,6 +45,7 @@ export class OpenLibraryAPI extends APIModel {
4145 year : result . first_publish_year ,
4246 dataSource : this . apiName ,
4347 id : result . key ,
48+ author : result . author_name ?? 'unknown' ,
4449 } as BookModel ) ,
4550 ) ;
4651 }
Original file line number Diff line number Diff line change @@ -56,6 +56,6 @@ export class BookModel extends MediaTypeModel {
5656 }
5757
5858 getSummary ( ) : string {
59- return this . englishTitle + ' (' + this . year + ')' ;
59+ return this . englishTitle + ' (' + this . year + ') - ' + this . author ;
6060 }
6161}
You can’t perform that action at this time.
0 commit comments