Spaces:
Running
Running
© 2025 by JerryCoder
Browse files
app.py
CHANGED
|
@@ -27,62 +27,6 @@ BASE_URL = "https://jerrycoder-jerryapp.hf.space"
|
|
| 27 |
def home():
|
| 28 |
return {"status": "ok"}
|
| 29 |
|
| 30 |
-
|
| 31 |
-
# 🔥 MAIN YT ENDPOINT
|
| 32 |
-
@app.get("/yt")
|
| 33 |
-
def yt(url: str, quality: str = "128"):
|
| 34 |
-
try:
|
| 35 |
-
# ✅ STEP 1: CALL NEOXR API
|
| 36 |
-
neoxr_url = f"https://api.neoxr.eu/api/youtube?url={url}&type=audio&quality={quality}kbps&apikey=jerrycoder"
|
| 37 |
-
r = requests.get(neoxr_url, timeout=20)
|
| 38 |
-
|
| 39 |
-
if r.status_code != 200:
|
| 40 |
-
raise Exception("Neoxr API failed")
|
| 41 |
-
|
| 42 |
-
data = r.json()
|
| 43 |
-
|
| 44 |
-
if not data.get("status"):
|
| 45 |
-
raise Exception("Invalid response from Neoxr")
|
| 46 |
-
|
| 47 |
-
# ✅ META
|
| 48 |
-
title = data.get("title")
|
| 49 |
-
duration = data.get("fduration") or data.get("duration")
|
| 50 |
-
download_url = data["data"]["url"]
|
| 51 |
-
|
| 52 |
-
# ✅ STEP 2: CALL /convert
|
| 53 |
-
convert_api = f"{BASE_URL}/convert?url={download_url}"
|
| 54 |
-
conv = requests.get(convert_api, timeout=60)
|
| 55 |
-
|
| 56 |
-
if conv.status_code != 200:
|
| 57 |
-
raise Exception("Convert API failed")
|
| 58 |
-
|
| 59 |
-
conv_json = conv.json()
|
| 60 |
-
|
| 61 |
-
if not conv_json.get("success"):
|
| 62 |
-
raise Exception(conv_json.get("error", "Conversion failed"))
|
| 63 |
-
|
| 64 |
-
final_url = conv_json.get("mp3_url")
|
| 65 |
-
|
| 66 |
-
# ✅ FINAL JSON
|
| 67 |
-
finalJson = {
|
| 68 |
-
"status": "success",
|
| 69 |
-
"title": title,
|
| 70 |
-
"duration": duration,
|
| 71 |
-
"quality": f"{quality} kbs",
|
| 72 |
-
"url": final_url,
|
| 73 |
-
"creator": "JerryCoder",
|
| 74 |
-
"telegram": "@Oggy_Workshop"
|
| 75 |
-
}
|
| 76 |
-
|
| 77 |
-
return finalJson
|
| 78 |
-
|
| 79 |
-
except Exception as e:
|
| 80 |
-
return {
|
| 81 |
-
"status": "error",
|
| 82 |
-
"error": str(e)
|
| 83 |
-
}
|
| 84 |
-
|
| 85 |
-
|
| 86 |
# 🔥 CONVERT ENDPOINT (UNCHANGED BUT CLEANED)
|
| 87 |
@app.get("/convert")
|
| 88 |
def convert(url: str):
|
|
|
|
| 27 |
def home():
|
| 28 |
return {"status": "ok"}
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
# 🔥 CONVERT ENDPOINT (UNCHANGED BUT CLEANED)
|
| 31 |
@app.get("/convert")
|
| 32 |
def convert(url: str):
|