Spaces:
Sleeping
Sleeping
File size: 2,981 Bytes
343eed9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | import os
import re
file_path = r"c:\Users\lapet\github-all\darkmedia\.youtube\scripts\firefly_horror_bot.py"
content = open(file_path, 'r', encoding='utf-8').read()
# 1. Fix update_status Prompt assignment
pattern_status = re.escape('if scene: current_status[model_name]["scene"] = scene')
content = re.sub(pattern_status, 'if scene: current_status[model_name]["scene"] = scene\n if prompt: current_status[model_name]["prompt"] = prompt', content)
# 2. Fix Polling delay in wait_for_generation
# We look for the await asyncio.sleep(3) that comes AFTER a True return or loop check
content = content.replace('await asyncio.sleep(3)', 'await asyncio.sleep(1)')
# 3. Fix Move logic Method 2 (direct URL)
# Find the download_video URL direct logic
old_url_logic = """ if response.ok:
content = await response.body()
with open(filepath, "wb") as f:
f.write(content)
log(f"Vidéo téléchargée via URL directe : {filename}", "💾")
return True"""
new_url_logic = """ if response.ok:
content = await response.body()
with open(filepath, "wb") as f:
f.write(content)
log(f"Vidéo téléchargée via URL directe : {filename}", "💾")
# Déplacement vers le dossier de la story si spécifié
if story_folder:
try:
import shutil
from pathlib import Path
videos_dir = Path(story_folder) / "videos"
videos_dir.mkdir(parents=True, exist_ok=True)
if "_S" in str(video_number):
scene_tag = str(video_number).split("_S")[-1]
dest_name = f"S{scene_tag}.mp4"
else:
dest_name = f"{video_number}.mp4"
dest_path = videos_dir / dest_name
log(f" 📂 Tentative de déplacement (Méthode 2) : {filepath.name} -> {dest_path}", "🚚")
shutil.move(str(filepath), str(dest_path))
log(f" ✅ Vidéo déplacée avec succès vers : {dest_path}", "🚚")
except Exception as e:
log(f" ⚠️ Erreur lors du déplacement (Méthode 2) : {e}", "⚠️")
return True"""
content = content.replace(old_url_logic, new_url_logic)
with open(file_path, 'w', encoding='utf-8') as f:
f.write(content)
print("Patch applied successfully.")
|