hpmor_split/split.py
2023-01-03 12:23:04 +01:00

62 lines
1.6 KiB
Python
Executable file

#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
#
# split.py
#
# Copyright 2023 Beat Jäckle <beat@git.jdmweb2.ch>
"""
Module providingClasses reading Files
Module providingFunction writing mediafiles for us
"""
from splitSrc.ChapterTitle import ChapterTitle
from splitSrc.ChapterTimes import ChapterTimes
from splitSrc.ffmpeg import ffmpeg
FILENAMEMUSTER = ['../HPMoR_Part_', '.mp3']
TITLES = 'chaptertitle.ods'
TIMES = 'chapter.csv'
FILEFORMAT = 'mp3'
def main():
"""Splitting HPmod Files into their chapter"""
chapter_title = ChapterTitle(TITLES)
chapter_times = ChapterTimes()
current = next(chapter_times)
for pochain in chapter_times:
[cid, part, time] = current
try:
cid = int(cid)
except ValueError:
print(cid, time, 'Keine Kapitelnummer')
else:
# Test if it has a processor)
if part == pochain[1]:
end = pochain[2]
else:
end = None
try:
title = chapter_title[cid]
except KeyError:
print('No Chapter', cid)
title = dict(time='__No Name__', time_='UNKNOWN')
else:
ffmpeg(
part=part,
cid=cid,
time=time,
end=end,
title=title,
filenamemuster=FILENAMEMUSTER,
fileformat=FILEFORMAT,
)
finally:
current = pochain
return 0
if __name__ == '__main__':
import sys
sys.exit(main())