fix: youtube and baidu link parsing
This commit is contained in:
parent
a0016cd512
commit
c4d49694a2
1 changed files with 17 additions and 1 deletions
18
core/link.py
18
core/link.py
|
@ -14,7 +14,7 @@ from config import config
|
||||||
whitelist_param_links = ['www.iesdouyin.com','item.taobao.com', 'detail.tmall.com', 'h5.m.goofish.com', 'music.163.com',
|
whitelist_param_links = ['www.iesdouyin.com','item.taobao.com', 'detail.tmall.com', 'h5.m.goofish.com', 'music.163.com',
|
||||||
'www.bilibili.com', 'm.bilibili.com', 'bilibili.com', 'mall.bilibili.com',
|
'www.bilibili.com', 'm.bilibili.com', 'bilibili.com', 'mall.bilibili.com',
|
||||||
'space.bilibili.com', 'live.bilibili.com','item.m.jd.com','item.jd.com',
|
'space.bilibili.com', 'live.bilibili.com','item.m.jd.com','item.jd.com',
|
||||||
'www.xiaohongshu.com','zhuanlan.zhihu.com']
|
'www.xiaohongshu.com','zhuanlan.zhihu.com','www.baidu.com','www.youtube.com']
|
||||||
|
|
||||||
has_self_redirection_links = ['www.cnbeta.com.tw','m.cnbeta.com.tw','www.landiannews.com', 'www.bilibili.com']
|
has_self_redirection_links = ['www.cnbeta.com.tw','m.cnbeta.com.tw','www.landiannews.com', 'www.bilibili.com']
|
||||||
|
|
||||||
|
@ -174,6 +174,22 @@ def reserve_whitelisted_params(url):
|
||||||
# 重新构建URL
|
# 重新构建URL
|
||||||
cleaned_query = urlencode(new_query_params, doseq=True)
|
cleaned_query = urlencode(new_query_params, doseq=True)
|
||||||
return urlunparse(parsed_url._replace(query=cleaned_query))
|
return urlunparse(parsed_url._replace(query=cleaned_query))
|
||||||
|
elif parsed_url.hostname in ['www.baidu.com','www.youtube.com']:
|
||||||
|
new_query_params = {}
|
||||||
|
if parsed_url.hostname == 'www.baidu.com' and 'wd' in query_params:
|
||||||
|
# 百度搜索链接保留 wd 参数
|
||||||
|
new_query_params['wd'] = query_params['wd']
|
||||||
|
if parsed_url.hostname == 'www.youtube.com':
|
||||||
|
# YouTube 视频链接保留 v 参数
|
||||||
|
if 'v' in query_params:
|
||||||
|
new_query_params['v'] = query_params['v'] # 保留 v 参数
|
||||||
|
if 't' in query_params:
|
||||||
|
new_query_params['t'] = query_params['t'] # 保留 t 参数
|
||||||
|
if 'list' in query_params:
|
||||||
|
new_query_params['list'] = query_params['list'] # 保留 list 参数
|
||||||
|
# 重新构建URL
|
||||||
|
cleaned_query = urlencode(new_query_params, doseq=True)
|
||||||
|
return urlunparse(parsed_url._replace(query=cleaned_query))
|
||||||
elif parsed_url.hostname in ['chatglm.cn'] and query_params:
|
elif parsed_url.hostname in ['chatglm.cn'] and query_params:
|
||||||
# 就你叫智谱啊
|
# 就你叫智谱啊
|
||||||
new_query_params = {'share_conversation_id': query_params['share_conversation_id']}
|
new_query_params = {'share_conversation_id': query_params['share_conversation_id']}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue