2023-01-03 10:32:41 +01:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: UTF-8 -*-
|
|
|
|
#
|
|
|
|
# split.py
|
|
|
|
#
|
|
|
|
# Copyright 2023 Beat Jäckle <beat@git.jdmweb2.ch>
|
2023-01-03 12:11:34 +01:00
|
|
|
"""
|
|
|
|
Module providingClasses reading Files
|
|
|
|
Module providingFunction writing mediafiles for us
|
|
|
|
"""
|
2023-01-03 10:32:41 +01:00
|
|
|
from splitSrc.ChapterTitle import ChapterTitle
|
|
|
|
from splitSrc.ChapterTimes import ChapterTimes
|
2023-01-03 12:11:34 +01:00
|
|
|
from splitSrc.ffmpeg import ffmpeg
|
|
|
|
|
2023-01-03 10:32:41 +01:00
|
|
|
|
|
|
|
FILENAMEMUSTER = ['../HPMoR_Part_', '.mp3']
|
|
|
|
TITLES = 'chaptertitle.ods'
|
|
|
|
TIMES = 'chapter.csv'
|
2023-01-03 12:11:34 +01:00
|
|
|
FILEFORMAT = 'mp3'
|
2023-01-03 10:32:41 +01:00
|
|
|
|
|
|
|
|
2023-01-03 12:11:34 +01:00
|
|
|
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
|
2023-01-03 10:32:41 +01:00
|
|
|
|
|
|
|
try:
|
2023-01-03 12:11:34 +01:00
|
|
|
cid = int(cid)
|
2023-01-03 10:32:41 +01:00
|
|
|
except ValueError:
|
2023-01-03 12:11:34 +01:00
|
|
|
print(cid, time, 'Keine Kapitelnummer')
|
2023-01-03 10:32:41 +01:00
|
|
|
else:
|
|
|
|
# Test if it has a processor)
|
2023-01-03 12:11:34 +01:00
|
|
|
if part == pochain[1]:
|
2023-01-03 10:32:41 +01:00
|
|
|
end = pochain[2]
|
|
|
|
else:
|
|
|
|
end = None
|
|
|
|
try:
|
2023-01-03 12:11:34 +01:00
|
|
|
title = chapter_title[cid]
|
2023-01-03 10:32:41 +01:00
|
|
|
except KeyError:
|
2023-01-03 12:11:34 +01:00
|
|
|
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,
|
|
|
|
)
|
2023-01-03 10:32:41 +01:00
|
|
|
finally:
|
|
|
|
current = pochain
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
import sys
|
2023-01-03 12:11:34 +01:00
|
|
|
sys.exit(main())
|