added media_category and support for STATUS calls #428

Merged
tushdante merged 4 commits from tushdante-video-upload into master 2016-09-30 04:28:38 -07:00
Showing only changes of commit e76a290166 - Show all commits

View file

@ -200,11 +200,11 @@ class EndpointsMixin(object):
'media_id': media_id 'media_id': media_id
} }
response = self.post(upload_url, params=params)
# Only get the status if explicity asked to # Only get the status if explicity asked to
# Default to False # Default to False
if check_progress == True: if check_progress:
response_finalize = self.post(upload_url, params=params)
# Stage 4: STATUS call if still processing # Stage 4: STATUS call if still processing
params = { params = {
@ -212,20 +212,20 @@ class EndpointsMixin(object):
'media_id': media_id 'media_id': media_id
} }
processing_state = response_finalize['processing_info'].get('state') processing_state = response['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['processing_info'].get('check_after_secs')
if check_after_secs is not None: if check_after_secs is not None:
time.sleep(check_after_secs) time.sleep(check_after_secs)
response_finalize = self.get(upload_url, params=params) response = self.get(upload_url, params=params)
# get new state after waiting # get new state after waiting
processing_state = response_finalize['processing_info'].get('state') processing_state = response['processing_info'].get('state')
return self.post(upload_url, param=params) return response
michaelhelmick commented 2016-09-23 06:23:26 -07:00 (Migrated from github.com)

Instead of changing the return here, can you add a keyword argument to upload_video like check_progress=False and if they pass check_progress=True, it will execute the code you added, otherwise it will just return the response.

Instead of changing the return here, can you add a keyword argument to `upload_video` like `check_progress=False` and if they pass `check_progress=True`, it will execute the code you added, otherwise it will just return the response.
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