From a1b67b461958b9616bd2336f502b5b3791cfccff Mon Sep 17 00:00:00 2001 From: thezero Date: Sat, 19 Jun 2021 20:49:24 +0200 Subject: [PATCH] fix ytdl --- Dockerfile | 1 + main.py | 55 ------------------------------------------------------ 2 files changed, 1 insertion(+), 55 deletions(-) delete mode 100644 main.py diff --git a/Dockerfile b/Dockerfile index 9f77fae..c5c7db0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,4 +2,5 @@ FROM python:3.8-slim-buster WORKDIR /bot COPY requirements.txt . RUN pip3 install -r requirements.txt +RUN pip3 install --upgrade youtube-dl COPY src src \ No newline at end of file diff --git a/main.py b/main.py deleted file mode 100644 index 9120b1c..0000000 --- a/main.py +++ /dev/null @@ -1,55 +0,0 @@ -import logging -import os - -from telegram import InlineKeyboardMarkup -from telegram.ext import Updater, CallbackQueryHandler, MessageHandler, Filters - -from vid_utils import Video, BadLink - -logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO) -logger = logging.getLogger(__name__) - - -def get_format(update, context): - logger.info("from {}: {}".format(update.message.chat_id, update.message.text)) # "history" - - try: - video = Video(link=update.message.text, init_keyboard=True) - except BadLink as e: - update.message.reply_text("Bad link: {}".format(e)) - else: - reply_markup = InlineKeyboardMarkup(video.keyboard) - update.message.reply_text('Choose format:', reply_markup=reply_markup) - - -def download_choosen_format(update, context): - query = update.callback_query - video_index = query.data - - context.bot.edit_message_text(text="Downloading...", - chat_id=query.message.chat_id, - message_id=query.message.message_id) - - video = Video(vid=video_index) - video.download() - - with video.send() as files: - for f in files: - logger.log("Sending... {} ".format(f)) - context.bot.send_document(chat_id=query.message.chat_id, document=open(f, 'rb')) - - context.bot.delete_message(chat_id=query.message.chat_id, - message_id=query.message.message_id) - -TOKEN = None -with open(os.path.join(os.environ['CONF_FOLDER'], 'bot.token')) as f: - TOKEN = f.read().strip() - -updater = Updater(token=TOKEN) - -updater.dispatcher.add_handler(MessageHandler(Filters.text, get_format)) -updater.dispatcher.add_handler(CallbackQueryHandler(download_choosen_format)) - - -updater.start_polling() -updater.idle()