mirror of
https://github.com/amtoaer/bili-sync.git
synced 2026-09-08 17:09:14 +08:00
fix: 修复无音频流视频下载失败的问题
This commit is contained in:
+14
-13
@@ -1,5 +1,6 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import datetime
|
import datetime
|
||||||
|
import itertools
|
||||||
from asyncio import Semaphore, create_subprocess_exec
|
from asyncio import Semaphore, create_subprocess_exec
|
||||||
from asyncio.subprocess import DEVNULL
|
from asyncio.subprocess import DEVNULL
|
||||||
|
|
||||||
@@ -293,33 +294,33 @@ async def process_favorite_item(
|
|||||||
process = await create_subprocess_exec(
|
process = await create_subprocess_exec(
|
||||||
FFMPEG_COMMAND,
|
FFMPEG_COMMAND,
|
||||||
"-i",
|
"-i",
|
||||||
str(fav_item.tmp_video_path),
|
fav_item.tmp_video_path,
|
||||||
str(fav_item.video_path),
|
fav_item.video_path,
|
||||||
stdout=DEVNULL,
|
stdout=DEVNULL,
|
||||||
stderr=DEVNULL,
|
stderr=DEVNULL,
|
||||||
)
|
)
|
||||||
await process.communicate()
|
await process.communicate()
|
||||||
fav_item.tmp_video_path.unlink()
|
fav_item.tmp_video_path.unlink()
|
||||||
else:
|
else:
|
||||||
await asyncio.gather(
|
paths, tasks = [fav_item.tmp_video_path], [
|
||||||
download_content(streams[0].url, fav_item.tmp_video_path),
|
download_content(streams[0].url, fav_item.tmp_video_path)
|
||||||
download_content(streams[1].url, fav_item.tmp_audio_path),
|
]
|
||||||
)
|
if streams[1]:
|
||||||
|
paths.append(fav_item.tmp_audio_path)
|
||||||
|
tasks.append(download_content(streams[1].url, fav_item.tmp_audio_path))
|
||||||
|
await asyncio.gather(*tasks)
|
||||||
process = await create_subprocess_exec(
|
process = await create_subprocess_exec(
|
||||||
FFMPEG_COMMAND,
|
FFMPEG_COMMAND,
|
||||||
"-i",
|
*list(itertools.chain(*zip(["-i"] * len(paths), paths))),
|
||||||
str(fav_item.tmp_video_path),
|
|
||||||
"-i",
|
|
||||||
str(fav_item.tmp_audio_path),
|
|
||||||
"-c",
|
"-c",
|
||||||
"copy",
|
"copy",
|
||||||
str(fav_item.video_path),
|
fav_item.video_path,
|
||||||
stdout=DEVNULL,
|
stdout=DEVNULL,
|
||||||
stderr=DEVNULL,
|
stderr=DEVNULL,
|
||||||
)
|
)
|
||||||
await process.communicate()
|
await process.communicate()
|
||||||
fav_item.tmp_video_path.unlink()
|
for path in paths:
|
||||||
fav_item.tmp_audio_path.unlink()
|
path.unlink()
|
||||||
fav_item.downloaded = True
|
fav_item.downloaded = True
|
||||||
except ResponseCodeException as e:
|
except ResponseCodeException as e:
|
||||||
match e.code:
|
match e.code:
|
||||||
|
|||||||
Reference in New Issue
Block a user