Celeskry commited on
Commit
994a59d
·
verified ·
1 Parent(s): 6cd3cf5

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +21 -0
main.py CHANGED
@@ -29,6 +29,9 @@ hentai_app = HentaiApp()
29
  from app.ht_rd import HentaiRandomApp
30
  ht_random_app = HentaiRandomApp()
31
 
 
 
 
32
  @asynccontextmanager
33
  async def lifespan(app: FastAPI):
34
  await invite_app.start()
@@ -133,6 +136,24 @@ async def hentai_random(
133
  key = x_api_key or apikey
134
  return await ht_random_app.get_random(key, API_KEY, limit)
135
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  @app.get("/")
137
  def home():
138
  uptime_seconds = int(time.time() - START_TIME)
 
29
  from app.ht_rd import HentaiRandomApp
30
  ht_random_app = HentaiRandomApp()
31
 
32
+ from app.tik_dl import TikTokDownloader
33
+ tik_app = TikTokDownloader()
34
+
35
  @asynccontextmanager
36
  async def lifespan(app: FastAPI):
37
  await invite_app.start()
 
136
  key = x_api_key or apikey
137
  return await ht_random_app.get_random(key, API_KEY, limit)
138
 
139
+ @app.get("/api/v1/tiktok/download")
140
+ async def tiktok_download(
141
+ url: str = Query(..., description="TikTok Video URL"),
142
+ hd: int = Query(1, description="HD mode: 1 for ON, 0 for OFF"),
143
+ apikey: Optional[str] = Query(None),
144
+ x_api_key: Optional[str] = Header(None, alias="X-API-Key")
145
+ ):
146
+ key = x_api_key or apikey
147
+ if not API_KEY or key != API_KEY:
148
+ raise HTTPException(status_code=403, detail="API key invalid. Stop sniffin' around.")
149
+
150
+ res = await tik_app.fetch_video(url, hd)
151
+
152
+ if not res["ok"]:
153
+ raise HTTPException(status_code=400, detail=res["error"])
154
+
155
+ return res
156
+
157
  @app.get("/")
158
  def home():
159
  uptime_seconds = int(time.time() - START_TIME)