吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 4993|回复: 12
收起左侧

[Python 转载] omofun 弹幕下载

 关闭 [复制链接]
话痨司机啊 发表于 2022-8-24 00:44
本帖最后由 话痨司机啊 于 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填入视频播放地址自动下载
弹幕内容 效果图:
弹幕1.jpg

源码:
[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)


免费评分

参与人数 2吾爱币 +4 热心值 +2 收起 理由
Supermexyh + 3 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!
为之奈何? + 1 + 1 我很赞同!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

lzqhyzz 发表于 2022-8-24 06:27
好东西,赞一个
whg118 发表于 2022-8-24 06:38
txzs123 发表于 2022-8-24 06:58
Supermexyh 发表于 2022-8-24 08:01
感谢分享
CZNemo 发表于 2022-8-24 09:00
感谢分享
lebra2022 发表于 2022-8-24 09:15
感谢分享
oohchanbaek61 发表于 2022-8-24 09:36
感谢分享
jimmy007 发表于 2022-8-24 09:40
感谢楼主分享的好东西,有时候觉得弹幕比视频有意思哈哈
1047504736 发表于 2022-8-24 14:49
感谢分享
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-4-28 22:15

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表