Upload from Imgur to Telegram directly

This commit is contained in:
JonnyWong16 2017-12-07 19:45:03 -08:00
parent 1d9d16b69b
commit d23c4ef319

View file

@ -3081,20 +3081,15 @@ class TELEGRAM(Notifier):
text = body.encode('utf-8') text = body.encode('utf-8')
if self.config['incl_poster'] and kwargs.get('parameters'): if self.config['incl_poster'] and kwargs.get('parameters'):
poster_data = {'chat_id': self.config['chat_id'],
'disable_notification': True}
parameters = kwargs['parameters'] parameters = kwargs['parameters']
poster_url = parameters.get('poster_url','') poster_url = parameters.get('poster_url','')
if poster_url: if poster_url:
poster_request = requests.get(poster_url) poster_data = {'photo': poster_url,
poster_content = poster_request.content 'chat_id': self.config['chat_id'],
'disable_notification': True}
files = {'photo': (poster_url, poster_content)} r = requests.post('https://api.telegram.org/bot{}/sendPhoto'.format(self.config['bot_token']), json=poster_data)
r = requests.post('https://api.telegram.org/bot{}/sendPhoto'.format(self.config['bot_token']),
data=poster_data, files=files)
if r.status_code == 200: if r.status_code == 200:
logger.info(u"PlexPy Notifiers :: {name} poster sent.".format(name=self.NAME)) logger.info(u"PlexPy Notifiers :: {name} poster sent.".format(name=self.NAME))