From ad04c49d278d3f242351a5da317172b61892b6f5 Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Sat, 21 Feb 2026 09:23:59 -0500 Subject: [PATCH] up --- Dockerfile | 1 + classes/MediaService.php | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3a95f83..0fdad12 100644 --- a/Dockerfile +++ b/Dockerfile @@ -58,6 +58,7 @@ RUN apk add --no-cache \ supervisor \ nginx \ curl \ + wget \ libzip \ icu \ oniguruma \ diff --git a/classes/MediaService.php b/classes/MediaService.php index 517251c..5b59f56 100644 --- a/classes/MediaService.php +++ b/classes/MediaService.php @@ -159,9 +159,11 @@ class MediaService { $tmpFile = tempnam(sys_get_temp_dir(), 'wget_'); $headerArgs = ''; foreach ($headers as $h) { + // Solo pasar headers que wget soporte $headerArgs .= ' --header=' . escapeshellarg($h); } - $cmd = 'wget -4 -q -O ' . escapeshellarg($tmpFile) . $headerArgs . ' ' . escapeshellarg($url) . ' 2>&1'; + // Intentar con GNU wget primero (soporta --prefer-family=IPv4) + $cmd = 'wget -q --prefer-family=IPv4 -O ' . escapeshellarg($tmpFile) . $headerArgs . ' ' . escapeshellarg($url) . ' 2>&1'; exec($cmd, $output, $exitCode); if ($exitCode === 0 && file_exists($tmpFile) && filesize($tmpFile) > 0) { @@ -171,7 +173,18 @@ class MediaService { return $content; } - error_log("[MediaService::downloadWithWget] FAIL exit={$exitCode} output=" . implode(' ', $output)); + // Fallback sin --prefer-family (BusyBox wget no lo soporta) + $cmd2 = 'wget -q -O ' . escapeshellarg($tmpFile) . $headerArgs . ' ' . escapeshellarg($url) . ' 2>&1'; + exec($cmd2, $output2, $exitCode2); + + if ($exitCode2 === 0 && file_exists($tmpFile) && filesize($tmpFile) > 0) { + $content = file_get_contents($tmpFile); + unlink($tmpFile); + error_log("[MediaService::downloadWithWget] OK (basic), " . strlen($content) . " bytes"); + return $content; + } + + error_log("[MediaService::downloadWithWget] FAIL exit={$exitCode}/{$exitCode2} output=" . implode(' ', array_merge($output, $output2))); if (file_exists($tmpFile)) unlink($tmpFile); return false; }