H
H
HoBu4okok2021-07-09 23:07:39
Python
HoBu4okok, 2021-07-09 23:07:39

How to send music via bot.send_audio (telebot, python)?

There is the following audio data:

{
      'id': 456392508,
      'owner_id': 371745457,
      'track_covers': [
        'https://sun1-25.userapi.com/impf/c857724/v857724105/231c49/Z06CcVsa0Pg.jpg?size=80x80&quality=96&sign=64c53cc0a18fbc45a1d34ee0539e8459&type=audio',
        'https://sun1-25.userapi.com/impf/c857724/v857724105/231c49/Z06CcVsa0Pg.jpg?size=150x150&quality=96&sign=3e4c5b4d5d8f3e0e876b78af0ec75316&type=audio'
      ],
      'url': 'https://cs1-65v4.vkuseraudio.net/p4/e3d1633c928938.mp3?extra=UwZawvd-y72N_CZYKP_lO04smUYKNGu3zxoXpl2drPQrkQ_PQpmg1ZsnEiMuElrCudU3abDH4V95MNh3aCNhU067lyStRejERVIJIJRQYUCRtA1KIL6q8hOK1Gtp1shMJhCNrCtovzc-IAENvvhsoNAp&long_chunk=1',
      'artist': 'Каспийский Груз',
      'title': 'Ок',
      'duration': 155
    }

Sending an audio recording to a user:
bot.send_audio(chat_id, audio.get('url'), audio.get('title') + ' - ' + audio.get('artist'))

60e8ac2e91c93032812649.jpeg
On the left is what happened. On the right is what should happen.

Please tell me how can this be done?
The json above contains a link to the audio recording image, title, and artist.
Heard about eyeD3, but did not understand how to use it.
Download songs, and then send - not an option, too long. There was an idea to upload an audio recording with an already normal name to the Telegram server, and send it by file_id, but it’s not clear how to upload and rename it.
Tried to specify title and other parameters in send_audio. Result 0.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2021-07-10
@HoBu4okok

Are you using pyTelegramBotAPI ? If you look at the github of the project, you can find an interesting comment in one of the issue :

You can't set title and performer when you are sending audio by url, but there would be no problem if you will do the same with local file

Those. parameters like title/performer/thumb only work when loading a file, not a link. FZ is this true, and if so, why such a restriction.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question