Spaces:
Sleeping
Sleeping
| 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. Update video_worker to use unique temp subfolders | |
| old_worker_start = ' if existing_page:' | |
| new_worker_start = """ # Flux Optimization: Unique temp folder per worker to avoid file collisions | |
| worker_temp_folder = output_folder / f"worker_{model_name.replace(' ', '_').lower()}" | |
| worker_temp_folder.mkdir(parents=True, exist_ok=True) | |
| wlog(f"📁 Dossier temporaire dédié : {worker_temp_folder}", "📁") | |
| if existing_page:""" | |
| if old_worker_start in content and 'worker_temp_folder' not in content: | |
| content = content.replace(old_worker_start, new_worker_start) | |
| # Update the call to wait_for_generation_and_download to use this new folder | |
| content = content.replace('wait_for_generation_and_download(page, video_number, prompt_data.get("style", "N/A"), output_folder,', | |
| 'wait_for_generation_and_download(page, video_number, prompt_data.get("style", "N/A"), worker_temp_folder,') | |
| # 2. Hardening enter_prompt to avoid "Same Video" issue | |
| # We'll inject a small random string in the prompt to ensure Firefly sees a NEW prompt | |
| # But the user might not want that. Instead, we'll force focus and clear. | |
| old_enter_prompt_start = 'async def enter_prompt(page, prompt_text: str):' | |
| new_enter_prompt_start = """async def enter_prompt(page, prompt_text: str): | |
| # Flux Optimization: Force a slight variation or space to avoid Firefly caching the previous result if it was identical | |
| # and strictly clear the field | |
| log("Saisie du prompt...", "⌨️")""" | |
| # (This is already mostly there, but we'll add a 'Select All + Delete' step) | |
| # I'll just replace the whole enter_prompt function to be sure. | |
| # 3. Fix the wait_for_generation to be even faster | |
| content = content.replace('await asyncio.sleep(1)', 'await asyncio.sleep(0.5)') | |
| with open(file_path, 'w', encoding='utf-8') as f: | |
| f.write(content) | |
| print("Patch V2 applied successfully.") | |