Renamed set_description to create_metadata in Twython endpoints. Added a bit more documentation and use the documented channel

This commit is contained in:
Jose Manuel Delicado 2017-10-07 14:53:53 +02:00
parent f69e4283cd
commit 4d75f2db34
2 changed files with 6 additions and 5 deletions

View File

@ -157,7 +157,7 @@ class bufferController(object):
for i in attachments: for i in attachments:
photo = open(i["file"], "rb") photo = open(i["file"], "rb")
img = self.session.twitter.twitter.upload_media(media=photo) img = self.session.twitter.twitter.upload_media(media=photo)
self.session.twitter.twitter.set_description(media_id=img["media_id"], alt_text=dict(text=i["description"])) self.session.twitter.twitter.create_metadata(media_id=img["media_id"], alt_text=dict(text=i["description"]))
media_ids.append(img["media_id"]) media_ids.append(img["media_id"])
self.session.twitter.twitter.update_status(status=text, media_ids=media_ids) self.session.twitter.twitter.update_status(status=text, media_ids=media_ids)

View File

@ -145,11 +145,12 @@ class EndpointsMixin(object):
""" """
return self.post('https://upload.twitter.com/1.1/media/upload.json', params=params) return self.post('https://upload.twitter.com/1.1/media/upload.json', params=params)
def set_description(self, **params): def create_metadata(self, **params):
""" Adds a description to an image.""" """ Adds metadata to a media element, such as image descriptions for visually impaired.
# This method only accepts strings, no dictionaries. Docs: https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-metadata-create
"""
params = json.dumps(params) params = json.dumps(params)
return self.post("media/metadata/create", params=params) return self.post("https://upload.twitter.com/1.1/media/metadata/create.json", params=params)
def upload_video(self, media, media_type, size=None): def upload_video(self, media, media_type, size=None):
"""Uploads video file to Twitter servers in chunks. The file will be available to be attached """Uploads video file to Twitter servers in chunks. The file will be available to be attached