Telegram bot API not updating audio metadata (performer and title)

I’m having trouble with the Telegram bot API when trying to modify audio metadata. When I send audio files through my bot, I want to set custom performer and title fields, but they don’t seem to update properly.

I’ve tested this multiple ways including direct browser API calls to make sure it’s not a coding error on my part. Has anyone else experienced this issue?

I’m using Python with the telebot library. Here’s my sample code:

import telebot
import config

# Bot initialization
my_bot = telebot.TeleBot(config.api_key)

@my_bot.message_handler(content_types=["text"])
def process_message(msg):
    result = my_bot.send_audio(
        msg.from_user.id, 
        audio_file_url, 
        caption=None, 
        duration=None, 
        performer="Artist Name", 
        title="Song Title",
        reply_to_message_id=None
    )
    print(result.audio.performer)
    print(result.audio.title)

my_bot.polling(none_stop=True, interval=0)

The metadata fields just won’t change from the original values. Any ideas what might be causing this?

Yeah, this is a known issue with Telegram’s Bot API. When your audio file already has metadata embedded, the API ignores whatever parameters you send and uses the existing ID3 tags instead. I ran into this exact problem building a music bot last year. Telegram’s servers read the file’s metadata first, so if there’s already performer/title info in there, that’s what gets displayed no matter what you specify in your API call. The workaround I found was copying the audio data to a clean file without any metadata, then sending that through the API with my custom parameters. Without existing tags to override, Telegram actually uses what you specify.

had this problem too! Telegram does retain the original metadata. Try stripping it out first, I used ffmpeg to remove it and then uploaded through the bot. Totally fixed the issue for me!

I encountered the same problem while developing a podcast bot. The Telegram API tends to prioritize the embedded metadata over your specified parameters. To resolve this, I recommend using the mutagen library to clear the existing metadata tags. You can achieve this by using audiofile = mutagen.File(your_file), followed by audiofile.delete() and audiofile.save() to remove all tags. After doing this, your custom performer and title should be recognized correctly when you call send_audio. Just remember to apply this to a copy of the file, as it permanently deletes the original tags. This method is more dependable than using ffmpeg and avoids the need for additional dependencies.