Spaces:
Running
Running
admin
commited on
Commit
·
0f30007
1
Parent(s):
dbe16dd
upl base codes
Browse files
README.md
CHANGED
@@ -2,13 +2,13 @@
|
|
2 |
title: Tiktok Parser
|
3 |
emoji: 🏢
|
4 |
colorFrom: red
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
sdk_version: 5.19.0
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: apache-2.0
|
11 |
-
short_description:
|
12 |
---
|
13 |
|
14 |
-
Check out the configuration reference at https://
|
|
|
2 |
title: Tiktok Parser
|
3 |
emoji: 🏢
|
4 |
colorFrom: red
|
5 |
+
colorTo: gray
|
6 |
sdk: gradio
|
7 |
sdk_version: 5.19.0
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: apache-2.0
|
11 |
+
short_description: Parse TikTok video without watermark
|
12 |
---
|
13 |
|
14 |
+
Check out the configuration reference at https://api.xinyew.cn/doc/douyinjx.html
|
app.py
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import re
|
3 |
+
import requests
|
4 |
+
import gradio as gr
|
5 |
+
|
6 |
+
|
7 |
+
def extract_fst_url(text):
|
8 |
+
url_pattern = r'(https?://[^\s"]+)'
|
9 |
+
match = re.search(url_pattern, text)
|
10 |
+
if match:
|
11 |
+
return match.group(1)
|
12 |
+
else:
|
13 |
+
return None
|
14 |
+
|
15 |
+
|
16 |
+
def infer(video_url):
|
17 |
+
video, parse_time, desc, avatar, author, sign = None, None, None, None, None, None
|
18 |
+
if not video_url:
|
19 |
+
desc = "The video sharing link is empty!"
|
20 |
+
return video, parse_time, desc, avatar, author, sign
|
21 |
+
|
22 |
+
video_url = extract_fst_url(video_url)
|
23 |
+
if not video_url:
|
24 |
+
desc = "Please enter a valid video sharing link!"
|
25 |
+
return video, parse_time, desc, avatar, author, sign
|
26 |
+
|
27 |
+
try:
|
28 |
+
response = requests.get(
|
29 |
+
os.getenv("api"),
|
30 |
+
params={"url": video_url},
|
31 |
+
)
|
32 |
+
|
33 |
+
response_json = response.json()
|
34 |
+
retcode = response_json["code"]
|
35 |
+
if retcode == 200:
|
36 |
+
response_data = response_json["data"]
|
37 |
+
video = response_data["play_url"]
|
38 |
+
parse_time = response_data["parse_time"]
|
39 |
+
additional_data = response_data["additional_data"][0]
|
40 |
+
desc = additional_data["desc"]
|
41 |
+
avatar = additional_data["url"].split("?from=")[0]
|
42 |
+
author = additional_data["nickname"]
|
43 |
+
sign = additional_data["signature"]
|
44 |
+
|
45 |
+
else:
|
46 |
+
desc = f"Interface call failed, error code: HTTP {retcode}"
|
47 |
+
|
48 |
+
except Exception as e:
|
49 |
+
desc = f"Video parsing failed, error code: {e}"
|
50 |
+
|
51 |
+
return video, parse_time, desc, avatar, author, sign
|
52 |
+
|
53 |
+
|
54 |
+
if __name__ == "__main__":
|
55 |
+
gr.Interface(
|
56 |
+
fn=infer,
|
57 |
+
inputs=[
|
58 |
+
gr.Textbox(
|
59 |
+
label="Please enter TikTok video sharing short link",
|
60 |
+
placeholder="https://v.douyin.com/*",
|
61 |
+
show_copy_button=True,
|
62 |
+
),
|
63 |
+
],
|
64 |
+
outputs=[
|
65 |
+
gr.Video(label="Video download", show_download_button=True),
|
66 |
+
gr.Textbox(label="Parsing time", show_copy_button=True),
|
67 |
+
gr.Textbox(label="Video description", show_copy_button=True),
|
68 |
+
gr.Image(label="Author avatar", show_share_button=True),
|
69 |
+
gr.Textbox(label="Author nickname", show_copy_button=True),
|
70 |
+
gr.TextArea(label="Author signature", show_copy_button=True),
|
71 |
+
],
|
72 |
+
title="Parse TikTok video without watermark",
|
73 |
+
description="This site does not provide any video storage services, only to provide the most basic resolution services",
|
74 |
+
flagging_mode="never",
|
75 |
+
examples=[
|
76 |
+
"https://v.douyin.com/iUsp2kWc",
|
77 |
+
"5.17 06/17 [email protected] OXM:/ MC——创世! 密码的 这咋玩?# 我的世界 # 我的世界极限生存 # 冰℃ https://v.douyin.com/i5MXfJac/ 复制此链接,打开Dou音搜索,直接观看视频!",
|
78 |
+
],
|
79 |
+
cache_examples=False,
|
80 |
+
).launch()
|