Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,7 @@ from pydantic import BaseModel
|
|
| 3 |
from TeraboxDL import TeraboxDL
|
| 4 |
from fastapi.responses import PlainTextResponse
|
| 5 |
import time
|
|
|
|
| 6 |
|
| 7 |
# --- CONFIGURATION ---
|
| 8 |
# 1. Apni working ndus cookie yahan update karein (Ye expire hoti rehti hai)
|
|
@@ -46,6 +47,22 @@ def fetch_with_retry(link, retries=3, delay=2):
|
|
| 46 |
def read_root():
|
| 47 |
return {"message": "API is Online. Use /download?link=YOUR_URL"}
|
| 48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
@app.get("/download", response_class=PlainTextResponse)
|
| 50 |
async def get_download_link(link: str = Query(...)):
|
| 51 |
# Basic URL Validation
|
|
|
|
| 3 |
from TeraboxDL import TeraboxDL
|
| 4 |
from fastapi.responses import PlainTextResponse
|
| 5 |
import time
|
| 6 |
+
import base64
|
| 7 |
|
| 8 |
# --- CONFIGURATION ---
|
| 9 |
# 1. Apni working ndus cookie yahan update karein (Ye expire hoti rehti hai)
|
|
|
|
| 47 |
def read_root():
|
| 48 |
return {"message": "API is Online. Use /download?link=YOUR_URL"}
|
| 49 |
|
| 50 |
+
@app.get("/get_id")
|
| 51 |
+
def generate_id(link: str):
|
| 52 |
+
# Link ko encode karke "Secret ID" banana
|
| 53 |
+
encoded_id = base64.b64encode(link.encode()).decode()
|
| 54 |
+
return {"secret_id": encoded_id, "api_url": f"/decode_and_download?id={encoded_id}"}
|
| 55 |
+
|
| 56 |
+
@app.get("/decode_and_download", response_class=PlainTextResponse)
|
| 57 |
+
async def decode_id(id: str):
|
| 58 |
+
try:
|
| 59 |
+
# ID ko wapas asli link mein badalna
|
| 60 |
+
original_link = base64.b64decode(id).decode()
|
| 61 |
+
# Ab wahi purana download logic call karna
|
| 62 |
+
return await get_download_link(original_link)
|
| 63 |
+
except Exception:
|
| 64 |
+
raise HTTPException(status_code=400, detail="Invalid ID provided")
|
| 65 |
+
|
| 66 |
@app.get("/download", response_class=PlainTextResponse)
|
| 67 |
async def get_download_link(link: str = Query(...)):
|
| 68 |
# Basic URL Validation
|