Rename 1. Convert to LRC format.py to source/1. Convert to LRC format.py

This commit is contained in:
~noah~
2021-11-23 23:38:36 -07:00
committed by GitHub
parent 947f8d44de
commit 48e9a972e1
+38
View File
@@ -0,0 +1,38 @@
# Read in the file
with open('lyrics.txt', 'r') as file :
filedata = file.read()
# Replace the target string
filedata = filedata.replace('},', '} \n')
filedata = filedata.replace('{"lyrics":{"syncType":"LINE_SYNCED","lines":[', '')
filedata = filedata.replace('\\u0027', '\'')
filedata = filedata.replace('{"startTimeMs":"', '[')
filedata = filedata.replace(',"syllables":[]} ', '')
filedata = filedata.replace('","words":', ']')
filedata = filedata.replace('"', '')
filedata = filedata.replace('hasVocalRemoval:false}', '')
filedata = filedata.replace(']', '] ')
# Write the file out again
with open('lyricsfixed.lrc', 'w') as file:
file.write(filedata)
# remove leftover shit from spotify that doesnt apply to lrc files
with open("lyricsfixed.lrc", "r") as f:
lines = f.readlines()
with open("lyricsfixed.lrc", "w") as new_f:
for line in lines:
if not line.startswith("colors:{background"):
new_f.write(line)
# remove last line
import os, sys, re
readFile = open("lyricsfixed.lrc")
lines = readFile.readlines()
readFile.close()
w = open("lyricsfixed.lrc",'w')
w.writelines([item for item in lines[:-1]])
w.close()