|
import os |
|
import telebot |
|
from Summarizer import * |
|
|
|
|
|
|
|
def process_youtube_url(url): |
|
try: |
|
|
|
summary = process(url) |
|
return summary |
|
except Exception as e: |
|
|
|
return f"Error processing YouTube URL: {e}" |
|
|
|
|
|
|
|
def main(): |
|
|
|
telegram_bot_token = os.getenv('TELEGRAM_BOT_TOKEN', 'YOUR_TELEGRAM_BOT_TOKEN') |
|
bot = telebot.TeleBot(telegram_bot_token) |
|
|
|
|
|
def url_handler(message): |
|
|
|
url = message.text |
|
print(f"Received YouTube URL: {url}") |
|
|
|
|
|
summary = process_youtube_url(url) |
|
|
|
|
|
bot.send_message(message.chat.id, summary, parse_mode="Markdown") |
|
|
|
@bot.message_handler(commands=['summarize']) |
|
def message_handler(message): |
|
text = "Please enter the URL of the YouTube video you would like to summarize." |
|
sent_msg = bot.send_message(message.chat.id, text, parse_mode="Markdown") |
|
bot.register_next_step_handler(sent_msg, url_handler) |
|
|
|
|
|
bot.infinity_polling() |
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
main() |
|
|