File size: 1,951 Bytes
31adef6
 
 
ce16ace
c63c39e
8c64cc3
00db48c
 
8c64cc3
 
 
2e6074b
 
 
00db48c
 
 
 
 
 
 
 
31adef6
ce16ace
 
00db48c
ce16ace
 
31adef6
ce16ace
31adef6
 
 
 
 
 
 
 
00db48c
 
 
c63c39e
00db48c
 
ce16ace
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31adef6
 
dccde78
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
60
61
62
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
import uvicorn
from datetime import datetime
from routers import video, files, presets
from init_defaults import init_all_defaults
import os

# تهيئة الإعدادات الافتراضية عند بدء التشغيل
init_all_defaults()

# إعداد المسارات لتكون دائماً داخل مجلد Clipping
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
UPLOAD_BASE_DIR = os.path.join(BASE_DIR, "temp_videos")
ORIGINALS_DIR = os.path.join(UPLOAD_BASE_DIR, "originals")
PROCESSED_DIR = os.path.join(UPLOAD_BASE_DIR, "processed") 
AUDIO_DIR = os.path.join(UPLOAD_BASE_DIR, "audio")
TEMP_DIR = os.path.join(UPLOAD_BASE_DIR, "temp")

# إنشاء الفولدرات
for directory in [UPLOAD_BASE_DIR, ORIGINALS_DIR, PROCESSED_DIR, AUDIO_DIR, TEMP_DIR]:
    os.makedirs(directory, exist_ok=True)

app = FastAPI(
    title="Video Processing API",
    description="Simple API for video processing - optimized for n8n automation",
    version="1.0.0"
)

# CORS middleware
app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

# Include routers - توحيد الـ tags
app.include_router(video.router, prefix="/api/video", tags=["Video"])
app.include_router(files.router, prefix="/api/files", tags=["Files"])
app.include_router(presets.router, prefix="/api/presets", tags=["Presets"])

# نحذف نظام إدارة النسخ لحد ما نحتاجه

@app.get("/")
async def root():
    return {
        "message": "Video Processing API",
        "version": "1.0.0",
        "timestamp": datetime.now().isoformat()
    }

@app.get("/health")
async def health_check():
    return {
        "status": "healthy",
        "timestamp": datetime.now().isoformat()
    }

if __name__ == "__main__":
    uvicorn.run("main:app", host="0.0.0.0", port=7860, reload=True)