Implemented first version of importLRC
This commit is contained in:
36
importLRC.py
Normal file
36
importLRC.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
"""
|
||||||
|
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)
|
||||||
Reference in New Issue
Block a user