xulh commited on
Commit
9bece33
·
1 Parent(s): 9471b22

代码初始化

Browse files
Files changed (2) hide show
  1. app.py +3 -0
  2. video/shortVedio.py +36 -0
app.py CHANGED
@@ -2,11 +2,14 @@ from fastapi import FastAPI
2
  from inference.inference import router
3
  from picture.generalImg import routerImg
4
  from video.iqiyi import routerVideo
 
 
5
 
6
  app = FastAPI()
7
  app.include_router(router)
8
  app.include_router(routerImg)
9
  app.include_router(routerVideo)
 
10
 
11
 
12
  @app.get("/")
 
2
  from inference.inference import router
3
  from picture.generalImg import routerImg
4
  from video.iqiyi import routerVideo
5
+ from video.shortVedio import shortVideo
6
+
7
 
8
  app = FastAPI()
9
  app.include_router(router)
10
  app.include_router(routerImg)
11
  app.include_router(routerVideo)
12
+ app.include_router(shortVideo)
13
 
14
 
15
  @app.get("/")
video/shortVedio.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import APIRouter, Query, HTTPException
2
+ import requests
3
+ from pydantic import BaseModel
4
+
5
+ shortVideo = APIRouter()
6
+
7
+ # 第三方API地址
8
+ EXTERNAL_API_URL = "https://playlet.zonelian.com"
9
+
10
+
11
+ @shortVideo.get("/video/category/list")
12
+ async def video_search(
13
+ page: int = Query(1, description="页数"),
14
+ limit: int = Query(10, description="搜索内容列表数"),
15
+ zlsj: str = Query("zlsj", description="跳过加解密")
16
+ ):
17
+ """
18
+ 视频搜索接口 - 封装第三方 API。
19
+ """
20
+ # 参数传递给第三方API
21
+ params = {
22
+ "page": page,
23
+ "limit": limit,
24
+ "zlsj": zlsj
25
+ }
26
+ try:
27
+ # 发送请求到第三方API
28
+ response = requests.get(EXTERNAL_API_URL + "/api/category/list", params=params)
29
+ response.raise_for_status() # 确保HTTP请求成功
30
+
31
+ # 返回第三方API的结果
32
+ return response.json()
33
+
34
+ except requests.exceptions.RequestException as e:
35
+ # 处理请求错误
36
+ raise HTTPException(status_code=500, detail=f"请求第三方API出错: {str(e)}")