From f3d8f958d7298c205ab5d604504476cfc6b229a9 Mon Sep 17 00:00:00 2001 From: gabichulas Date: Fri, 14 Aug 2026 21:44:32 -0300 Subject: [PATCH] feat: add support for OGG and Opus audio files --- lrcput.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/lrcput.py b/lrcput.py index f2cdcb9..33fbef4 100644 --- a/lrcput.py +++ b/lrcput.py @@ -3,11 +3,13 @@ import argparse from mutagen.flac import FLAC from mutagen.mp4 import MP4 +from mutagen.oggopus import OggOpus +from mutagen.oggvorbis import OggVorbis import eyed3 from tqdm import tqdm def has_embedded_lyrics(audio): - if isinstance(audio, FLAC): + if isinstance(audio, (FLAC, OggOpus, OggVorbis)): return 'LYRICS' in audio elif isinstance(audio, MP4): return '\xa9lyr' in audio.tags @@ -23,7 +25,9 @@ def embed_lrc(directory, skip_existing, reduce_lrc, recursive): audio_files = [] for root, dirs, files in os.walk(directory): for file in files: - if file.endswith('.flac') or file.endswith('.mp3') or file.endswith('.m4a'): + if (file.endswith('.flac') or file.endswith('.mp3') or + file.endswith('.m4a') or file.endswith('.ogg') or + file.endswith('.opus')): audio_files.append(os.path.join(root, file)) with tqdm(total=len(audio_files), desc='Embedding LRC files', unit='file') as pbar: @@ -37,6 +41,13 @@ def embed_lrc(directory, skip_existing, reduce_lrc, recursive): audio = None if file.endswith('.flac'): audio = FLAC(audio_path) + elif file.endswith('.opus'): + audio = OggOpus(audio_path) + elif file.endswith('.ogg'): + try: + audio = OggVorbis(audio_path) + except Exception: + audio = OggOpus(audio_path) elif file.endswith('.mp3'): audio = eyed3.load(audio_path) elif file.endswith('.m4a'): @@ -51,6 +62,17 @@ def embed_lrc(directory, skip_existing, reduce_lrc, recursive): audio = FLAC(audio_path) audio['LYRICS'] = open(lrc_path, 'r', encoding='utf-8').read() audio.save() + elif file.endswith('.opus'): + audio = OggOpus(audio_path) + audio['LYRICS'] = open(lrc_path, 'r', encoding='utf-8').read() + audio.save() + elif file.endswith('.ogg'): + try: + audio = OggVorbis(audio_path) + except Exception: + audio = OggOpus(audio_path) + audio['LYRICS'] = open(lrc_path, 'r', encoding='utf-8').read() + audio.save() elif file.endswith('.mp3'): audio = eyed3.load(audio_path) tag = audio.tag