本帖最后由 话痨司机啊 于 2022-8-24 00:49 编辑
弹幕成品下载:https://pan.baidu.com/s/1u5BDo0_56Vzc7KksY1ezcQ?pwd=2h7u 提取码: 2h7u
omofun视频下载:【双击运行】 omofun 动漫下载器(成品) - 『编程语言区』 - 吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn
omofun视频下载源码:omofun 动漫下载 - 『编程语言区』 - 吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn
使用说明:在omofun_address.txt填入视频播放地址自动下载
弹幕内容 效果图:
源码:
[Python] 纯文本查看 复制代码 import json
import urllib.parse
from pathlib import Path
import requests
from lxml import etree
def barrageAnalysis(url):
'''解析弹幕获取弹幕数据'''
danmu_url = lambda params:f'https://omofun.tv/index.php/danmu?ac=dm&id={params}'
list_path = urllib.parse.urlparse(url).path.split('/')
ids = list_path.index('id')
sid = list_path.index('sid')
res = requests.get(danmu_url(list_path[ids+1]+list_path[sid+1]))
return res.json()
def title_filter(title: str):
"""
转为Windows合法文件名
"""
lst = ['\r', '\n', '\\', '/', ':', '*', '?', '"', '<', '>', '|']
for key in lst:
title = title.replace(key, '-')
if len(title) > 60:
title = title[:60]
return title.strip()
def getTitle(url):
'''获取标题'''
res = requests.get(url)
title = etree.HTML(res.text).xpath('//title/text()')[0]
return title
def save_bulletChat(data,title):
"""保存弹幕数据"""
with open(Path('.').joinpath(f'{title_filter(title)}_弹幕.json'),
'w',
encoding='utf-8-sig') as f:
json.dump(data, f,ensure_ascii=False)
def main(url):
'''主逻辑'''
data = barrageAnalysis(url)
title = getTitle(url)
save_bulletChat(data,title)
if __name__=='__main__':
with open(Path('.').joinpath("omofun_address.txt"),'r',encoding='utf8') as f:
urls = f.readlines()
for url in urls:
main(url)
|