Skip to content

fix(instagram): восстановить скачивание Reels (curl-cffi + cookies sync)#4

Merged
pyfig merged 2 commits into
mainfrom
cursor/fix-instagram-reels-5952
Jun 30, 2026
Merged

fix(instagram): восстановить скачивание Reels (curl-cffi + cookies sync)#4
pyfig merged 2 commits into
mainfrom
cursor/fix-instagram-reels-5952

Conversation

@pyfig

@pyfig pyfig commented Jun 30, 2026

Copy link
Copy Markdown
Owner

Проблема

При отправке ссылки на Instagram Reel бот отвечал:

❌ Could not download this Instagram post. Please try again later.

Локальная проверка yt-dlp на URL из скриншота (/reel/DZdSSJ7I_FM/) воспроизводит ошибку Instagram sent an empty media response. Instagram теперь требует browser impersonation через зависимость curl_cffi, а Docker-образ устанавливал yt-dlp без этого extra.

Изменения

Исправление Instagram Reels

  1. Dockerfile — установка yt-dlp[default,curl-cffi] вместо голого yt-dlp
  2. ytdlpOpts — синхронизация cookie-файлов с read-only mount в writable temp
  3. Ошибки yt-dlp — если ответ явно просит cookies, классифицируем как auth (для логов)

UX ошибок (по запросу)

  • Обычные пользователи — всегда видят errors.generic («Что-то пошло не так…») при сбоях загрузки
  • Админ (ADMIN_TELEGRAM_ID) — та же общая фраза + блок 🔧 Debug с текстом ошибки исполнения (yt-dlp, send и т.д.)
  • Смысловые сообщения сохранены: «только текст» для X, «слишком большой файл», «нет медиа» для Pinterest и т.п.

Деплой

docker compose build saveinator
docker compose up -d --force-recreate saveinator

Если после деплоя ошибка сохранится — обновить cookies:

scripts/deploy_instagram_cookies.sh

Тесты

  • go test ./internal/worker/... — OK (userFacingError, ytdlpOpts)
  • go test ./internal/ytdlp/... — OK
  • scripts/check-parity.sh — OK
Open in Web Open in Cursor 

cursoragent and others added 2 commits June 30, 2026 11:22
Instagram now requires browser impersonation via curl_cffi in yt-dlp.
The Docker image installed plain yt-dlp without that dependency, so
reel downloads failed with an empty media response even when cookies
were configured.

Also sync Instagram/TikTok cookie files from the read-only mount into
the writable temp path before yt-dlp runs, matching maintenance and
photo fallback behavior. Map empty-media-response errors that mention
--cookies to instagram.auth_required so operators know to refresh cookies.

Co-authored-by: Daniil Khramov <pyfig@users.noreply.github.com>
Regular users now always see errors.generic on download failures instead
of platform-specific messages like instagram.download_failed.

Admins (ADMIN_TELEGRAM_ID) get the same generic text plus the underlying
execution error to simplify production debugging.

Also fix maintenance_test to use context.Background for Go 1.22 CI.

Co-authored-by: Daniil Khramov <pyfig@users.noreply.github.com>
@pyfig pyfig marked this pull request as ready for review June 30, 2026 11:59
@pyfig pyfig merged commit 9649718 into main Jun 30, 2026
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants