mirror of
https://github.com/bookorbit/bookorbit.git
synced 2026-11-03 08:21:39 -06:00
fix(metadata): improve Amazon genre extraction and diff panel UX
This commit is contained in:
@@ -47,18 +47,18 @@ function apply() {
|
||||
</div>
|
||||
<div class="flex gap-1.5 shrink-0">
|
||||
<button
|
||||
class="flex items-center gap-1.5 h-7 px-2.5 rounded-lg border border-border text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted transition-all active:scale-95"
|
||||
class="flex items-center gap-1.5 h-7 px-2.5 rounded-lg border border-amber-500/40 bg-amber-500/10 text-amber-600 dark:text-amber-400 text-xs font-medium hover:bg-amber-500/20 transition-all active:scale-95"
|
||||
@click="copyMissing"
|
||||
>
|
||||
<Copy class="size-3" />
|
||||
Missing
|
||||
Copy Missing
|
||||
</button>
|
||||
<button
|
||||
class="flex items-center gap-1.5 h-7 px-2.5 rounded-lg border border-border text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted transition-all active:scale-95"
|
||||
class="flex items-center gap-1.5 h-7 px-2.5 rounded-lg border border-primary/40 bg-primary/10 text-primary text-xs font-medium hover:bg-primary/20 transition-all active:scale-95"
|
||||
@click="copyAll"
|
||||
>
|
||||
<CopyCheck class="size-3" />
|
||||
All
|
||||
Copy All
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -5,14 +5,14 @@
|
||||
{
|
||||
"idx": 0,
|
||||
"version": "7",
|
||||
"when": 1771665199472,
|
||||
"when": 1771828457494,
|
||||
"tag": "0000_baseline",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 1,
|
||||
"version": "7",
|
||||
"when": 1771665199472,
|
||||
"when": 1771828457494,
|
||||
"tag": "0001_add_embedding_column",
|
||||
"breakpoints": true
|
||||
}
|
||||
|
||||
@@ -172,14 +172,28 @@ function extractCoverUrl($: CheerioAPI): string | undefined {
|
||||
}
|
||||
|
||||
function extractCategories($: CheerioAPI): string[] {
|
||||
const seen = new Set<string>();
|
||||
const cats: string[] = [];
|
||||
$('#detailBullets_feature_div .zg_hrsr .a-list-item a').each((_, el) => {
|
||||
const name = $(el)
|
||||
.text()
|
||||
|
||||
const add = (raw: string) => {
|
||||
const name = raw
|
||||
.trim()
|
||||
.replace(/\s*\(Books\)\s*$/i, '');
|
||||
if (name) cats.push(name);
|
||||
});
|
||||
.replace(/\s*\(Books\)\s*$/i, '')
|
||||
.trim();
|
||||
if (name && !seen.has(name)) {
|
||||
seen.add(name);
|
||||
cats.push(name);
|
||||
}
|
||||
};
|
||||
|
||||
// Primary: bestseller rank categories
|
||||
$('#detailBullets_feature_div .zg_hrsr .a-list-item a').each((_, el) => add($(el).text()));
|
||||
|
||||
// Fallback: breadcrumb navigation
|
||||
if (cats.length === 0) {
|
||||
$('#wayfinding-breadcrumbs_feature_div li:not(.a-breadcrumb-divider) a').each((_, el) => add($(el).text()));
|
||||
}
|
||||
|
||||
return cats;
|
||||
}
|
||||
|
||||
@@ -189,7 +203,7 @@ function detailBulletValue($: CheerioAPI, labelPattern: RegExp): string {
|
||||
let value = '';
|
||||
$('#detailBullets_feature_div .a-text-bold').each((_, el) => {
|
||||
if (labelPattern.test($(el).text())) {
|
||||
value = $(el).next('span').text().trim();
|
||||
value = $(el).next().text().trim();
|
||||
return false; // break
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user