R
R
Rotyin2021-02-12 02:56:16
Python
Rotyin, 2021-02-12 02:56:16

Play audio via url python?

import telebot
from telebot import types

tocen='1625926730:AAE-_C2fEtjCYk67po961PzGKvO4uB7ezBQ'
bot=telebot.TeleBot(tocen)

@bot.message_handler(commands=['start'])
def get_start(message):
audio = open(' https:/ /drive.google.com/file/d/1C6Q7cSHZ_WHhmc8hp... ', 'rb')
bot.send_audio(message.chat.id, audio)

if __name__ == '__main__':
bot.polling(none_stop=True)
I I want that after pressing the command in the bot, he would send me the audio that is stored on google drive, but the

Traceback (most recent call last) error pops up:
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run .py", line 31,
start(fakepyfile,mainpyfile)
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start
exec(open(mainpyfile).read(), __main__.__dict__)
File "", line 15, in
File "/data/user/0/en.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/telebot/__init__.py", line 485, in polling
self .__threaded_polling(none_stop, interval, timeout, long_polling_timeout)
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/telebot/__init__.py" , line 544, in __threaded_polling
raise e
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/telebot/__init__.py", line 507 , in __threaded_polling
self.worker_pool.raise_exceptions()
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/telebot/util.py", line 117, in raise_exceptions
raise self.exception_info
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/telebot/util.py", line 69, in run
task(*args, * *kwargs)
File "", line 10, in get_start
FileNotFoundError: [Errno 2] No such file or directory: ' https://drive.google.com/file/d/1C6Q7cSHZ_WHhmc8hp... '

[Program finished]
How to fix ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
Wispik, 2021-02-12
@Wispik

Firstly, access to the audio via your link is closed
Secondly,

audio = open('https://drive.google.com/file/d/1C6Q7cSHZ_WHhmc8hp...', 'rb')
open only opens files from disk, it doesn't work with links
Thirdly, study requests

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question