fix twitter robot

This commit is contained in:
bakatrouble 2021-04-24 00:29:03 +03:00
parent 01d5063807
commit c8e0af9bd9

View File

@ -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']