- Double -> single quotes
- Removed default value from .get() - Added a check_progress param to upload_video to allow users to decide when to check 'STATUS' calls
This commit is contained in:
parent
2c02b622a2
commit
7401adfb64
1 changed files with 24 additions and 19 deletions
|
|
@ -145,7 +145,7 @@ 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 upload_video(self, media, media_type, size=None):
|
def upload_video(self, media, media_type, size=None, check_progress=False):
|
||||||
"""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
|
||||||
to a status for 60 minutes. To attach to a update, pass a list of returned media ids
|
to a status for 60 minutes. To attach to a update, pass a list of returned media ids
|
||||||
to the 'update_status' method using the 'media_ids' param.
|
to the 'update_status' method using the 'media_ids' param.
|
||||||
|
|
@ -199,6 +199,11 @@ class EndpointsMixin(object):
|
||||||
'command': 'FINALIZE',
|
'command': 'FINALIZE',
|
||||||
'media_id': media_id
|
'media_id': media_id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Only get the status if explicity asked to
|
||||||
|
# Default to False
|
||||||
|
if check_progress == True:
|
||||||
|
|
||||||
response_finalize = self.post(upload_url, params=params)
|
response_finalize = self.post(upload_url, params=params)
|
||||||
|
|
||||||
# Stage 4: STATUS call if still processing
|
# Stage 4: STATUS call if still processing
|
||||||
|
|
@ -207,10 +212,10 @@ class EndpointsMixin(object):
|
||||||
'media_id': media_id
|
'media_id': media_id
|
||||||
}
|
}
|
||||||
|
|
||||||
processing_state = response_finalize['processing_info'].get('state', None)
|
processing_state = response_finalize['processing_info'].get('state')
|
||||||
|
|
||||||
if processing_state is not None:
|
if processing_state is not None:
|
||||||
while (processing_state == "pending" or processing_state == "in_progress") :
|
while (processing_state == 'pending' or processing_state == 'in_progress') :
|
||||||
# get the secs to wait
|
# get the secs to wait
|
||||||
check_after_secs = response_finalize['processing_info'].get('check_after_secs', None)
|
check_after_secs = response_finalize['processing_info'].get('check_after_secs', None)
|
||||||
|
|
||||||
|
|
@ -220,7 +225,7 @@ class EndpointsMixin(object):
|
||||||
# get new state after waiting
|
# get new state after waiting
|
||||||
processing_state = response_finalize['processing_info'].get('state')
|
processing_state = response_finalize['processing_info'].get('state')
|
||||||
|
|
||||||
return response_finalize
|
return self.post(upload_url, param=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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue