primevide 16:9 thumbnail scrapping sorunu çözüldü.
This commit is contained in:
@@ -444,6 +444,52 @@ function extractPrimeYear($, html) {
|
|||||||
* Extract thumbnail from Amazon Prime page
|
* Extract thumbnail from Amazon Prime page
|
||||||
*/
|
*/
|
||||||
function extractPrimeThumbnail($, html) {
|
function extractPrimeThumbnail($, html) {
|
||||||
|
// 1. Ana hero background'daki resmi al (style="aspect-ratio:16/9" div'indeki ilk resim)
|
||||||
|
const heroMatch = html.match(/<div[^>]*data-automation-id="hero-background"[^>]*>[\s\S]*?<img[^>]*src="([^"]+)"/);
|
||||||
|
if (heroMatch && heroMatch[1]) {
|
||||||
|
const imageUrl = heroMatch[1];
|
||||||
|
if (isValidPrimeThumbnail(imageUrl)) {
|
||||||
|
return imageUrl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. data-testid="base-image" ve style="aspect-ratio:16/9" kombinasyonu
|
||||||
|
const baseAspectMatch = html.match(/style="aspect-ratio:16\/9"[^>]*>[\s\S]*?<img[^>]*data-testid="base-image"[^>]*src="([^"]+)"/);
|
||||||
|
if (baseAspectMatch && baseAspectMatch[1]) {
|
||||||
|
const imageUrl = baseAspectMatch[1];
|
||||||
|
if (isValidPrimeThumbnail(imageUrl)) {
|
||||||
|
return imageUrl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. İlk loading="eager" olan resmi al (ana hero resmi)
|
||||||
|
const eagerImageMatch = html.match(/<img[^>]*loading="eager"[^>]*src="([^"]+)"/);
|
||||||
|
if (eagerImageMatch && eagerImageMatch[1]) {
|
||||||
|
const imageUrl = eagerImageMatch[1];
|
||||||
|
if (isValidPrimeThumbnail(imageUrl)) {
|
||||||
|
return imageUrl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. İlk data-testid="base-image" olan resmi al
|
||||||
|
const baseImageMatch = html.match(/<img[^>]*data-testid="base-image"[^>]*src="([^"]+)"/);
|
||||||
|
if (baseImageMatch && baseImageMatch[1]) {
|
||||||
|
const imageUrl = baseImageMatch[1];
|
||||||
|
if (isValidPrimeThumbnail(imageUrl)) {
|
||||||
|
return imageUrl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. _SX1080_FMjpg_ formatındaki en yüksek kaliteli resmi ara
|
||||||
|
const highQualityMatch = html.match(/(https:\/\/m\.media-amazon\.com\/images\/S\/pv-target-images\/[a-f0-9]+\._SX1080_FMjpg_\.jpg)/);
|
||||||
|
if (highQualityMatch && highQualityMatch[1]) {
|
||||||
|
const imageUrl = highQualityMatch[1];
|
||||||
|
if (isValidPrimeThumbnail(imageUrl)) {
|
||||||
|
return imageUrl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 6. En son fallback olarak meta tag'lerini kullan
|
||||||
for (const selector of PRIME_THUMBNAIL_SELECTORS) {
|
for (const selector of PRIME_THUMBNAIL_SELECTORS) {
|
||||||
const imageUrl = $(selector).attr('content') || $(selector).attr('src');
|
const imageUrl = $(selector).attr('content') || $(selector).attr('src');
|
||||||
if (imageUrl && isValidPrimeThumbnail(imageUrl)) {
|
if (imageUrl && isValidPrimeThumbnail(imageUrl)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user