#!/usr/bin/env python3 """ Fix LRC file by mapping correct lyrics to existing timestamps """ import re import sys def extract_timestamps(lrc_file): """Extract all timestamps from existing LRC file""" timestamps = [] with open(lrc_file, 'r', encoding='utf-8') as f: for line in f: line = line.strip() if line and line.startswith('[') and ']' in line: timestamp = line.split(']')[0] + ']' timestamps.append(timestamp) return timestamps def clean_lyrics_text(lyrics_text): """Clean lyrics text and split into lines""" lines = [] for line in lyrics_text.split('\n'): line = line.strip() # Skip section headers like [Intro:], [Chorus:], [Verse 1:], etc. if line.startswith('[') and ':' in line and line.endswith(']'): continue # Skip empty lines if not line: continue lines.append(line) return lines def create_fixed_lrc(timestamps, lyrics_lines, output_file): """Create new LRC file with correct lyrics mapped to timestamps""" with open(output_file, 'w', encoding='utf-8') as f: for i, timestamp in enumerate(timestamps): if i < len(lyrics_lines): f.write(f"{timestamp}{lyrics_lines[i]}\n") else: # If we run out of lyrics, use empty line f.write(f"{timestamp}\n") # Correct lyrics from Genius (removed producer tag) correct_lyrics = """Hey Young Jefe Fuck it up, get it again My mind it be stuck on that cash If I love you, I'll give you my last Hundreds and fifties is hitting the stash Twenties and tens, we blow that shit fast Fuck it up, get it again Fuck it up, get it again Fuck it up, get it again We fuck it up, fuck it up, get it again I'm here to make money, not friends I fell in love with the blue on them bands I like to thumb through a check with my friends For all of this money, committed some sins Fuck it up, get it again (yeah) Fuck it up, get it again (fuck it up) Fuck it up, get it again We fuck it up, fuck it up, get it again, yeah She wanna fuck with a boss She cannot kick it with him She wanna fuck a big dog I told her okay lil baby I'm him Me and my niggas we ballin' Fuck around, cut the net off of the rim (swish) I fuck around, fuck her again (yeah) Then I fuck around, fuck on her friends They like who is them niggas right there? I see all of them dressed in Monclers I spent twenty bands on my ears (bling bling) Goddamnit this shit is unfair (goddamn, goddamn) Play with me nigga, I dare I highly advise you to stay over there Got your lil bitch and another lil bitch and they all in my bed We layin' on the spread I am the Louboutin don I'm passing my swag to my son Big booty bitch on my arm She papi can we go to Milan? I took that bitch to Miami Yeah and we stayed at The One We had to live up on Sunday I fucked that bitch off the Dom Perignon, uh My mind it be stuck on that cash If I love you, I'll give you my last Hundreds and fifties is hitting the stash Twenties and tens, we blow that shit fast Fuck it up, get it again Fuck it up, get it again Fuck it up, get it again We fuck it up, fuck it up, get it again I'm here to make money, not friends I fell in love with the blue on them bands I like to thumb through a check with my friends For all of this money, committed some sins Fuck it up, get it again (yeah) Fuck it up, get it again (fuck it up) Fuck it up, get it again We fuck it up, fuck it up, get it again, yeah I fell in love with the seats in the Wraith My lawyer Jewish, I'm beating my case Hundreds and fifties, we keeping it safe You say you got pistols, I need 'em today I don't feel safe if I ain't got a pipe My homie just called me, they just gave him life I'm tryna give 50K to his lawyer I hope they appeal that shit like shakin' dice Fuck up a check when I run up in Saks My bitch got my name tatted right on her ass I used to bag up, go right to the ave I ain't have no whip, I got right in the cab Goin' for nothing, know I'm with the shit I like to match up my gun with my fit Shout out to Glizzy, know I got that glizzy Got so many diamonds I look like a lick So many bitches I look like a pimp We ordering lobster, don't forget the shrimp Foreign, I gotta five percent the tint Every day pray Allah forgive my sins Young nigga risk it all for a Benz Ain't got no pal, I'm goin' to the pen Baggin' the powder, blow it in the wind I'm gon' get dollars, know I'm 'bout to spend I gotta get money My mind it be stuck on that cash If I love you, I'll give you my last Hundreds and fifties is hitting the stash Twenties and tens, we blow that shit fast Fuck it up, get it again Fuck it up, get it again Fuck it up, get it again We fuck it up, fuck it up, get it again I'm here to make money, not friends I fell in love with the blue on them bands I like to thumb through a check with my friends For all of this money, committed some sins Fuck it up, get it again (yeah) Fuck it up, get it again (fuck it up) Fuck it up, get it again We fuck it up, fuck it up, get it again, yeah""" if __name__ == "__main__": input_lrc = "/Volumes/Jellyfin Media/Music/Shy Glizzy/Quiet Storm - (2017)/Shy Glizzy - Get It Again.lrc" output_lrc = "/Volumes/Jellyfin Media/Music/Shy Glizzy/Quiet Storm - (2017)/Shy Glizzy - Get It Again.fixed.lrc" # Extract timestamps from existing file timestamps = extract_timestamps(input_lrc) print(f"Extracted {len(timestamps)} timestamps") # Clean and split lyrics lyrics_lines = clean_lyrics_text(correct_lyrics) print(f"Cleaned {len(lyrics_lines)} lyric lines") # Create fixed LRC create_fixed_lrc(timestamps, lyrics_lines, output_lrc) print(f"Created fixed LRC: {output_lrc}") # Show first few lines as preview print("\nPreview of fixed LRC:") with open(output_lrc, 'r') as f: for i, line in enumerate(f): if i < 10: print(line.rstrip()) else: break