Update main.py
Browse files
main.py
CHANGED
|
@@ -676,14 +676,19 @@ LEGENDA ORIGINAL:
|
|
| 676 |
json=export_payload,
|
| 677 |
timeout=600
|
| 678 |
)
|
| 679 |
-
export_resp.
|
|
|
|
|
|
|
| 680 |
export_data = export_resp.json()
|
| 681 |
final_content_url = export_data.get("video_url")
|
|
|
|
|
|
|
| 682 |
print(f"✅ Vídeo exportado: {final_content_url}")
|
| 683 |
else:
|
| 684 |
-
|
| 685 |
except Exception as ve:
|
| 686 |
-
print(f"⚠️ Erro no video export: {ve}")
|
|
|
|
| 687 |
|
| 688 |
# Se for imagem e result_type == meme
|
| 689 |
elif 'image' in content_type and title_text and result_data.get("result_type") == "meme":
|
|
@@ -740,13 +745,16 @@ LEGENDA ORIGINAL:
|
|
| 740 |
})
|
| 741 |
final_content_url = f"https://habulaj-recurve-api-img.hf.space/meme?{meme_params}&image_url={uploaded_img_url}"
|
| 742 |
print(f"✅ Meme API URL gerada (com imagem): {final_content_url}")
|
|
|
|
|
|
|
| 743 |
else:
|
| 744 |
# Só texto, sem imagem de apoio: manda apenas o text
|
| 745 |
meme_params = urllib.parse.urlencode({"text": title_text})
|
| 746 |
final_content_url = f"https://habulaj-recurve-api-img.hf.space/meme?{meme_params}"
|
| 747 |
print(f"✅ Meme API URL gerada (só texto): {final_content_url}")
|
| 748 |
except Exception as e:
|
| 749 |
-
print(f"⚠️ Erro ao gerar URL do meme: {e}")
|
|
|
|
| 750 |
|
| 751 |
# Add generated subtitles to the result JSON for Supabase
|
| 752 |
if result_json and srt_for_export:
|
|
|
|
| 676 |
json=export_payload,
|
| 677 |
timeout=600
|
| 678 |
)
|
| 679 |
+
if not export_resp.ok:
|
| 680 |
+
raise Exception(f"API de video export falhou com status {export_resp.status_code}: {export_resp.text}")
|
| 681 |
+
|
| 682 |
export_data = export_resp.json()
|
| 683 |
final_content_url = export_data.get("video_url")
|
| 684 |
+
if not final_content_url:
|
| 685 |
+
raise Exception(f"API de video export não retornou a URL do vídeo final. Resposta: {export_data}")
|
| 686 |
print(f"✅ Vídeo exportado: {final_content_url}")
|
| 687 |
else:
|
| 688 |
+
raise Exception("Falha ao obter URL do screenshot original.")
|
| 689 |
except Exception as ve:
|
| 690 |
+
print(f"⚠️ Erro crítico no video export: {ve}")
|
| 691 |
+
raise Exception(f"Falha na etapa de video export: {ve}")
|
| 692 |
|
| 693 |
# Se for imagem e result_type == meme
|
| 694 |
elif 'image' in content_type and title_text and result_data.get("result_type") == "meme":
|
|
|
|
| 745 |
})
|
| 746 |
final_content_url = f"https://habulaj-recurve-api-img.hf.space/meme?{meme_params}&image_url={uploaded_img_url}"
|
| 747 |
print(f"✅ Meme API URL gerada (com imagem): {final_content_url}")
|
| 748 |
+
else:
|
| 749 |
+
raise Exception("Falha ao receber a URL da imagem upada via recurve-save.")
|
| 750 |
else:
|
| 751 |
# Só texto, sem imagem de apoio: manda apenas o text
|
| 752 |
meme_params = urllib.parse.urlencode({"text": title_text})
|
| 753 |
final_content_url = f"https://habulaj-recurve-api-img.hf.space/meme?{meme_params}"
|
| 754 |
print(f"✅ Meme API URL gerada (só texto): {final_content_url}")
|
| 755 |
except Exception as e:
|
| 756 |
+
print(f"⚠️ Erro crítico ao gerar URL do meme: {e}")
|
| 757 |
+
raise Exception(f"Falha na etapa de geração da imagem (meme): {e}")
|
| 758 |
|
| 759 |
# Add generated subtitles to the result JSON for Supabase
|
| 760 |
if result_json and srt_for_export:
|