1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| import os import json videopath = os.path.abspath('.') episodes = os.listdir(videopath) episodes.remove(os.path.basename(__file__)) for episode in episodes: episodePath = videopath+'\\%s\\' % episode contents = os.listdir(episodePath) for c in contents: if(os.path.isdir(episodePath+c)): blvPath = c elif c == 'entry.json': with open(episodePath+c, encoding='UTF-8') as jsonf: temp = json.load(jsonf) titletemp = temp['page_data']['part'] title = titletemp blvs = os.listdir(episodePath+blvPath) with open(episodePath + blvPath + '\\list.txt', 'w', encoding='utf-8') as f: isblv = True for blv in blvs: if blv == 'audio.m4s': isblv = False break elif os.path.splitext(blv)[1] == '.blv': f.write("file '%s'\n" % blv) if isblv: cmd = r'%s && cd %s && ffmpeg -f concat -i list.txt -c copy "%s.mp4"' % ( videopath[0:2], episodePath + blvPath, videopath+'\\'+title) else: cmd = r'%s && cd %s && ffmpeg -i video.m4s -i audio.m4s -c copy "%s.mp4"' % ( videopath[0:2], episodePath + blvPath, videopath+'\\'+title)
os.system(cmd)
|