update 5 files

This commit is contained in:
2025-01-21 00:39:42 +03:00
parent 81cffd5d61
commit 88768a5e4b
5 changed files with 38 additions and 53 deletions

View File

@@ -12,27 +12,32 @@ class AmazonBookSearch {
const fetchBookId = async (isbn) => {
const headers = config.headers;
try {
const url = encodeURI(this.url + isbn);
const response = await axios.get(url, { headers });
if (!response.data) {
throw new Error("Kitap bilgisi bulunamadı!");
}
const bookId = modules.extractBookId(response.data);
return bookId;
} catch (error) {
throw new Error("Hata: " + error.message);
throw new Error(error.message);
}
};
this.getBookDetails = async (isbn, geminiApiKey) => {
const headers = config.headers;
try {
const bookId = await fetchBookId(isbn);
const url = encodeURI(location == "tr" ? config.tr_detail_url + bookId : config.en_detail_url + bookId);
const url = encodeURI(
location == "tr"
? config.tr_detail_url + bookId
: config.en_detail_url + bookId
);
return new Promise((resolve, reject) => {
setTimeout(async () => {
try {
@@ -54,7 +59,7 @@ class AmazonBookSearch {
}, config.fetchTimeout);
});
} catch (error) {
throw new Error("Hata: " + error.message);
throw new Error(error.message);
}
};
}
@@ -73,13 +78,13 @@ module.exports = AmazonBookSearch;
// }
// })();
// //
// (async () => {
// try {
// const BookSearch = new AmazonBookSearch("en");
// const bookDetails = await BookSearch.getBookDetails("0593724283");
// console.log(bookDetails);
// } catch (error) {
// console.log(error.message);
// }
// })();
// //
(async () => {
try {
const BookSearch = new AmazonBookSearch("en");
const bookDetails = await BookSearch.getBookDetails("0593724283");
console.log(bookDetails);
} catch (error) {
console.log(error.message);
}
})();

View File

@@ -9,9 +9,7 @@ const geminiDescriptionEdit = async (description, geminiApiKey, location) => {
if (location == "en") {
prompt =
description +
" based on the text above, provide a detailed book description of similar length. Do not add any comments to the text, remain completely faithful to it. Only provide the book description, without using a title like book description.";
console.log(prompt);
" based on the text above, provide a detailed book description of similar length. Do not add any comments to the text, remain completely faithful to it. Only provide the book description, without using a title like book description.";
} else {
prompt =
description +