def download_choosen_format(update, context): query = update.callback_query resolution_code, link = query.data.split( ' ', 1 ) #setting the max parameter to 1, will return a list with 2 elements! context.bot.edit_message_text(text="Downloading...", chat_id=query.message.chat_id, message_id=query.message.message_id) video = Video(link) video.download(resolution_code) with video.send() as files: for f in files: try: context.bot.send_document( chat_id=query.message.chat_id, document=open(f, 'rb')) #open with binary file and send data except TimeoutError: context.bot.send_message( chat_id=update.effective_chat.id, text="Tansfer timeout, place try again later") video.remove() context.bot.send_message(chat_id=update.effective_chat.id, text="Finished") video.remove()
def download_choosen_format(bot, update): query = update.callback_query resolution_code, link = query.data.split(' ', 1) bot.edit_message_text(text="Downloading...", chat_id=query.message.chat_id, message_id=query.message.message_id) video = Video(link) video.download(resolution_code) with video.send() as files: for f in files: bot.send_document(chat_id=query.message.chat_id, document=open(f, 'rb'))
def download_choosen_format(update, CallbackContext): query = update.callback_query if query == '3' or query == '1' or query == '2': pass else: resolution_code, link = query.data.split(' ', 1) b1 = b = updater.bot.edit_message_text( text="Making *Http* request...", chat_id=query.message.chat_id, message_id=query.message.message_id, parse_mode=ParseMode.MARKDOWN) time.sleep(2) b = updater.bot.edit_message_text(text="```Downloading...```", chat_id=query.message.chat_id, message_id=query.message.message_id, parse_mode=ParseMode.MARKDOWN) time.sleep(2) updater.bot.send_chat_action(chat_id=query.message.chat_id, action=ChatAction.UPLOAD_DOCUMENT) a = updater.bot.edit_message_text(text="```Uploading...```", chat_id=query.message.chat_id, message_id=query.message.message_id, parse_mode=ParseMode.MARKDOWN) video = Video(link) video.download(resolution_code) with video.send() as files: for f in files: updater.bot.send_document( chat_id=query.message.chat_id, document=open(f, 'rb'), caption= f'<b>Title</b>: {t1}\n<b>Duration</b>:<code>{d1}</code>\n<b>Views</b>:<code>{v1}</code>', parse_mode=ParseMode.HTML) time.sleep(2) a.delete()
def download_choosen_format(update, CallbackContext): query = update.callback_query if query == '3' or query == '1' or query == '2': pass else: bot = Updater(TOKEN) resolution_code, link = query.data.split(' ', 1) #b = bot.edit_message_text(text="```Downloading...```",chat_id=query.message.chat_id,message_id=query.message.message_id,parse_mode=ParseMode.MARKDOWN) time.sleep(2) # a = bot.edit_message_text(text="```Uploading...```",chat_id=query.message.chat_id,message_id=query.message.message_id,parse_mode=ParseMode.MARKDOWN) video = Video(link) video.download(resolution_code) with video.send() as files: for f in files: update.send_document( chat_id=query.message.chat_id, document=open(f, 'rb'), caption= f'<b>Title</b>: {t1}\n<b>Duration</b>:<code>{d1}</code>\n<b>Views</b>:<code>{v1}</code>', parse_mode=ParseMode.HTML)