30 lines
874 B
Python
30 lines
874 B
Python
"""
|
||
修复数据库中的 TTS URL,将 127.0.0.1 替换为空,让系统重新生成
|
||
"""
|
||
import sys
|
||
import os
|
||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||
|
||
from sqlalchemy import create_engine, text
|
||
from lover.config import settings
|
||
|
||
def fix_tts_urls():
|
||
engine = create_engine(settings.DATABASE_URL)
|
||
|
||
with engine.connect() as conn:
|
||
# 将所有包含 127.0.0.1 的 TTS URL 清空
|
||
result = conn.execute(
|
||
text("""
|
||
UPDATE nf_chat_message
|
||
SET tts_url = NULL, tts_status = 'pending'
|
||
WHERE tts_url LIKE '%127.0.0.1%'
|
||
""")
|
||
)
|
||
conn.commit()
|
||
|
||
print(f"已清理 {result.rowcount} 条旧的 TTS URL")
|
||
print("用户下次请求 TTS 时会自动使用新的 URL")
|
||
|
||
if __name__ == "__main__":
|
||
fix_tts_urls()
|