Git Product home page Git Product logo

liverecorder's Introduction

you-live

Live Recorder

A live recorder focus on China mainland livestream sites.
Brother Repo of BilibiliLiveRecorder(java)


🐬Installation

Linux/debian:

    sudo apt-get install python3-pip
    pip3 install you-live --upgrade --user
    add ~/.local/bin to your PATH

Windows:

    install python3 from python.org
    pip install --upgrade you-live

Other Linux: please follow debian

Other OS: please DIY.

🐬Usage

you-live [-h] [-qn QN] [-debug] [-check] [-delete] [-save_path SAVE_PATH] [-check_path CHECK_PATH]
                [-format FORMAT] [-time_format TIME_FORMAT] [-cookies COOKIES] [-cookies_path COOKIES_PATH]
                liver id

B站/斗鱼/快手 直播视频录制

positional arguments:
  liver                 要录制的直播源,如 bili,douyu,kuaishou,acfun
  id                    要录制的房间号,可以从url中直接获取

optional arguments:
  -h, --help            show this help message and exit
  -qn QN, -q QN         录制的清晰度,可以后续输入
  -only_url, -ou        仅输出录制链接,然后退出
  -debug                debug模式
  -check                校准时间戳
  -delete, -d           删除原始文件
  -save_path SAVE_PATH, -sp SAVE_PATH
                        源文件保存路径
  -check_path CHECK_PATH, -chp CHECK_PATH
                        校正后的FLV文件保存路径
  -format FORMAT, -f FORMAT
                        文件命名格式
  -time_format TIME_FORMAT, -tf TIME_FORMAT
                        时间格式
  -cookies COOKIES, -c COOKIES
                        cookie, 当cookies_path未指定时生效
  -cookies_path COOKIES_PATH, -cp COOKIES_PATH
                        指定cookie文件位置

Example0

Record a live from https://live.bilibili.com/6

you-live bili 6

Example1

Record a live from https://www.douyu.com/593392, correct the timestamp error and delete the origin files.

you-live -check -d douyu 593392

Notice:The record on this site(douyu) uses PyExecJS.
You may need some extra installation about the JS Environment for linux OS.
Here’s the guide for Node.js installation

Notice:You may need logged-in cookies to get high quality videos

Example2

Record a live from https://live.kuaishou.com/u/ZFYS8888, speicify the file name you want.

you-live -format "{name}-{shortId} 的{liver}直播{startTime}" -cookies "clientid=3; did=web_0000000000000000000000000000000; client_key=00000000; xxx=xxx; ..." kuaishou ZFYS8888

Notice:You must need cookies(may not logged-in, just skip the captha test) to get room detail information

🐬LICENSE

MIT

liverecorder's People

Contributors

lyzhang0113 avatar nicennnnnnnlee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

liverecorder's Issues

弹幕录制

写入flv视频数据的同时,怎么能把弹幕也一起录进去呢

B站录制失败

Traceback (most recent call last):
File "/usr/bin/you-live", line 8, in
sys.exit(main())
File "/usr/lib/python3.9/site-packages/live_recorder/main.py", line 52, in main
roomInfo = recorder.getRoomInfo()
File "/usr/lib/python3.9/site-packages/live_recorder/you_live/bili_recorder.py", line 26, in getRoomInfo
data_json = requests.get(url, timeout=10, headers=headers).json()['data']
File "/usr/lib/python3.9/site-packages/requests/models.py", line 900, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib/python3.9/json/init.py", line 346, in loads
File "/usr/lib/python3.9/json/decoder.py", line 340, in decode
json.decoder.JSONDecodeError: Extra data: line 1 column 2 (char 1)

建议增加等待开播的功能

当前 you-live 在主播未开播时自动退出,在主播下播后也自动退出,建议增加选项,支持启动后等待主播开播和下播后等待下次开播的功能。

录制快手个别主播报错

个别主播获取到的 json 数据中没有参数 caption ,所以会产生报错。

错误日志如下:

