Add support for creating image descriptions
This commit is contained in:
parent
0702b4bce1
commit
43217a512c
2 changed files with 18 additions and 5 deletions
|
|
@ -140,8 +140,11 @@ class Twython(EndpointsMixin, object):
|
||||||
params = params or {}
|
params = params or {}
|
||||||
|
|
||||||
func = getattr(self.client, method)
|
func = getattr(self.client, method)
|
||||||
|
if type(params) is dict:
|
||||||
params, files = _transparent_params(params)
|
params, files = _transparent_params(params)
|
||||||
|
else:
|
||||||
|
params = params
|
||||||
|
files = list()
|
||||||
requests_args = {}
|
requests_args = {}
|
||||||
for k, v in self.client_args.items():
|
for k, v in self.client_args.items():
|
||||||
# Maybe this should be set as a class variable and only done once?
|
# Maybe this should be set as a class variable and only done once?
|
||||||
|
|
@ -199,8 +202,10 @@ class Twython(EndpointsMixin, object):
|
||||||
else:
|
else:
|
||||||
content = response.json()
|
content = response.json()
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise TwythonError('Response was not valid JSON. \
|
# Send the response as is for working with /media/metadata/create.json.
|
||||||
Unable to decode.')
|
content = response.content
|
||||||
|
#raise TwythonError('Response was not valid JSON. \
|
||||||
|
#Unable to decode.')
|
||||||
|
|
||||||
return content
|
return content
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ from time import sleep
|
||||||
#from StringIO import StringIO
|
#from StringIO import StringIO
|
||||||
#except ImportError:
|
#except ImportError:
|
||||||
#from io import StringIO
|
#from io import StringIO
|
||||||
|
import json
|
||||||
from .advisory import TwythonDeprecationWarning
|
from .advisory import TwythonDeprecationWarning
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -238,6 +238,14 @@ class EndpointsMixin(object):
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
def set_description(self, **params):
|
||||||
|
""" Adds a description to an image.
|
||||||
|
Docs: there is no official documentation
|
||||||
|
"""
|
||||||
|
# This method only accepts strings, no dictionaries.
|
||||||
|
params = json.dumps(params)
|
||||||
|
return self.post("media/metadata/create", params=params)
|
||||||
|
|
||||||
def get_oembed_tweet(self, **params):
|
def get_oembed_tweet(self, **params):
|
||||||
"""Returns information allowing the creation of an embedded
|
"""Returns information allowing the creation of an embedded
|
||||||
representation of a Tweet on third party sites.
|
representation of a Tweet on third party sites.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue