mirror of
https://github.com/saveweb/biliarchiver.git
synced 2024-09-19 11:05:28 -07:00
*如果 hevc dash 资源实际上不可用,fallback 到 avc
*下载视频前清空本地下载缓存以防意外 *上传 IA 前先检查一下最重要的视频文件存不存在…… bump 0.0.15
This commit is contained in:
parent
20ecf9e1eb
commit
d7753c0312
@ -81,9 +81,10 @@ def _upload_bvid(bvid: str):
|
||||
if os.path.basename(file).startswith('_'):
|
||||
continue
|
||||
if not os.path.isfile(file):
|
||||
continue
|
||||
continue
|
||||
filedict[filename] = file
|
||||
|
||||
|
||||
assert f'{file_basename}.mp4' in filedict
|
||||
|
||||
# IA 去重
|
||||
for file_in_item in item.files:
|
||||
|
@ -73,6 +73,15 @@ async def archive_bvid(d: DownloaderBilibili, bvid: str, logined: bool=False):
|
||||
print(f'{file_basename}: 已经下载过了')
|
||||
continue
|
||||
|
||||
def delete_cache(reason: str = ''):
|
||||
if not os.path.exists(video_basepath):
|
||||
return
|
||||
_files_in_video_basepath = os.listdir(video_basepath)
|
||||
for _file in _files_in_video_basepath:
|
||||
if _file.startswith(file_basename):
|
||||
print(f'{file_basename}: {reason},删除缓存: {_file}')
|
||||
os.remove(video_basepath / _file)
|
||||
delete_cache('为防出错,清空上次未完成的下载缓存')
|
||||
video_info = await api.get_video_info(d.client, page.p_url)
|
||||
print(f'{file_basename}: {video_info.title}...')
|
||||
os.makedirs(video_basepath, exist_ok=True)
|
||||
@ -127,6 +136,31 @@ async def archive_bvid(d: DownloaderBilibili, bvid: str, logined: bool=False):
|
||||
cor3 = download_bilibili_video_detail(d.client, bvid, f'{video_extrapath}/{file_basename}.info.json')
|
||||
await asyncio.gather(cor1, cor2, cor3)
|
||||
|
||||
if codec.startswith('hev') and not os.path.exists(video_basepath / f'{file_basename}.mp4'):
|
||||
|
||||
# 如果有下载缓存文件(以 file_basename 开头的文件),说明这个 hevc 的 dash 资源存在,只是可能因为网络之类的原因下载中途失败了
|
||||
delete_cache('下载出错')
|
||||
|
||||
# 下载缓存文件都不存在,应该是对应的 dash 资源根本就没有,一些老视频会出现这种情况。
|
||||
# 换 avc 编码
|
||||
print(f'{file_basename}: 视频文件没有被下载?也许是 hevc 对应的 dash 资源不存在,尝试 avc ……')
|
||||
for media in video_info.dash.videos:
|
||||
if media.codec.startswith('avc'):
|
||||
codec = media.codec
|
||||
print(f'{file_basename}: "{codec}" "{media.quality}" ...')
|
||||
break
|
||||
cor4 = d.get_video(page.p_url ,video_info=video_info, path=video_basepath,
|
||||
quality=0, # 选择最高画质
|
||||
codec=codec, # 编码
|
||||
# 下载 ass 弹幕(bilix 会自动调用 danmukuC 将 pb 弹幕转为 ass)、封面、字幕
|
||||
# 弹幕、封面、字幕都会被放进 extra 子目录里,所以需要 d.hierarchy is True
|
||||
dm=True, image=True, subtitle=True
|
||||
)
|
||||
await asyncio.gather(cor4)
|
||||
|
||||
|
||||
assert os.path.exists(video_basepath / f'{file_basename}.mp4')
|
||||
|
||||
# 还原为了自定义文件名而做的覆盖
|
||||
video_info.pages[video_info.p].p_name = old_p_name
|
||||
video_info.h1_title = old_h1_title
|
||||
|
@ -1 +1 @@
|
||||
BILI_ARCHIVER_VERSION = '0.0.14'
|
||||
BILI_ARCHIVER_VERSION = '0.0.15'
|
@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "biliarchiver"
|
||||
version = "0.0.14"
|
||||
version = "0.0.15"
|
||||
description = ""
|
||||
authors = ["yzqzss <yzqzss@yandex.com>"]
|
||||
readme = "README.md"
|
||||
|
Loading…
Reference in New Issue
Block a user