Skip to content

Commit

Permalink
add log
Browse files Browse the repository at this point in the history
  • Loading branch information
simonsmh authored Jan 8, 2025
1 parent 7c445e5 commit ebb0e9d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions biliparser/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ async def get_media_mediathumb(f, client):


async def handle_dash_media(f, client):
media = []
res = []
try:
cache_dash_file = LOCAL_FILE_PATH / f.mediafilename[0]
cache_dash = await get_cache_media(cache_dash_file.name)
Expand All @@ -258,15 +258,18 @@ async def handle_dash_media(f, client):
get_media(client, f.url, m, fn, size=1280)
for m, fn in zip(f.dashurls, f.dashfilename)
]
media = [m for m in await asyncio.gather(*tasks) if m]

res = [m for m in await asyncio.gather(*tasks) if m]
if len(res) < 2:
logger.error(f"DASH媒体下载失败: {f.url}")
return []
# Merge segments
cmd = [os.environ.get("FFMPEG_PATH", "ffmpeg"), "-y"]
for item in media:
for item in res:
cmd.extend(["-i", str(item)])
cmd.extend(
["-vcodec", "copy", "-acodec", "copy", str(cache_dash_file.absolute())]
)
logger.info(f"开始合并,执行命令:{' '.join(cmd)}")
subprocess.run(cmd, check=True)

f.mediaurls = [str(cache_dash_file.absolute())]
Expand All @@ -278,7 +281,7 @@ async def handle_dash_media(f, client):
logger.error(f"DASH媒体处理失败: {f.url} - {str(e)}")
return []
finally:
for item in media:
for item in res:
if isinstance(item, Path):
item.unlink(missing_ok=True)

Expand Down

0 comments on commit ebb0e9d

Please sign in to comment.