我正在重新编写一个 bash 脚本,该脚本从 .pencast 文件(实际上只是 .zip)中提取 aac 文件......
import os
import glob
import zipfile
app_path = os.path.dirname(os.path.realpath(__file__)) + os.sep
temp = app_path + 'AudioFiles'
for pencast in (glob.glob( app_path + '*.pencast')):
f = zipfile.ZipFile(pencast, 'r')
for number, audio in enumerate(f.namelist()):
if 'aac' in audio:
print(os.path.basename(pencast), number, audio)
返回(这样您就可以看到文件的样子)
:!/usr/local/bin/python3 pencast.py
Cancer1-1.pencast 29 userdata/Sessions/PRS-a6959094a/audio-0.aac
Cancer1-1.pencast 32 userdata/Sessions/PRS-a695732e5/audio-0.aac
Cancer1-2.pencast 30 userdata/Sessions/PRS-a696fa7ab/audio-0.aac
Cancer1-2.pencast 33 userdata/Sessions/PRS-a699046df/audio-0.aac
Cancer1-3.pencast 32 userdata/Sessions/PRS-a699046df/audio-0.aac
Cancer1-3.pencast 35 userdata/Sessions/PRS-a696fa7ab/audio-0.aac
如何解压缩每个文件,给它一个唯一的名称,即
Cancer1-1-1.aac
Cancer1-1-2.aac
Cancer1-2-1.aac
...并且只是将音频文件移至“AudioFiles”文件夹吗?