jonathanjordan21 commited on
Commit
4a4fd31
·
verified ·
1 Parent(s): 5e79fdb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -9,14 +9,16 @@ app = FastAPI()
9
 
10
 
11
  @app.get("/tiktok_details/")
12
- async def read_item(link_detail: str):
13
  user_agent = "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; Googlebot/2.1; +http://www.google.com/bot.html) Chrome/W.X.Y.Z Safari/537.36"
14
- if "https:" in link_detail:
15
- url = link_detail
16
- elif link_detail[0] == "/":
17
- url = "https://tiktok.com" + link_detail
18
- else:
19
- url = "https://tiktok.com/"+link_detail
 
 
20
 
21
  res = requests.get(url, headers={"user-agent":user_agent})
22
  text_maker = html2text.HTML2Text()
 
9
 
10
 
11
  @app.get("/tiktok_details/")
12
+ async def read_item(username: str, video_id:str):
13
  user_agent = "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; Googlebot/2.1; +http://www.google.com/bot.html) Chrome/W.X.Y.Z Safari/537.36"
14
+ # if "https:" in link_detail:
15
+ # url = link_detail
16
+ # elif link_detail[0] == "/":
17
+ # url = "https://tiktok.com" + link_detail
18
+ # else:
19
+ # url = "https://tiktok.com/"+link_detail
20
+
21
+ url = f"https://www.tiktok.com/{username}/video/{video_id}"
22
 
23
  res = requests.get(url, headers={"user-agent":user_agent})
24
  text_maker = html2text.HTML2Text()