Send flac files as audio
Code that causes the issue
target_entity = await client.get_entity(target_channel_id)
files = ["1.flac", "2.flac"]
await client.send_file(entity=target_entity, file=files)
I'm trying to send a group of audio files in .flac format. The problem is that they are sent as document files instead of audio, so they can't be played directly in the chat.
When I send .mp3 files in the same way, they are properly recognized as playable audio.
Expected behavior
Expected playable audio in target channel
Actual behavior
When sending multiple .flac audio files as a group using client.send_file(entity, file=files), the files are delivered as unplayable documents instead of audio messages. As a result, users can't play them directly in the chat interface. The same code works correctly for .mp3 files, which are recognized as playable audio.
Traceback
No errors, wrong behavior
Telethon version
1.40.0
Python version
3.11.6
Operating system (including distribution name and version)
Windows10, Ubuntu Linux
Other details
No response
Checklist
- [x] The error is in the library's code, and not in my own.
- [x] I have searched for this issue before posting it and there isn't an open duplicate.
- [x] I ran
pip install -U https://github.com/LonamiWebs/Telethon/archive/v1.zipand triggered the bug in the latest version.
You likely need to pass the media attributes yourself. Though the v1 code for albums is a bit of a mess, so I don't know how well that'll work, and I have no plans to change it either (meaning you may need to use the raw API).
Attributes will not work for albums - this is a problem. Moreover, the problem is not only FLAC files, but also with some MP3 files. The attributes of certain files are wrong, which causes the corresponding error and does not allow to send the album.
@Avazart if i'm not mistaken I uploaded FLAC just about fine, though not as albums and kinda long time ago. Did you installed hachoir as proposed in docs (https://docs.telethon.dev/en/stable/basic/installation.html)? Maybe this will help?