Forums

When I run the bot, I get this error, I don't understand what's wrong, please help

When I run the bot, I get this error, I don't understand what's wrong, please help TgCrypto is missing! Pyrogram will work the same, but at a much slower speed. More info: https://docs.pyrogram.org/topics/speedups Traceback (most recent call last): File "/home/Fermer1490/skachatYou/main.py", line 39, in <module> bot.run() File "/home/Fermer1490/.local/lib/python3.10/site-packages/pyrogram/methods/utilities/run.py", line 84, in run self.start() TgCrypto is missing! Pyrogram will work the same, but at a much slower speed. More info: https://docs.pyrogram.org/topics/speedups /home/Fermer1490/.local/lib/python3.10/site-packages/pyrogram/init.py Traceback (most recent call last): File "/home/Fermer1490/skachatYou/main.py", line 41, in <module> bot.run() File "/home/Fermer1490/.local/lib/python3.10/site-packages/pyrogram/methods/utilities/run.py", line 84, in run self.start() File "/home/Fermer1490/.local/lib/python3.10/site-packages/pyrogram/sync.py", line 66, in async_to_sync_wrap return loop.run_until_complete(coroutine) File "/usr/local/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete return future.result() File "/home/Fermer1490/.local/lib/python3.10/site-packages/pyrogram/methods/utilities/start.py", line 58, in start is_authorized = await self.connect() File "/home/Fermer1490/.local/lib/python3.10/site-packages/pyrogram/methods/auth/connect.py", line 40, in connect await self.load_session() File "/home/Fermer1490/.local/lib/python3.10/site-packages/pyrogram/client.py", line 608, in load_session await self.storage.open() File "/home/Fermer1490/.local/lib/python3.10/site-packages/pyrogram/storage/file_storage.py", line 58, in open self.conn = sqlite3.connect(str(path), timeout=1, check_same_thread=False) sqlite3.OperationalError: unable to open database file

My bot code main.py from pyrogram.handlers import MessageHandler import time from pyrogram import Client, filters import logging import requests import download import random import os import validation import pyrogram print(pyrogram.file) logging.basicConfig(level=logging.INFO) bot = Client( "SKACHATYIU_BOT", api_id=, api_hash="", workers = 5, bot_token='' ) @bot.on_message(filters.command("start", ["!", "/"])) def connect(chat, m): try: userID = m.chat.id bot.send_message(userID, 'Привет! Я умею скачивать видео из YouTube. Отправь мне ссылку — а я отправлю тебе скачанное видео') except Exception as e: print(e)

@bot.on_message(filters.text) def get(chat, m): url=m.text userID = m.chat.id try: VID_ID = '' VID_ID = validation.to_valid(url, VID_ID) #валидация регуляркой из validation.py bot.send_message(m.chat.id, 'Начинаем загрузку видео...') download.worker(VID_ID) #скачивание видео bot.send_video(m.chat.id, str(VID_ID) + '.mp4') #отправляем видео пользователю os.remove(VID_ID + '.mp4') #удаляем видео на диске в целях жкономии места except Exception as e: bot.send_message(m.chat.id, f'Что-то пошло не так! Ошибка {e}') bot.run()

download.py import youtube_dl import re

def worker(VID_ID):

ydl_opts = {
    'max_filesize': 20000000000,
    'format': 'best',
    'outtmpl': VID_ID + '.mp4',
    'output': VID_ID + '.mp4',
    'quiet': True
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
    ydl.download([VID_ID])

validation.py import re def to_valid(url, VID_ID): youtube_urls_test = [''] youtube_urls_test.pop(0) youtube_urls_test.append(url) youtube_regex = ( r'(https?://)?(www.)?' '(youtube|youtu|youtube-nocookie).(com|be)/' '(watch\?v=|embed/|v/|.+\?v=)?([^&=%\?]{11})') youtube_regex_match = re.match(youtube_regex, url) VID_ID = youtube_regex_match.group(6) if youtube_regex_match != None: return VID_ID else: raise Exception('NOT_VALID_URL')

Make sure that you're installed tgCrypto into the version of Python that you're using to run your code. See https://help.pythonanywhere.com/pages/InstallingNewModules/