Implemented first version of exportLRC
This commit is contained in:
33
exportLRC.py
Normal file
33
exportLRC.py
Normal file
@ -0,0 +1,33 @@
|
||||
"""
|
||||
Exports the lyric track in Audacity to an LRC file.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import os
|
||||
|
||||
import utils
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Exports the lyric track in Audacity to an LRC file.')
|
||||
parser.add_argument('lrcFile', nargs='?', default='./output.lrc', help='The .lrc file to export.')
|
||||
args = parser.parse_args()
|
||||
|
||||
if os.path.isfile(args.lrcFile):
|
||||
i = utils.inputYN(f'"{args.lrcFile}" already exists, would you like to overwrite it? (y/n) > ')
|
||||
if not i:
|
||||
print('User abort.')
|
||||
exit()
|
||||
|
||||
lrcIdx = utils.getLRCTrackIndex()
|
||||
|
||||
if lrcIdx is None:
|
||||
print('No lyric track was found in Audacity.')
|
||||
print('Please either use importLRC.py, or create a label track called "Lyrics".')
|
||||
exit(1)
|
||||
|
||||
labels = [data[1] for data in utils.getInfo('Labels') if data[0] == lrcIdx][0]
|
||||
|
||||
with open(args.lrcFile, 'w', encoding='utf-8') as f:
|
||||
for label in labels:
|
||||
f.write(utils.generateLRCLine(label[0], label[2]))
|
||||
f.write('\n')
|
||||
Reference in New Issue
Block a user