From c8e0af9bd91a987afe1f91f344c97e0aad26065a Mon Sep 17 00:00:00 2001 From: bakatrouble Date: Sat, 24 Apr 2021 00:29:03 +0300 Subject: [PATCH] fix twitter robot --- bots/modules/robot.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bots/modules/robot.py b/bots/modules/robot.py index 9cca245..1b515f5 100644 --- a/bots/modules/robot.py +++ b/bots/modules/robot.py @@ -9,6 +9,7 @@ import twitter from django.db import models # from qrtools import QR from telegram import Update, InlineKeyboardMarkup, InlineKeyboardButton, MessageEntity +from telegram.error import BadRequest from telegram.ext import CallbackContext, Dispatcher, MessageHandler, Filters from djconfig import config @@ -89,11 +90,11 @@ class RobotBotModuleConfig(TelegramBotModuleConfig): config.twitter_access_token, config.twitter_access_token_secret) tweet = api.GetStatus(twitter_matches.group(1)) try: - for media in tweet_info['extended_entities']['media']: + for media in tweet.media: if media['type'] == 'video': max_bitrate = -1 max_bitrate_link = None - for variant in media['video_info']['variants']: + for variant in media.video_unfo['variants']: if variant['content_type'] == 'video/mp4' and variant['bitrate'] > max_bitrate: max_bitrate = variant['bitrate'] max_bitrate_link = variant['url']