37 lines
950 B
Python
37 lines
950 B
Python
"""
|
|
Imports an LRC file (with or without timestamps) into Audacity.
|
|
"""
|
|
|
|
import argparse
|
|
|
|
import utils
|
|
|
|
parser = argparse.ArgumentParser(
|
|
description='Imports an LRC file (with or without timestamps) into Audacity.')
|
|
parser.add_argument('lrcFile', nargs='?', default=None, help='The .lrc file to import.')
|
|
args = parser.parse_args()
|
|
|
|
lyrics = []
|
|
|
|
if args.lrcFile is None:
|
|
print('No .lrc file was passed, please paste the lyrics, then enter \'/\' to continue.')
|
|
i = ''
|
|
while i != '/':
|
|
i = input('')
|
|
lyrics.append(i)
|
|
lyrics.pop(-1)
|
|
else:
|
|
with open(args.lrcFile, 'r', encoding='utf-8') as f:
|
|
lyrics = f.read().split('\n')
|
|
|
|
lyrics = [utils.parseLrcLine(lrcLine) for lrcLine in lyrics]
|
|
|
|
lrcidx = utils.getLRCTrackIndex(True)
|
|
projectLen = utils.getProjectLength()
|
|
|
|
for idx, (t, lyric) in enumerate(lyrics):
|
|
if t is None:
|
|
t = idx * (projectLen / len(lyrics))
|
|
|
|
utils.addLabel(lrcidx, t, lyric)
|