mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-22 19:28:09 -06:00
Added set_description to twython API
This commit is contained in:
parent
3bc92af55f
commit
48232a6cf8
@ -140,8 +140,11 @@ class Twython(EndpointsMixin, object):
|
||||
params = params or {}
|
||||
|
||||
func = getattr(self.client, method)
|
||||
params, files = _transparent_params(params)
|
||||
|
||||
if type(params) is dict:
|
||||
params, files = _transparent_params(params)
|
||||
else:
|
||||
params = params
|
||||
files = list()
|
||||
requests_args = {}
|
||||
for k, v in self.client_args.items():
|
||||
# Maybe this should be set as a class variable and only done once?
|
||||
@ -199,8 +202,10 @@ class Twython(EndpointsMixin, object):
|
||||
else:
|
||||
content = response.json()
|
||||
except ValueError:
|
||||
raise TwythonError('Response was not valid JSON. \
|
||||
Unable to decode.')
|
||||
# Send the response as is for working with /media/metadata/create.json.
|
||||
content = response.content
|
||||
# raise TwythonError('Response was not valid JSON. \
|
||||
# Unable to decode.')
|
||||
|
||||
return content
|
||||
|
||||
@ -253,10 +258,8 @@ class Twython(EndpointsMixin, object):
|
||||
url = endpoint
|
||||
else:
|
||||
url = '%s/%s.json' % (self.api_url % version, endpoint)
|
||||
|
||||
content = self._request(url, method=method, params=params,
|
||||
api_call=url)
|
||||
|
||||
return content
|
||||
|
||||
def get(self, endpoint, params=None, version='1.1'):
|
||||
|
@ -14,6 +14,7 @@ This map is organized the order functions are documented at:
|
||||
https://dev.twitter.com/docs/api/1.1
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
import warnings
|
||||
try:
|
||||
@ -145,7 +146,10 @@ class EndpointsMixin(object):
|
||||
return self.post('https://upload.twitter.com/1.1/media/upload.json', params=params)
|
||||
|
||||
def set_description(self, **params):
|
||||
return self.post('media/metadata/create', params=params)
|
||||
""" Adds a description to an image."""
|
||||
# This method only accepts strings, no dictionaries.
|
||||
params = json.dumps(params)
|
||||
return self.post("media/metadata/create", params=params)
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user