fix(instagram): смягчить /cookies/check, честное сообщение для гейтованного контента
All checks were successful
CI/CD Pipeline / build-and-deploy (push) Successful in 1m0s
All checks were successful
CI/CD Pipeline / build-and-deploy (push) Successful in 1m0s
/cookies/check раньше тестировал только путь с cookies и при неудаче писал
cookies_invalid — даже когда реальное скачивание прекрасно работает через
app-level fallback без cookies. Теперь проверка повторяет этот же
эффективный путь: cookies path сломан известным багом yt-dlp (media/info
всегда 404 вместо редиректа на логин), но раз fallback его закрывает —
это не авария и не повод слать ложный алерт "куки протухли", который
обновление cookies всё равно не лечит. Если не работает и анонимный путь
(который cookies не использует) — это extraction_failed, а не cookies_invalid.
Отдельно: когда Instagram сам отказывает показывать контент анонимным/
несовместимым аккаунтам ("can't be seen by certain audiences") — это
легитимный отказ, а не наша поломка, и повторная попытка не поможет.
Пользователь теперь видит это прямо, а не общее "Something went wrong".
Админ по-прежнему получает полный технический текст без изменений.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
b5f0670754
commit
8fa53f7cfc
2 changed files with 92 additions and 75 deletions
12
bot.py
12
bot.py
|
|
@ -45,6 +45,11 @@ VK_DOWNLOADER_URL = os.getenv('VK_DOWNLOADER_URL', 'http://localhost:5555')
|
|||
YAPFILES_DOWNLOADER_URL = os.getenv('YAPFILES_DOWNLOADER_URL', 'http://localhost:5558')
|
||||
TIKTOK_DOWNLOADER_URL = os.getenv('TIKTOK_DOWNLOADER_URL', 'http://localhost:5559')
|
||||
|
||||
# Instagram сам отказывает в показе такого контента анонимным/несовместимым аккаунтам —
|
||||
# повторная попытка не поможет, поэтому пользователю нужен отдельный, понятный текст
|
||||
# вместо общего "Something went wrong"
|
||||
INSTAGRAM_SENSITIVE_CONTENT_MARKERS = ("can't be seen by certain audiences", "isn't available to everyone")
|
||||
|
||||
# Базовая директория проекта (абсолютный путь), чтобы не зависеть от рабочей директории процесса
|
||||
BASE_DIR = Path(__file__).resolve().parent
|
||||
|
||||
|
|
@ -111,6 +116,7 @@ TEXTS = {
|
|||
'sending': "📤 Отправляю видео...",
|
||||
'caption': "Видео скачано с @{bot_username}",
|
||||
'error': "❌ Something went wrong while processing your video. Please try again in a bit.",
|
||||
'error_sensitive_content': "⚠️ This content is restricted by Instagram (age/sensitive content) and can't be downloaded by the bot. Try opening the link directly in the Instagram app.",
|
||||
'error_unknown_source': "Пардон, не умеем работать с этим источником",
|
||||
'error_vk_not_video': "❌ Это ссылка VK, но не на видео. Пришлите ссылку вида vk.com/video... или vk.com/clip...",
|
||||
'error_file_too_large': "❌ Видео слишком большое ({size_mb:.1f} МБ, max = 50)",
|
||||
|
|
@ -169,6 +175,7 @@ TEXTS = {
|
|||
'sending': "📤 Sending video...",
|
||||
'caption': "Video downloaded via @{bot_username}",
|
||||
'error': "❌ Something went wrong while processing your video. Please try again in a bit.",
|
||||
'error_sensitive_content': "⚠️ This content is restricted by Instagram (age/sensitive content) and can't be downloaded by the bot. Try opening the link directly in the Instagram app.",
|
||||
'error_unknown_source': "Sorry, this source is not supported",
|
||||
'error_vk_not_video': "❌ This is a VK link, but not a video. Send a vk.com/video... or vk.com/clip... link.",
|
||||
'error_file_too_large': "❌ Video is too large ({size_mb:.1f} MB, max = 50)",
|
||||
|
|
@ -841,7 +848,10 @@ async def process_queue_item(item: QueueItem):
|
|||
|
||||
await notify_admin_error(item.url, str(e), item.original_message.from_user)
|
||||
|
||||
error_msg = get_text(item.locale, 'error')
|
||||
if any(marker in str(e).lower() for marker in INSTAGRAM_SENSITIVE_CONTENT_MARKERS):
|
||||
error_msg = get_text(item.locale, 'error_sensitive_content')
|
||||
else:
|
||||
error_msg = get_text(item.locale, 'error')
|
||||
try:
|
||||
await item.status_message.edit_text(error_msg)
|
||||
except:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue