Fdgg55 commited on
Commit
2373b18
·
verified ·
1 Parent(s): 32bd7de

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -21
app.py CHANGED
@@ -5,9 +5,12 @@ import whisper
5
  import tempfile
6
  import os
7
  import io
 
 
 
8
  from diffusers import StableDiffusionPipeline
9
 
10
- # --- 1. METADATA ---
11
  api_description = """
12
  <div style="text-align: center; margin-top: 20px; border-bottom: 1px solid #333; padding-bottom: 20px;">
13
  <img src="https://i.ibb.co/C5nyyyXH/cccfe44a8d63663a60eed6f0300a8b44.jpg" width="150" style="border-radius: 15px; box-shadow: 0 0 20px rgba(0, 255, 204, 0.6); border: 2px solid #00ffcc;">
@@ -32,11 +35,10 @@ app = FastAPI(
32
  description=api_description,
33
  version="2.0.0",
34
  openapi_tags=tags_metadata,
35
- docs_url=None, # We disable the default so we can use our custom Neon UI
36
  redoc_url=None
37
  )
38
 
39
- # --- 2. CUSTOM NEON UI ---
40
  @app.get("/docs", include_in_schema=False)
41
  async def neon_swagger_ui():
42
  html = """
@@ -48,39 +50,25 @@ async def neon_swagger_ui():
48
  <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/swagger-ui.css" />
49
  <link rel="icon" type="image/png" href="https://i.ibb.co/C5nyyyXH/cccfe44a8d63663a60eed6f0300a8b44.jpg" />
50
  <style>
51
- /* 🚀 CUSTOM NEON CYBERPUNK CSS 🚀 */
52
  body { background-color: #050505 !important; color: #00ffcc !important; font-family: 'Segoe UI', Tahoma, sans-serif; }
53
  .swagger-ui .info .title { color: #00ffcc !important; text-shadow: 0 0 10px rgba(0, 255, 204, 0.7); }
54
  .swagger-ui .info p { color: #a0aec0 !important; }
55
  .swagger-ui .info h1, .swagger-ui .info h2, .swagger-ui .info h3, .swagger-ui .info h4, .swagger-ui .info h5 { color: #00ffcc !important; }
56
  .swagger-ui .info a { color: #bd00ff !important; text-shadow: 0 0 8px rgba(189, 0, 255, 0.7); }
57
  .swagger-ui .scheme-container { background-color: #0a0a0a !important; box-shadow: 0 0 15px rgba(0, 255, 204, 0.1); border-bottom: 1px solid #00ffcc; }
58
-
59
- /* GET Requests (Neon Cyan) */
60
  .swagger-ui .opblock.opblock-get { background: rgba(0, 255, 204, 0.05) !important; border: 1px solid #00ffcc !important; box-shadow: 0 0 10px rgba(0, 255, 204, 0.2); border-radius: 8px; }
61
  .swagger-ui .opblock.opblock-get .opblock-summary-method { background: #00ffcc !important; color: #000 !important; font-weight: bold; }
62
-
63
- /* POST Requests (Neon Purple) */
64
  .swagger-ui .opblock.opblock-post { background: rgba(189, 0, 255, 0.05) !important; border: 1px solid #bd00ff !important; box-shadow: 0 0 10px rgba(189, 0, 255, 0.2); border-radius: 8px; }
65
  .swagger-ui .opblock.opblock-post .opblock-summary-method { background: #bd00ff !important; color: #fff !important; font-weight: bold; }
66
-
67
- /* Glowing Execute Button */
68
  .swagger-ui .btn.execute { background-color: #00ffcc !important; color: #000 !important; border: none !important; box-shadow: 0 0 15px rgba(0, 255, 204, 0.6) !important; font-weight: bold; transition: 0.3s; }
69
  .swagger-ui .btn.execute:hover { box-shadow: 0 0 25px rgba(0, 255, 204, 1) !important; }
70
  .swagger-ui .btn { color: #00ffcc !important; border-color: #00ffcc !important; }
71
-
72
- /* Text & Inputs */
73
  .swagger-ui .opblock-body pre.microlight { background-color: #000 !important; border: 1px solid #333 !important; border-radius: 8px; color: #fff !important; }
74
- .swagger-ui .parameters-col_name { color: #bd00ff !important; }
75
  .swagger-ui input[type=text], .swagger-ui input[type=file] { background: #000 !important; color: #00ffcc !important; border: 1px solid #bd00ff !important; border-radius: 4px; padding: 5px; }
76
  .swagger-ui .responses-inner h4, .swagger-ui .responses-inner h5 { color: #00ffcc !important; }
77
  .swagger-ui svg { fill: #00ffcc !important; }
78
-
79
- /* Models Section */
80
  .swagger-ui section.models { border: 1px solid #333 !important; background: #0a0a0a !important; border-radius: 8px;}
81
  .swagger-ui section.models h4 { color: #00ffcc !important; border-bottom: 1px solid #333; }
82
- .swagger-ui .model-title { color: #bd00ff !important; }
83
- .swagger-ui .model { color: #a0aec0 !important; }
84
  </style>
85
  </head>
86
  <body>
@@ -103,8 +91,7 @@ async def neon_swagger_ui():
103
  """
104
  return HTMLResponse(html)
105
 
106
-
107
- # --- 3. LOAD AI MODELS ---
108
  print("Loading Whisper Voice AI...")
109
  voice_model = whisper.load_model("base")
110
 
@@ -112,8 +99,7 @@ print("Loading Uncensored Image AI...")
112
  image_model = StableDiffusionPipeline.from_pretrained("prompthero/openjourney", safety_checker=None)
113
  image_model.to("cpu")
114
 
115
-
116
- # --- 4. API ENDPOINTS ---
117
  @app.get("/", tags=["System"])
118
  def read_root():
119
  return {"status": "Silent Utils API is ONLINE", "version": "2.0.0"}
@@ -123,6 +109,24 @@ def download_media(url: str):
123
  """Bypasses protections and gets the direct raw MP4/MP3 link."""
124
  clean_url = url.strip()
125
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  ydl_opts = {
127
  'format': 'best',
128
  'quiet': True,
 
5
  import tempfile
6
  import os
7
  import io
8
+ import urllib.request
9
+ import urllib.parse
10
+ import json
11
  from diffusers import StableDiffusionPipeline
12
 
13
+ # --- 1. METADATA & NEON UI ---
14
  api_description = """
15
  <div style="text-align: center; margin-top: 20px; border-bottom: 1px solid #333; padding-bottom: 20px;">
16
  <img src="https://i.ibb.co/C5nyyyXH/cccfe44a8d63663a60eed6f0300a8b44.jpg" width="150" style="border-radius: 15px; box-shadow: 0 0 20px rgba(0, 255, 204, 0.6); border: 2px solid #00ffcc;">
 
35
  description=api_description,
36
  version="2.0.0",
37
  openapi_tags=tags_metadata,
38
+ docs_url=None,
39
  redoc_url=None
40
  )
41
 
 
42
  @app.get("/docs", include_in_schema=False)
43
  async def neon_swagger_ui():
44
  html = """
 
50
  <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/swagger-ui.css" />
51
  <link rel="icon" type="image/png" href="https://i.ibb.co/C5nyyyXH/cccfe44a8d63663a60eed6f0300a8b44.jpg" />
52
  <style>
 
53
  body { background-color: #050505 !important; color: #00ffcc !important; font-family: 'Segoe UI', Tahoma, sans-serif; }
54
  .swagger-ui .info .title { color: #00ffcc !important; text-shadow: 0 0 10px rgba(0, 255, 204, 0.7); }
55
  .swagger-ui .info p { color: #a0aec0 !important; }
56
  .swagger-ui .info h1, .swagger-ui .info h2, .swagger-ui .info h3, .swagger-ui .info h4, .swagger-ui .info h5 { color: #00ffcc !important; }
57
  .swagger-ui .info a { color: #bd00ff !important; text-shadow: 0 0 8px rgba(189, 0, 255, 0.7); }
58
  .swagger-ui .scheme-container { background-color: #0a0a0a !important; box-shadow: 0 0 15px rgba(0, 255, 204, 0.1); border-bottom: 1px solid #00ffcc; }
 
 
59
  .swagger-ui .opblock.opblock-get { background: rgba(0, 255, 204, 0.05) !important; border: 1px solid #00ffcc !important; box-shadow: 0 0 10px rgba(0, 255, 204, 0.2); border-radius: 8px; }
60
  .swagger-ui .opblock.opblock-get .opblock-summary-method { background: #00ffcc !important; color: #000 !important; font-weight: bold; }
 
 
61
  .swagger-ui .opblock.opblock-post { background: rgba(189, 0, 255, 0.05) !important; border: 1px solid #bd00ff !important; box-shadow: 0 0 10px rgba(189, 0, 255, 0.2); border-radius: 8px; }
62
  .swagger-ui .opblock.opblock-post .opblock-summary-method { background: #bd00ff !important; color: #fff !important; font-weight: bold; }
 
 
63
  .swagger-ui .btn.execute { background-color: #00ffcc !important; color: #000 !important; border: none !important; box-shadow: 0 0 15px rgba(0, 255, 204, 0.6) !important; font-weight: bold; transition: 0.3s; }
64
  .swagger-ui .btn.execute:hover { box-shadow: 0 0 25px rgba(0, 255, 204, 1) !important; }
65
  .swagger-ui .btn { color: #00ffcc !important; border-color: #00ffcc !important; }
 
 
66
  .swagger-ui .opblock-body pre.microlight { background-color: #000 !important; border: 1px solid #333 !important; border-radius: 8px; color: #fff !important; }
 
67
  .swagger-ui input[type=text], .swagger-ui input[type=file] { background: #000 !important; color: #00ffcc !important; border: 1px solid #bd00ff !important; border-radius: 4px; padding: 5px; }
68
  .swagger-ui .responses-inner h4, .swagger-ui .responses-inner h5 { color: #00ffcc !important; }
69
  .swagger-ui svg { fill: #00ffcc !important; }
 
 
70
  .swagger-ui section.models { border: 1px solid #333 !important; background: #0a0a0a !important; border-radius: 8px;}
71
  .swagger-ui section.models h4 { color: #00ffcc !important; border-bottom: 1px solid #333; }
 
 
72
  </style>
73
  </head>
74
  <body>
 
91
  """
92
  return HTMLResponse(html)
93
 
94
+ # --- 2. LOAD AI MODELS ---
 
95
  print("Loading Whisper Voice AI...")
96
  voice_model = whisper.load_model("base")
97
 
 
99
  image_model = StableDiffusionPipeline.from_pretrained("prompthero/openjourney", safety_checker=None)
100
  image_model.to("cpu")
101
 
102
+ # --- 3. API ENDPOINTS ---
 
103
  @app.get("/", tags=["System"])
104
  def read_root():
105
  return {"status": "Silent Utils API is ONLINE", "version": "2.0.0"}
 
109
  """Bypasses protections and gets the direct raw MP4/MP3 link."""
110
  clean_url = url.strip()
111
 
112
+ # 💥 FIREWALL BYPASS: If it's YouTube, route it through an external proxy API!
113
+ if "youtube.com" in clean_url or "youtu.be" in clean_url:
114
+ try:
115
+ bypass_url = f"https://api.bk9.site/yt/mp4?url={urllib.parse.quote(clean_url)}"
116
+ req = urllib.request.Request(bypass_url, headers={'User-Agent': 'Mozilla/5.0'})
117
+ with urllib.request.urlopen(req) as response:
118
+ data = json.loads(response.read().decode())
119
+ if data.get("status") and "BK9" in data:
120
+ return {
121
+ "success": True,
122
+ "title": data["BK9"].get("title", "YouTube Video"),
123
+ "download_url": data["BK9"].get("url")
124
+ }
125
+ except Exception as bypass_e:
126
+ print("Bypass failed:", str(bypass_e))
127
+ # If bypass fails, fall back to yt-dlp just in case
128
+
129
+ # Standard yt-dlp for TikTok, Instagram, Twitter, etc.
130
  ydl_opts = {
131
  'format': 'best',
132
  'quiet': True,