mirror of
https://github.com/xhlove/GetDanMu.git
synced 2025-12-17 08:35:57 +08:00
增加搜狐视频弹幕下载并改进输入提示
This commit is contained in:
@@ -3,13 +3,15 @@
|
||||
'''
|
||||
# 作者: weimo
|
||||
# 创建日期: 2020-01-05 12:45:18
|
||||
# 上次编辑时间 : 2020-01-11 17:37:22
|
||||
# 上次编辑时间 : 2020-01-16 14:50:34
|
||||
# 一个人的命运啊,当然要靠自我奋斗,但是...
|
||||
'''
|
||||
|
||||
import hashlib
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from basic.vars import ALLOW_SITES
|
||||
|
||||
def remove_same_danmu(comments: list):
|
||||
# 在原有基础上pop会引起索引变化 所以还是采用下面这个方式
|
||||
contents = []
|
||||
@@ -23,7 +25,11 @@ def remove_same_danmu(comments: list):
|
||||
return contents
|
||||
|
||||
def check_url_site(url):
|
||||
return urlparse(url).netloc.split(".")[-2]
|
||||
site = urlparse(url).netloc.split(".")[-2]
|
||||
if site in ALLOW_SITES:
|
||||
return site
|
||||
else:
|
||||
return None
|
||||
|
||||
def check_url_locale(url):
|
||||
flag = {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
'''
|
||||
# 作者: weimo
|
||||
# 创建日期: 2020-01-04 19:17:44
|
||||
# 上次编辑时间 : 2020-01-11 17:25:09
|
||||
# 上次编辑时间 : 2020-01-16 20:06:23
|
||||
# 一个人的命运啊,当然要靠自我奋斗,但是...
|
||||
'''
|
||||
import os
|
||||
@@ -31,12 +31,16 @@ def write_lines_to_file(ass_head, lines, file_path):
|
||||
for line in lines:
|
||||
f.write(line + "\n")
|
||||
|
||||
def check_file(name, skip=False, fpath=os.getcwd()):
|
||||
def check_file(name, args, fpath=os.getcwd()):
|
||||
flag = True
|
||||
file_path = os.path.join(fpath, name + ".ass")
|
||||
if os.path.isfile(file_path):
|
||||
if skip:
|
||||
if args.y:
|
||||
os.remove(file_path)
|
||||
elif args.series:
|
||||
# 存在重复的 那么直接pass(认为已经下载好了)
|
||||
flag = False
|
||||
return flag, file_path
|
||||
else:
|
||||
isremove = input("{}已存在,是否覆盖?(y/n):".format(file_path))
|
||||
if isremove.strip() == "y":
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
'''
|
||||
# 作者: weimo
|
||||
# 创建日期: 2020-01-04 19:14:43
|
||||
# 上次编辑时间 : 2020-01-11 17:42:30
|
||||
# 上次编辑时间 : 2020-01-16 19:44:55
|
||||
# 一个人的命运啊,当然要靠自我奋斗,但是...
|
||||
'''
|
||||
import re
|
||||
@@ -40,6 +40,28 @@ def get_all_vids_by_column_id():
|
||||
# 综艺类型的
|
||||
pass
|
||||
|
||||
def get_cid_by_vid(vid):
|
||||
api_url = "http://union.video.qq.com/fcgi-bin/data"
|
||||
params = {
|
||||
"tid": "98",
|
||||
"appid": "10001005",
|
||||
"appkey": "0d1a9ddd94de871b",
|
||||
"idlist": vid,
|
||||
"otype":"json"
|
||||
}
|
||||
r = requests.get(api_url, params=params, headers=qqlive).content.decode("utf-8")
|
||||
data = json.loads(r.lstrip("QZOutputJson=").rstrip(";"))
|
||||
try:
|
||||
cid = data["results"][0]["fields"]
|
||||
except Exception as e:
|
||||
print("load fields error info -->", e)
|
||||
return None
|
||||
if cid.get("sync_cover"):
|
||||
return cid["sync_cover"]
|
||||
elif cid.get("cover_list"):
|
||||
return cid["cover_list"][0]
|
||||
return
|
||||
|
||||
def get_all_vids_by_cid(cid):
|
||||
api_url = "http://union.video.qq.com/fcgi-bin/data"
|
||||
params = {
|
||||
|
||||
Reference in New Issue
Block a user