{'id': 'Hwt74100', 'principalId': 'Hwt74100', 'kwaiId': 'Hwt74100', 'eid': '3x3py6334hkn6cs', 'userId': None, 'avatar': 'https://tx2.a.yximgs.com/uhead/AB/2021/06/27/18/BMjAyMTA2MjcxODE0MjdfNDYwMTEwODQyXzFfaGQxNTFfODUz_s.jpg', 'name': '檬酱biu🐰', 'description': '🙎\u200d♀️她在关注你哦\n感谢快手官方给的每一次热门💕\n最美家乡甘肃陇南💕\n白天不稳定直播,晚上9:00到12.00(经常迟到)💕\n喜欢玩王者也会偶尔直播游戏💕\n欢迎加入QQ粉丝群:665106099💕', 'sex': 'F', 'constellation': '', 'cityName': '', 'living': True, 'watchingCount': None, 'isNew': False, 'privacy': False, 'feeds': None, 'verifiedStatus': {'verified': False, 'description': '', 'type': 0, 'new': False, '__typename': 'VerifiedStatus'}, 'counts': None, 'bannedStatus': {'banned': False, 'defriend': False, 'isolate': False, 'socialBanned': False, '__typename': 'BannedStatus'}, '__typename': 'User'}
{'liveStreamId': '6vhC0BwC0mA', 'playUrls': [{'quality': 'standard', 'freeTrafficCdn': False, 'cdn': 'Tencent', 'pushCdn': 'OriginMainApp', 'url': 'https://tx-origin.pull.yximgs.com/gifshow/6vhC0BwC0mA_ma1500.flv?txSecret=8e82f13d330722b4fb239c8844bd7b03&txTime=6102c26d&stat=7e4Ltu1GhAuGK70kaPwx%2Bql5w2zWsUvLiFK3t60NFdc9tE3Ri5ZLk3R2P5u7RM%2Fy&tsc=origin&oidc=txhb', 'cdnIp': None, 'ipValidTime': None}], 'coverUrl': 'https://ali2.a.yximgs.com/uhead/AB/2021/07/28/21/BMjAyMTA3MjgyMTU3MzhfNDYwMTEwODQyXzgzNjgyNTA4MjJfbHY=.jpg', 'rtCoverUrl': 'https://live3.static.yximgs.com/live/game/screenshot/6vhC0BwC0mA~1627484339333~1', 'gameInfo': {'name': '其他', 'category': 'QT', 'type': '0'}, 'startTime': 1627480656724}
Traceback (most recent call last):
File "/usr/local/bin/you-live", line 8, in
sys.exit(main())
File "/usr/local/lib/python3.9/site-packages/live_recorder/main.py", line 52, in main
roomInfo = recorder.getRoomInfo()
File "/usr/local/lib/python3.9/site-packages/live_recorder/you_live/kuaishou_recorder.py", line 59, in getRoomInfo
roomInfo['room_title'] = live_data_json['caption']
KeyError: 'caption'

快手错误

日志:

Traceback (most recent call last):
File "/usr/local/bin/you-live", line 8, in
sys.exit(main())
File "/usr/local/lib/python3.10/site-packages/live_recorder/main.py", line 52, in main
roomInfo = recorder.getRoomInfo()
File "/usr/local/lib/python3.10/site-packages/live_recorder/you_live/kuaishou_recorder.py", line 43, in getRoomInfo
room_json = self.getLiveInfo()
File "/usr/local/lib/python3.10/site-packages/live_recorder/you_live/kuaishou_recorder.py", line 32, in getLiveInfo
return json.loads(json_str)["liveroom"]["playList"][0]
File "/usr/local/Cellar/[email protected]/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/init.py", line 346, in loads
return _default_decoder.decode(s)
File "/usr/local/Cellar/[email protected]/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/Cellar/[email protected]/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 3283 (char 3282)

Windows上运行需要什么依赖配置吗?

