I'd like to shuffle / zip two fields together.
Allow me to explain. My music player now supports non timestamped lines in synced lyrics.
So this:
[00:00.00] Agua
Water
Means both those lines will appear at the timestamp with the timestamped line being bold, which is cool.
To create these synced lyrics with translations I was manually inserting the translated lines one by one if i could not find a synced lyrics file that already features translation.
If possible i'd like to place the synced lyrics in one field. The translated lyrics in another field & have them shuffled together like a deck of playing cards, joined together in a zipper fashion.
So if:
Field 1=
[00:00.00] A
[00:01.00] B
[00:02.00] C
Field 2=
1
2
3
I want Field 3=
[00:00.00] A
1
[00:01.00] B
2
[00:02.00] C
3
I was first thinking of using a spreadsheet & some simple formulas to accomplish this as I don't know how to script & have yet to figure regex out. I feel mp3tag is probably powerful enough to do this I just havent gotten the right idea.
Any suggestions would be greatly appreciated!
In case no one provides an mp3tag solution, here's a simple python script I just created with the help of ChatGPT for this purpose.
def zip_files(file_a_path, file_b_path, output_path):
# Open both files with UTF-8 encoding and read the lines
with open(file_a_path, 'r', encoding='utf-8') as file_a, open(file_b_path, 'r', encoding='utf-8') as file_b:
lines_a = file_a.readlines()
lines_b = file_b.readlines()
# Check if line counts match
if len(lines_a) != len(lines_b):
print("The files have different line counts and cannot be zipped together.")
return
# Open the output file with UTF-8 encoding to write the zipped lines
with open(output_path, 'w', encoding='utf-8') as output_file:
for line_a, line_b in zip(lines_a, lines_b):
# Strip newline characters and format output
output_file.write(f"{line_a.strip()}\n{line_b.strip()}\n")
print("Files have been zipped successfully!")
# Example usage:
zip_files('original language.txt', 'translation.txt', 'output.lrc')
Save this as zipme.py (or whatever name you like) in a folder.
Then create 2 .txt files in the same folder that you name original language.txt and translation.txt
Open both in a text editor and save the original lyrics to original language.txt and the translation to translation.txt. Ensure that the line count of both is identical. Then open a cmd window in that folder (CTRL+L → cmd → ENTER) followed by zipme.py → ENTER
That ought to create a new file called output.lrc with the results you want.
If you keep all 3 files open in a text editor that detects changes like Notepad++ that should be relatively quick.
For the test case you provided:
original language.txt =
[00:00.00] A
[00:01.00] B
[00:02.00] C
translation.txt =
1
2
3
it yielded output.lrc =
[00:00.00] A
1
[00:01.00] B
2
[00:02.00] C
3
I have not tested it further than that. I'd be curious how this can be solved in Mp3tag.
Oh nice! Thank You so much! I'll have to give this a go.
I'm also curious if/how this could be done in mp3tag. If not I think this should work exactly as planned.
I do not know any function in MP3tag that has a loop which terminates after a certain condition has been met.
As far as I understand regular expressions they are meant to deal with fixed patterns but not variable amounts of data - which would mean in this case: one would have to count the lines and then add as many groups in the expression.
Which would lead me to the assumption that the problem cannot be solved with MP3tag functions in a flexible way.