From fc3449e7d950586965007b58d5707446d4daf583 Mon Sep 17 00:00:00 2001
From: ihmily <961532186@qq.com>
Date: Fri, 8 Sep 2023 00:30:45 +0800
Subject: [PATCH] Fix douyin live update and bilibili live record bug
---
README.md | 20 ++++--
api/convert.php | 11 ++--
api/index.php | 51 +++++++++++----
config/URL_config.ini | 3 +-
config/config.ini | 24 +++++--
main.py | 144 ++++++++++++++++++++++++------------------
spider.py | 130 +++++++++++++++++++++++---------------
web_rid.py | 41 ++++++------
8 files changed, 264 insertions(+), 160 deletions(-)
diff --git a/README.md b/README.md
index a82aed94..306b69df 100644
--- a/README.md
+++ b/README.md
@@ -24,10 +24,11 @@
```
.
└── DouyinLiveRecorder/
- ├── /api -> (get live stream api )
+ ├── /api -> (get live stream api )
├── /config -> (config record)
├── /log -> (save runing log file)
├── /backup_config -> (backup file)
+ ├── /libs -> (dll file)
├── main.py -> (main file)
├── spider.py-> (get live url)
├── web_rid.py -> (get web_rid)
@@ -36,6 +37,7 @@
├── x-bogus.js -> (get douyin xbogus token)
├── ffmpeg.exe -> (record video)
├── index.html -> (play m3u8 and flv video)
+ ├── requirements.txt -> (library dependencies)
```
@@ -47,12 +49,13 @@
- 抖音录制需要使用到PC网页端直播间页面的Cookie,请先在config.ini配置文件中添加后再进行抖音录制
- 注意事项① 录制使用到了ffmpeg,如果没有则无法进行录制,请将ffmpeg.exe放置运行文件同个文件夹
- 注意事项② 录制Tiktok时需要使用vpn代理,请先在配置文件中设置开启代理并添加proxy_addr链接
-- 注意事项③ 如果电脑开启了`全局或者规则代理`,可不用添加proxy_addr参数值但仍需在config.ini配置文件中设置开启代理 (最好还是设置一下代理地址,降低出错概率)
+- 注意事项③ 如果电脑开启了`全局或者规则代理`,可不用添加proxy_addr参数值但仍需在config.ini配置文件中设置开启代理 (最好还是设置一下代理地址,否则很容易请求出错)
- 注意事项④ 可以在URL_config.ini中的链接开头加上#,此时将不会录制该条链接对应的直播
- 注意事项⑤ 测试时有可能会出现在IDE如Pycharm中运行代码进行直播录制,录制出来的视频却无法正常播放的现象,如果遇到这个问题 最好在命令控制台DOS界面运行代码,录制出来的视频即可正常播放。
- 可使用 `pyinstaller -D或-F` 将代码打包成exe可执行文件 ,前提是已经安装了`pyinstaller`库
- 当同时在录制多个直播时,最好线程数设置大一些,否则可能出现其中一个直播录制出错。当然设置的过大也没用,要同时考虑自身电脑的配置,如CPU内核数、网络带宽等限制。
- 如果想直接使用打包好的录制软件,进入[Releases](https://github.com/ihmily/DouyinLiveRecorder/releases) 下载最新发布的 zip压缩包即可,可能有些电脑会报毒,直接忽略即可,这是pyinstaller打包的锅。
+- 如果要长时间挂着软件循环监测直播,最好循环时间设置长一点,避免因请求频繁导致被官方封禁IP 。
@@ -83,7 +86,7 @@ B站:
https://live.bilibili.com/320
```
-Tiktok目前只支持PC网页端地址(没下载app),其他平台 app端直播间分享地址和网页端长地址都能正常进行录制(抖音尽量用长链接,避免因短链接转换失效导致不能正常录制)。
+Tiktok目前只支持PC网页端地址(我没下载app),其他平台 app端直播间分享地址和网页端长地址都能正常进行录制(抖音尽量用长链接,避免因短链接转换失效导致不能正常录制)。
@@ -105,7 +108,7 @@ GET https://hmily.vip/api/jx/live/?url=https://live.douyin.com/573716250978
GET https://hmily.vip/api/jx/live/convert.php?url=https://v.douyin.com/iQLgKSj/
```
-在线播放m3u8视频地址:[https://jx.hmily.vip/play/ ](https://jx.hmily.vip/play/)
+在线播放m3u8和flv视频网站:[M3U8 在线视频播放器 ](https://jx.hmily.vip/play/)
@@ -117,11 +120,18 @@ GET https://hmily.vip/api/jx/live/convert.php?url=https://v.douyin.com/iQLgKSj/
## ⏳提交日志
+- 20230907
+ - 修复了因抖音官方更新了版本导致的录制出错以及短链接转换出错
+
+ - 修复B站无法录制原画视频的bug
+
+ - 修改了配置文件字段,新增各平台自定义设置Cookie
+
- 20230903
- 修复了Tiktok录制时报644无法录制的问题
- 新增直播状态推送到钉钉和微信的功能,如有需要请看 [设置推送教程](https://d04vqdiqwr3.feishu.cn/docx/XFPwdDDvfobbzlxhmMYcvouynDh?from=from_copylink)
- 最近比较忙,其他问题有时间再更新
-
+
- 20230816
- 修复斗鱼直播(官方更新了字段)和快手直播录制出错的问题
- 20230814
diff --git a/api/convert.php b/api/convert.php
index f7db1db1..e38d35cf 100644
--- a/api/convert.php
+++ b/api/convert.php
@@ -4,6 +4,7 @@
* Author: Hmily
* Github:https://github.com/ihmily
* Date: 2023-07-20 21:06:20
+ * Update: 2023-09-07 22:34:57
* Copyright (c) 2023 by Hmily, All Rights Reserved.
* Function:convert short url to long url
* Address:https://github.com/ihmily/DouyinLiveRecorder
@@ -20,8 +21,8 @@
$share_url=$_GET['url'];
$get_id=get_redirect_url($share_url);
-preg_match('/reflow\/(.*?)\?u_code/', $get_id, $room_id);
-preg_match('/&sec_user_id=(.*?)&ecom_share_track_params/', $get_id, $sec_user_id);
+preg_match('/reflow\/(.*?)\?/', $get_id, $room_id);
+preg_match('/sec_user_id=([\w\d_\-]+)&/', $get_id, $sec_user_id);
$room_data=get_live_web_rid($room_id[1],$sec_user_id[1]);
$title=$room_data[0];
$web_rid=$room_data[1];
@@ -44,7 +45,7 @@
exit(json_encode($return,448));
-// 抖音X-bogus算法,这里我直接封装成接口进行调用了
+// 抖音X-bogus算法,直接调用我封装的接口
function get_xbogus($url) {
$query = parse_url($url, PHP_URL_QUERY);
$url = "http://43.138.133.177:8890/xbogus";
@@ -115,4 +116,6 @@ function get_redirect_url($url) {
curl_close($curl);
preg_match("/Location: (.*?)\r\n/iU",$ret,$location);
return $location[1];
-}
\ No newline at end of file
+}
+
+
diff --git a/api/index.php b/api/index.php
index c029ab31..643cf724 100644
--- a/api/index.php
+++ b/api/index.php
@@ -4,12 +4,14 @@
* Author: Hmily
* Github:https://github.com/ihmily
* Date: 2023-07-20 21:06:20
- * Update: 2023-08-05 23:35:00
+ * Update: 2023-09-07 23:53:07
* Copyright (c) 2023 by Hmily, All Rights Reserved.
* Function:Spider the live stream url
* Address:https://github.com/ihmily/DouyinLiveRecorder
*/
+
+// 本API代码只有解析抖音、快手和虎牙的,有需要其他的可自己根据源码增加
header('Content-type: application/json; charset=utf-8');
if(empty($_GET['url'])){
@@ -23,7 +25,7 @@
// 判断是否是app端分享链接,如果是则转为PC网页端地址,否则无法解析
// 示例链接:
// $live_url="https://live.douyin.com/187615265444";
- $json_str=get_curl("https://hmily.vip/api/dy/live/convert.php?url=".$live_url);
+ $json_str=get_curl("https://hmily.vip/api/jx/live/convert.php?url=".$live_url);
$json_data=json_decode($json_str,true);
$live_url = $json_data['long_url'];
}
@@ -52,20 +54,37 @@ function get_douyin_json_data($url) {
$cookies='ttwid=1%7CIkooT8SJQrpeYtHlSALuhz9BdcHpaaf9tHQRKHuDaYE%7C1687785070%7C6690250483b63b6482128174d0f93bd879614d76f1b6e03ca52e032cf7fbaafd; passport_csrf_token=52bece134ac246c81163cc93b72f86a6; passport_csrf_token_default=52bece134ac246c81163cc93b72f86a6; d_ticket=2b9e3eb3626216c0122f0d980f867deb7b414; n_mh=hvnJEQ4Q5eiH74-84kTFUyv4VK8xtSrpRZG1AhCeFNI; passport_auth_status=a74f300f376940d65914eb148d55ca96%2C9ca487aea255972120d502f736c5dd7b; passport_auth_status_ss=a74f300f376940d65914eb148d55ca96%2C9ca487aea255972120d502f736c5dd7b; sso_auth_status=52ecac30d95890cc7896c880366aa21a; sso_auth_status_ss=52ecac30d95890cc7896c880366aa21a; LOGIN_STATUS=1; store-region=cn-fj; store-region-src=uid; __security_server_data_status=1; __live_version__=%221.1.1.1853%22; live_can_add_dy_2_desktop=%220%22; xgplayer_user_id=528819598596; msToken=ZfXzPPa_KqQDF9wkHigKqgyUMIt33-qgLl1qqthGsAea4L69i9wxWaGH4GaQ9M_Q-eqhLpnD4v8FRGIj9KGJGIyLmjPkR1uepZ0gBaqhCkqK1KaauPXT_VK_uVgW6q4=; home_can_add_dy_2_desktop=%220%22; strategyABtestKey=%221689685952.92%22; FOLLOW_LIVE_POINT_INFO=%22MS4wLjABAAAAf6aekfyBsc4u8jMkeYbgnkFa0ksIWKWpGOywuyHXyo4%2F1689609600000%2F0%2F1689606316434%2F0%22; FOLLOW_NUMBER_YELLOW_POINT_INFO=%22MS4wLjABAAAAf6aekfyBsc4u8jMkeYbgnkFa0ksIWKWpGOywuyHXyo4%2F1689609600000%2F0%2F0%2F1689594083273%22; FORCE_LOGIN=%7B%22videoConsumedRemainSeconds%22%3A180%7D; volume_info=%7B%22isUserMute%22%3Afalse%2C%22isMute%22%3Atrue%2C%22volume%22%3A0.6%7D; device_web_cpu_core=8; device_web_memory_size=-1; webcast_local_quality=origin; csrf_session_id=0446f50cc7e08f146ad07351af90f413; __ac_nonce=064be522600a12daa29ff; __ac_signature=_02B4Z6wo00f0145FB4AAAIDCkga5P5okFMuOdAMAAIc3h1Lmbu.WZmNdgawlJBkHRSAf1yndkZFgF.zN2OHlE62.f.4ZFt740eSkTrQW8j3EM2s9s3vtK9LGh-h9jhUkgSbj4UOtYTqpCZZc88; webcast_leading_last_show_time=1690194481638; webcast_leading_total_show_times=1; odin_tt=6ebbe0a3c1b4e5bc6d333c5c7514fc88a288b3b03b1f0cf34826dee5d6d6394620f17fd4eb624b710954233f38fa3c67fd4a5338bffaa792a2cf71d1b51d837f079925497d6b372f47a577d779036a71; msToken=uHqyINCG79-ojuC5cXU6tYm0Av3BqNzqLkFGvbNw5QmSCtFY7xYHJjJ3wu-gk2Evj5QQ7D6UMsz2inlRN-aZf8xTGMAnpmgieOrygPqoK7QboFwCXR7aLi4KKcFXvFu2; tt_scid=BVvDLf3XEG4PZlY2-haad4.kR2BYWdq4X88b6-sPA2Wpg2lsSDI5M7YuZ7H-GPf.6646';
$html_str = get_curl($url,$headers,$cookies);
- preg_match('/