From a0535aa3dbf85e562ff3c7becc4f6eeb3e23c337 Mon Sep 17 00:00:00 2001 From: Wanoo Date: Fri, 28 Feb 2020 16:04:07 +0100 Subject: [PATCH 01/11] Add ComicVine Api Fetching Metadata for comicBook with ComicVine API --- cps/static/js/get_meta.js | 77 +++++++++++++++++++++++++++++++++++- cps/templates/book_edit.html | 3 ++ 2 files changed, 79 insertions(+), 1 deletion(-) diff --git a/cps/static/js/get_meta.js b/cps/static/js/get_meta.js index 14317da4..e10b83ed 100644 --- a/cps/static/js/get_meta.js +++ b/cps/static/js/get_meta.js @@ -15,13 +15,15 @@ * along with this program. If not, see . */ /* - * Get Metadata from Douban Books api and Google Books api + * Get Metadata from Douban Books api and Google Books api and ComicVine * Google Books api document: https://developers.google.com/books/docs/v1/using * Douban Books api document: https://developers.douban.com/wiki/?title=book_v2 (Chinese Only) + * ComicVine api document: https://comicvine.gamespot.com/api/documentation */ /* global _, i18nMsg, tinymce */ var dbResults = []; var ggResults = []; +var cvResults = []; $(function () { var msg = i18nMsg; @@ -33,6 +35,10 @@ $(function () { var ggSearch = "/books/v1/volumes"; var ggDone = false; + var comicvine = "https://comicvine.gamespot.com"; + var cvSearch = "/api/search/"; + var cvDone = false; + var showFlag = 0; var templates = { @@ -164,6 +170,52 @@ $(function () { }); dbDone = false; } + if (cvDone && cvResults.length > 0) { + cvResults.forEach(function(result) { + var seriesTitle = ""; + if (result.volume.name) { + seriesTitle = result.volume.name; + } + var dateFomers = ""; + if (result.store_date) { + dateFomers = result.store_date.split("-"); + }else{ + dateFomers = result.date_added.split("-"); + } + var publishedYear = parseInt(dateFomers[0]); + var publishedMonth = parseInt(dateFomers[1]); + var publishedDate = new Date(publishedYear, publishedMonth - 1, 1); + + publishedDate = formatDate(publishedDate); + + var book = { + id: result.id, + title: seriesTitle + ' #' +('00' + result.issue_number).slice(-3) + ' - ' + result.name, + authors: result.author || [], + description: result.description, + publisher: "", + publishedDate: publishedDate || "", + tags: ['Comics', seriesTitle], + rating: 0, + series: seriesTitle || "", + cover: result.image.original_url, + url: result.site_detail_url, + source: { + id: "comicvine", + description: "ComicVine Books", + url: "https://comicvine.gamespot.com/" + } + }; + + var $book = $(templates.bookResult(book)); + $book.find("img").on("click", function () { + populateForm(book); + }); + + $("#book-list").append($book); + }); + cvDone = false; + } } function ggSearchBook (title) { @@ -207,12 +259,35 @@ $(function () { }); } + function cvSearchBook (title) { + var apikey = "57558043c53943d5d1e96a9ad425b0eb85532ee6"; + title = encodeURIComponent(title); + $.ajax({ + url: comicvine + cvSearch + "?api_key=" + apikey + "&resources=issue&query=" + title + "&sort=name:desc&format=jsonp", + type: "GET", + dataType: "jsonp", + jsonp: "json_callback", + success: function success(data) { + cvResults = data.results; + }, + error: function error() { + $("#meta-info").html("

" + msg.search_error + "!

" + $("#meta-info")[0].innerHTML); + }, + complete: function complete() { + cvDone = true; + showResult(); + $("#show-comics").trigger("change"); + } + }); + } + function doSearch (keyword) { showFlag = 0; $("#meta-info").text(msg.loading); if (keyword) { dbSearchBook(keyword); ggSearchBook(keyword); + cvSearchBook(keyword); } } diff --git a/cps/templates/book_edit.html b/cps/templates/book_edit.html index d3619060..547d59f5 100644 --- a/cps/templates/book_edit.html +++ b/cps/templates/book_edit.html @@ -222,6 +222,9 @@ + + +
From 5ba4801a79286ae23cd8fe7114351951faa876f6 Mon Sep 17 00:00:00 2001 From: OzzieIsaacs Date: Sun, 8 Mar 2020 08:02:15 +0100 Subject: [PATCH 02/11] Updated test result --- test/Calibre-Web TestSummary.html | 1635 ++++++++++------------------- 1 file changed, 559 insertions(+), 1076 deletions(-) diff --git a/test/Calibre-Web TestSummary.html b/test/Calibre-Web TestSummary.html index 9f4117c4..e06b7639 100644 --- a/test/Calibre-Web TestSummary.html +++ b/test/Calibre-Web TestSummary.html @@ -36,17 +36,17 @@
-

Start Time: 2020-02-16 16:10:19

+

Start Time: 2020-03-08 06:43:07

-

Stop Time: 2020-02-16 16:50:18

+

Stop Time: 2020-03-08 07:47:49

-

Duration: 2160.47 s

+

Duration: 3600.91 s

@@ -414,13 +414,13 @@ test_edit_books.test_edit_books - 23 - 12 + 30 + 18 0 - 0 - 11 + 9 + 3 - Detail + Detail @@ -428,7 +428,7 @@ -
test_database_errors
+
test_delete_book
@@ -452,59 +452,16 @@ - - -
test_delete_book
- - -
- SKIP -
- - - - - - - - - + -
test_delete_format
- - -
- SKIP -
- - - +
test_download_book
+ PASS - +
test_edit_author
@@ -513,7 +470,7 @@ - +
test_edit_category
@@ -522,7 +479,7 @@ - +
test_edit_comments
@@ -531,7 +488,7 @@ - +
test_edit_custom_bool
@@ -540,7 +497,7 @@ - +
test_edit_custom_rating
@@ -549,7 +506,7 @@ - +
test_edit_custom_single_select
@@ -558,7 +515,7 @@ - +
test_edit_custom_text
@@ -567,7 +524,7 @@ - +
test_edit_language
@@ -576,7 +533,7 @@ - +
test_edit_publisher
@@ -585,19 +542,19 @@ - +
test_edit_publishing_date
- SKIP + SKIP
-