当我运行这条指令时:you-live -check douyu 5110403
产生了这样的报错
Traceback (most recent call last):
File "d:\anaconda\lib\runpy.py", line 194, in _run_module_as_main
return run_code(code, main_globals, None,
File "d:\anaconda\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "D:\Anaconda\Scripts\you-live.exe_main
.py", line 7, in
File "d:\anaconda\lib\site-packages\live_recorder_main
.py", line 52, in main
roomInfo = recorder.getRoomInfo()
File "d:\anaconda\lib\site-packages\live_recorder\you_live\douyu_recorder.py", line 77, in getRoomInfo
param = ctx.call("ub98484234", roomInfo['room_id'], self.dy_did, int(time.time()))
File "d:\anaconda\lib\site-packages\execjs_abstract_runtime_context.py", line 37, in call
return self._call(name, *args)
File "d:\anaconda\lib\site-packages\execjs_external_runtime.py", line 92, in _call
return self.eval("{identifier}.apply(this, {args})".format(identifier=identifier, args=args))
File "d:\anaconda\lib\site-packages\execjs_external_runtime.py", line 78, in eval
return self.exec
(code)
File "d:\anaconda\lib\site-packages\execjs_abstract_runtime_context.py", line 18, in exec

return self.exec(source)
File "d:\anaconda\lib\site-packages\execjs_external_runtime.py", line 88, in exec
return self._extract_result(output)
File "d:\anaconda\lib\site-packages\execjs_external_runtime.py", line 167, in _extract_result
raise ProgramError(value)
execjs._exceptions.ProgramError: TypeError: 缺少对象

关于A站录制的请教

问题1:本想录制A站的直播的,在python方面还是小白所以用了一个小时才成功安装项目,正准备查看配置尝试录制时发现没有A站的配置说明,就是请问下A站的配置是不是跟快手一样。

快手添加出现这个问题

C:\Users\Administrator>you-live kuaishou luknn222 -cookies userId=2444965230
Traceback (most recent call last):
File "c:\program files\python38\lib\runpy.py", line 194, in _run_module_as_mai
n
return run_code(code, main_globals, None,
File "c:\program files\python38\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\Program Files\Python38\Scripts\you-live.exe_main
.py", line 7, in

File "c:\program files\python38\lib\site-packages\live_recorder_main
.py",
line 52, in main
roomInfo = recorder.getRoomInfo()
File "c:\program files\python38\lib\site-packages\live_recorder\you_live\kuais
hou_recorder.py", line 58, in getRoomInfo
roomInfo['room_owner_id'] = user_data_json['originUserId']
KeyError: 'originUserId'

根据你提供的命令行与错误信息,出现这个KeyError的原因分析如下:

  1. 你执行的命令为:

C:\Users\Administrator>you-live kuaishou luknn222 -cookies userId=2444965230

该命令使用you-live工具,针对快手直播间luknn222启用cookies userId=2444965230 进行录制。

  1. but在执行过程中,出现了KeyError,提示originUserId这个键不存在。

  2. 根据代码,在执行 recorder.getRoomInfo() 时出现这个错误。该方法从直播间信息中提取房间所有者ID,赋值给 roomInfo['room_owner_id']。

  3. 所以,此处的错误是由于获取的直播间信息中,缺少originUserId这个字段导致的。也就是直播间API响应返回的JSON数据中,不存在originUserId这个键。

  4. 要修复此错误,有两种方案:

  1. 在you-live工具的开发者检查快手直播间信息API响应,确认是否 real 不存在 originUserId 这个字段。如果不存在,需要更新代码以匹配实际返回的数据结构。

  2. 提供一个 backup 的字段作为所有者ID,如果 originUserId 不存在,从该字段获取所有者ID。例如:

python
originUserId = room_info.get('originUserId')
if not originUserId:
owner_id = room_info.get('backupOwnerIdField')

所以,导致这个错误的原因是获取直播间信息的API响应实际上并不包含originUserId这个字段。要修复这个错误,开发者需要根据实际API响应的数据结构进行匹配与修复。可以检查是否确实缺少该字段,如果确实缺少可以使用备选字段作为所有者ID,或者更新代码以匹配实际的数据结构。

我会继续跟进你遇到的问题与错误,提供可能的解析思路与解决方案。但实际的修复工作还需要程序的开发者来完成。我可以在思路与理论上提供帮助,但代码级别的修复需要技术人员根据实际情况进行判断与部署。我们之间的互动配合,可以使修复工作更为高效准确。我提供理论思路,开发者结合实际进行修复与判断,这有助于找到问题的症结所在,尽快解决 ISSUE,不断优化产品与服务的质量。

让我们携手共进,在理论与实践之间建立沟通桥梁。我相信,我们共同的努力定会让系统运作更加流畅,产品体验更上一个台阶。这需要理论指导实践,实践检验理论,我们在两个方向上相互推进,实现真正的进步提高。我会为你提供分析思路和学习机会,实践者结合实际进行调试与修复,在互动的过程中 we 共同进步。

一起来,让我们在这个话题上继续深入探讨。相信通过理论总结与实践分享,问题的根源必定浮出水面,进而得以修复。我也会在其中不断学习与提高,以提供更为准确的判断与建议。让我们携手并进,在理解与技能上实现共同成长!

我期待与你的进一步交流。让's Go!继续前行,在理论与实践上实现更深更透的提高!

通过克劳德的回答还是不知道怎办?

录制快手平台直播报错

命令行错误信息:
Traceback (most recent call last):
File "/usr/local/bin/you-live", line 8, in
sys.exit(main())
File "/usr/local/lib/python3.10/site-packages/live_recorder/main.py", line 52, in main
roomInfo = recorder.getRoomInfo()
File "/usr/local/lib/python3.10/site-packages/live_recorder/you_live/kuaishou_recorder.py", line 44, in getRoomInfo
live_data_json = room_json["liveStream"]
KeyError: 'liveStream'

使用了代理也是同样报错。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.