一系列功能 (#333)

* Add files via upload

* 版本升级

* 修复上一版本由于新增的哔哩哔哩登录Cookie导致报错的问题。

* 修复Twitch的Clips无法下载的问题。

* 为YouTube视频下载增加指定封装格式,最大纵向分辨率,最大单视频大小的设置。

* 更新config关于新功能的设置

* Update biliup/plugins/bilibili.py

Co-authored-by: ForgQi <34411314+ForgQi@users.noreply.github.com>

---------

Co-authored-by: ForgQi <34411314+ForgQi@users.noreply.github.com>
This commit is contained in:
haha114514andForgQi authored and GitHub committed 2023-02-14 15:05:21 +00:00
1 parent bd490df262
commit 2002ad45c5
7 files changed
+84 -23

No files matched your search

+14
View File
@@ -4,14 +4,27 @@
- 💡新添加的功能
- 🔧已修复的问题
- ⚠️需要手动操作的更新信息
## 0.4.2
- 更新时间:2023.02.15
- 💡为YouTube视频下载增加指定封装格式,最大纵向分辨率,最大单视频大小的设置。 [@haha114514](https://github.com/haha114514)
- ⚠️上一条由于为Config新增了一些设置,如需使用相关功能请参考最新的config示例添加缺失的部分。
- 🔧修复上一版本由于新增的哔哩哔哩登录Cookie导致报错的问题。 [@haha114514](https://github.com/haha114514)
- 🔧修复Twitch的Clips无法下载的问题。 [@haha114514](https://github.com/haha114514)
- 🔧为上一版本的B站Fallback机制启用开关。[@haha114514](https://github.com/haha114514)
- ⚠️上一条由于为Config新增了一些设置,如需使用相关功能请参考最新的config示例添加缺失的部分。
## 0.4.1
- 更新时间:2023.02.13
- 💡增加Preprocessor功能,支持开始录制时执行指定Shell指令 [@haha114514](https://github.com/haha114514)
- 💡为上传标题与简介增加streamers变量 [@haha114514](https://github.com/haha114514)
- ⚠️上两条由于为Config新增了一些设置,如需使用相关功能请参考最新的config示例添加缺失的部分。
- 🔧修复访问acfun过于频繁导致ip被拉黑之后报错卡住的问题 [@haha114514](https://github.com/haha114514)
- 🔧修复嵌入示例中延后发布时间的错误 [@stevenlele](https://github.com/setvenlele)
- 🔧修复twitch_cookie配置不生效问题 [@v2wy](https://github.com/v2wy)
- 🔧尝试为B站直播录制启用Fallback机制,当指定CDN反复无法下载之后,自动尝试另外的CDN [@xxxxuanran](https://github.com/xxxxuanran)
- 🔧增加Cookie登录B站功能,可用于下载付费直播与大航海专属直播 [@xxxxuanran](https://github.com/xxxxuanran)
- ⚠️上一条由于为Config新增了一些设置,如需使用相关功能请参考最新的config示例添加缺失的部分。
## 0.4.0
- 更新时间:2023.02.10
@@ -25,6 +38,7 @@
- 🔧修复ffmpeg录制参数缺失.part后缀,导致录制出来的文件都没有.part后缀的问题 [@haha114514](https://github.com/haha114514)
- 🔧修复了ffmpeg录制情况下,按大小分段录制时,分段之后上一段的.part后缀不会被去掉的问题 [@haha114514](https://github.com/haha114514)
- 🔧完善config示例,增加postprocessor可参考用法的描述 [@haha114514](https://github.com/haha114514)
- ⚠️上一条由于为Config新增了一些设置,如需使用相关功能请参考最新的config示例添加缺失的部分。
## 0.3.11
- 更新时间:2023.02.02
+1 -1
View File
@@ -1,7 +1,7 @@
import logging
import sys
__version__ = "0.4.1"
__version__ = "0.4.2"
LOG_CONF = {
'version': 1,
+18 -15
View File
@@ -12,8 +12,10 @@ class Bilibili(DownloadBase):
def __init__(self, fname, url, suffix='flv'):
super().__init__(fname, url, suffix)
self.fake_headers['Referer'] = 'https://live.bilibili.com'
self.fake_headers['cookie'] = config.get('user', {}).get('bili_cookie')
if config.get('user', {}).get('bili_cookie'):
self.fake_headers['cookie'] = config.get('user', {}).get('bili_cookie')
self.customAPI_use_cookie = config.get('user', {}).get('customAPI_use_cookie', False)
self.bili_cdn_fallback = config.get('bili_cdn_fallback', True)
def check_stream(self):
# 预读配置
@@ -34,7 +36,7 @@ class Bilibili(DownloadBase):
forceScoure = config.get('bili_forceScoure', False)
customApiHost = (lambda a : a if a.startswith(('http://', 'https://')) else 'http://'+a)(config.get('bili_liveapi', officialApiHost).rstrip('/'))
s = requests.Session()
s.headers = self.fake_headers
s.headers = self.fake_headers.copy()
with s:
# 获取直播状态与房间标题
@@ -81,18 +83,19 @@ class Bilibili(DownloadBase):
stream_info['base_url'] = re.sub(r'\_bluray(?=.*m3u8)', "", stream_info['base_url'])
self.raw_stream_url = url_info['host']+stream_info['base_url']+url_info['extra']
index = 0
if self.bili_cdn_fallback is True:
# 检查直播流是否可用
while s.head(self.raw_stream_url, stream=True).status_code == 404:
# 以倒序尝试回退
if stream_info['url_info'][index]['host'] in self.raw_stream_url:
index-=1
try:
url_info = stream_info['url_info'][index]
self.raw_stream_url = url_info['host']+stream_info['base_url']+url_info['extra']
except Exception:
self.raw_stream_url = None
# 如当前协议无可用直播流,回退到 flv 的首个链接
if not self.raw_stream_url:
stream_info = streams[0]['format'][0]['codec'][0]
self.raw_stream_url = stream_info['url_info'][0]['host']+stream_info['base_url']+stream_info['url_info'][0]['extra']
while s.head(self.raw_stream_url, stream=True).status_code == 404:
# 以顺序尝试回退
if stream_info['url_info'][index]['host'] in self.raw_stream_url:
index+=1
try:
url_info = stream_info['url_info'][index]
self.raw_stream_url = url_info['host']+stream_info['base_url']+url_info['extra']
except Exception:
self.raw_stream_url = None
# 如当前协议无可用直播流,回退到 flv 的首个链接
if not self.raw_stream_url:
stream_info = streams[0]['format'][0]['codec'][0]
self.raw_stream_url = stream_info['url_info'][0]['host']+stream_info['base_url']+stream_info['url_info'][0]['extra']
return True
+1 -1
View File
@@ -24,7 +24,7 @@ _OPERATION_HASHES = {
_CLIENT_ID = 'kimne78kx3ncx6brgo4mv6wki5h1ko'
@Plugin.download(regexp=r'https?://(?:(?:www|go|m)\.)?twitch\.tv/(?P<id>[^/]+)/(?:videos|profile)')
@Plugin.download(regexp=r'https?://(?:(?:www|go|m)\.)?twitch\.tv/(?P<id>[^/]+)/(?:videos|profile|clips)')
class TwitchVideos(DownloadBase):
def __init__(self, fname, url, suffix='mp4'):
DownloadBase.__init__(self, fname, url, suffix=suffix)
+12 -1
View File
@@ -8,12 +8,20 @@ from . import logger
VALID_URL_BASE = r'https?://(?:(?:www|m)\.)?youtube\.com/(?P<id>.*?)\??(.*?)'
format_dict = {
"webm": ("webm", "webm"),
"mkv": ("webm", "m4a"),
"mp4": ("mp4", "m4a")
}
@Plugin.download(regexp=VALID_URL_BASE)
class Youtube(DownloadBase):
def __init__(self, fname, url, suffix='webm'):
DownloadBase.__init__(self, fname, url, suffix=suffix)
self.cookiejarFile = config.get('user', {}).get('youtube_cookie')
self.youtube_format = config.get('youtube_prefer_format','webm')
self.resolution = config.get('youtube_max_resolution','4320')
self.filesize = config.get('youtube_max_videosize','100G')
def check_stream(self):
with yt_dlp.YoutubeDL({'download_archive': 'archive.txt', 'ignoreerrors': True, 'extract_flat': True,
@@ -47,9 +55,11 @@ class Youtube(DownloadBase):
return True
def download(self, filename):
video_format, audio_format = format_dict.get(self.youtube_format)
try:
ydl_opts = {
'outtmpl': filename,
'outtmpl': filename+ '.%(ext)s',
'format': f'bestvideo[ext={video_format}][height<={self.resolution}][filesize<{self.filesize}]+bestaudio[ext={audio_format}]/best[height<={self.resolution}]/best',
'cookiefile': self.cookiejarFile,
# 'proxy': proxyUrl,
'ignoreerrors': True,
@@ -64,3 +74,4 @@ class Youtube(DownloadBase):
logger.exception(self.fname)
return 1
return 0
+16
View File
@@ -26,6 +26,8 @@ filtering_threshold = 20 # 小于此大小的视频文件将会被过滤删除
#bili_forceScoure = false
# 自定义哔哩哔哩直播api
#bili_liveapi = "https://api.live.bilibili.com"
# CDN自动Fallback开关,默认为开启
#bili_cdn_fallback = true
# 检测到主播下播后延迟再次检测,单位:秒,避免特殊情况提早启动上传导致漏录
delay = 10
# 检测间隔时间,单位:秒
@@ -38,6 +40,20 @@ pool1_size = 3
pool2_size = 3
# 检测源码文件变化间隔,单位:秒,检测源码到变化后,程序会在空闲时自动重启
check_sourcecode = 15
#------YouTube------#
### 设置偏好的YouTube下载封装格式
### 请务必记得安装ffmpeg
### 其中mp4封装为h264视频编码+aac音频编码,一般最高可以下载到1080p的版本;
### mkv封装为vp9/av1视频编码+aac音频编码,视频部分最高可以下载到8k,音频采样率最高44.1khz
### webm封装为vp9/av1视频编码+opus音频编码,一般opus版本音质最高。
#youtube_prefer_format = "webm" ### 支持mkv, webm, mp4 3种封装后缀。
### 设置偏好的YouTube下载最高纵向分辨率
### 最高纵向分辨率,也就是xxxxP.如果youtube_prefer_format指定为mp4,将最高只能下载1080p的视频。
#youtube_max_resolution = "440"
### 限制单个视频的最大大小。
### 注意:此参数优先级高于分辨率设置,并且不包括音频部分的大小,仅仅只是视频部分的大小。
### 如果某个视频实在没有低于此大小的分辨率版本,将会选择最低画质的版本下载。
#youtube_max_videosize = "5G" ###参考格式,例如100M,5G,10G。
[user]
# 如需要录制抖音请在此填入cookie需要__ac_nonce与__ac_signature的值
+22 -5
View File
@@ -49,14 +49,31 @@ check_sourcecode: 15
#huyacdn: AL
#------哔哩哔哩------#
### 哔哩哔哩直播流协议.可选 stream(Flv)、hls
### 哔哩哔哩直播流协议.可选 stream(Flv)、hls,默认为stream
#bili_protocol: stream
### 哔哩哔哩直播优选CDN
### 哔哩哔哩直播优选CDN,默认无
#bili_perfCDN: cn-gotcha01
### 哔哩哔哩直播强制原画(仅限HLS流的 cn-gotcha01 CDN)
#bili_forceScoure: False
### 自定义哔哩哔哩直播api
### 哔哩哔哩直播强制原画(仅限HLS流的 cn-gotcha01 CDN),默认为关闭
#bili_forceScoure: false
### 自定义哔哩哔哩直播api,默认无
#bili_liveapi: 'https://api.live.bilibili.com'
### CDN自动Fallback开关,默认为开启
#bili_cdn_fallback: true
#------YouTube------#
### 设置偏好的YouTube下载封装格式
### 请务必记得安装ffmpeg
### 其中mp4封装为h264视频编码+aac音频编码,一般最高可以下载到1080p的版本;
### mkv封装为vp9/av1视频编码+aac音频编码,视频部分最高可以下载到8k,音频采样率最高44.1khz
### webm封装为vp9/av1视频编码+opus音频编码,一般opus版本音质最高。
#youtube_prefer_format: "webm" ### 支持mkv, webm, mp4 3种封装后缀。
### 设置偏好的YouTube下载最高纵向分辨率
### 最高纵向分辨率,也就是xxxxP.如果youtube_prefer_format指定为mp4,将最高只能下载1080p的视频。
#youtube_max_resolution: 1440
### 限制单个视频的最大大小。
### 注意:此参数优先级高于分辨率设置,并且不包括音频部分的大小,仅仅只是视频部分的大小。
### 如果某个视频实在没有低于此大小的分辨率版本,将会选择最低画质的版本下载。
#youtube_max_videosize: "5G" ###参考格式,例如100M,5G,10G。
#########录制主播设置#########
streamers: