🐱修复TikTok链接转换问题

This commit is contained in:
Evil0ctal 2022-02-11 20:10:26 -08:00 committed by GitHub
parent 2ba67c5eb9
commit 5f077a465b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -106,6 +106,10 @@ def get_tiktok_url(tiktok_link):
# 从请求头中获取原始链接
response = requests.get(url=tiktok_link, headers=headers, allow_redirects=False)
true_link = response.headers['Location'].split("?")[0]
# TikTok请求头返回的第二种链接类型
if '.html' in true_link:
response = requests.get(url=true_link, headers=headers, allow_redirects=False)
true_link = response.headers['Location'].split("?")[0]
return true_link
except Exception as e:
error_do(e, get_tiktok_url, tiktok_link)
@ -187,6 +191,7 @@ def get_video_info(original_url):
def get_video_info_tiktok(tiktok_url):
# 对TikTok视频进行解析
tiktok_url = get_tiktok_url(tiktok_url)
print(tiktok_url)
try:
tiktok_headers = {
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",