Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase image cover size in URL to 1024px #246

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/scraper/scrapeBooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ export const parseAuthor = (scrapedAuthor: string): string => {
return scrapedAuthor.replace(/.*: /, '')?.trim();
};

export const parseImageUrl = (scrapedImageUrl: string): string => {
return scrapedImageUrl.replace(/\._SY\d+\./, '._SX1024.')?.trim();
};


export const parseBooks = ($: Root): Book[] => {
const booksEl = $('.kp-notebook-library-each-book').toArray();

Expand All @@ -41,14 +46,15 @@ export const parseBooks = ($: Root): Book[] => {

const scrapedLastAnnotatedDate = $('[id^="kp-notebook-annotated-date"]', bookEl).val();
const scrapedAuthor = $('p.kp-notebook-searchable', bookEl).text();
const scrapedImageUrl = $('.kp-notebook-cover-image', bookEl).attr('src');

return {
id: hash(title),
asin: $(bookEl).attr('id'),
title,
author: parseAuthor(scrapedAuthor),
url: `https://www.amazon.com/dp/${$(bookEl).attr('id')}`,
imageUrl: $('.kp-notebook-cover-image', bookEl).attr('src'),
imageUrl: parseImageUrl(scrapedImageUrl),
lastAnnotatedDate: parseToDateString(
scrapedLastAnnotatedDate,
get(settingsStore).amazonRegion
Expand Down