added media_category and support for STATUS calls #428
1 changed files with 22 additions and 1 deletions
|
|
@ -199,7 +199,28 @@ class EndpointsMixin(object):
|
||||||
'command': 'FINALIZE',
|
'command': 'FINALIZE',
|
||||||
|
Can you just make this Can you just make this `if check_progress` -- sorry, a lot of the review is just styling issues!
Can you make this: outside of this and use and outside of the check, you can just Can you make this:
``` python
response = self.post(upload_url, params=params)
```
outside of this `if check_progress:`
and use `response` everywhere you use `response_finalize`
and outside of the check, you can just `return response` then, does that make sense or should I elaborate more?
No worries! @michaelhelmick totally happy to ensure everything is compliant. appreciate the feedback! No worries! @michaelhelmick totally happy to ensure everything is compliant. appreciate the feedback!
|
|||||||
'media_id': media_id
|
'media_id': media_id
|
||||||
}
|
}
|
||||||
return self.post(upload_url, params=params)
|
response_finalize = self.post(upload_url, params=params)
|
||||||
|
|
||||||
|
# Stage 4: STATUS call if still processing
|
||||||
|
params = {
|
||||||
|
'command': 'STATUS',
|
||||||
|
'media_id': media_id
|
||||||
|
}
|
||||||
|
|
||||||
|
processing_state = response_finalize['processing_info'].get('state', None)
|
||||||
|
|
||||||
|
if processing_state is not None:
|
||||||
|
while (processing_state == "pending" or processing_state == "in_progress") :
|
||||||
|
# get the secs to wait
|
||||||
|
check_after_secs = response_finalize['processing_info'].get('check_after_secs', None)
|
||||||
|
|
||||||
|
if check_after_secs is not None:
|
||||||
|
time.sleep(check_after_secs)
|
||||||
|
response_finalize = self.get(upload_url, params=params)
|
||||||
|
# get new state after waiting
|
||||||
|
processing_state = response_finalize['processing_info'].get('state')
|
||||||
|
|
||||||
|
return response_finalize
|
||||||
|
|
||||||
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
Can you change these double quotes to single quotes, please?
You don't need to default to
Noneascheck_after_secs = response_finalize['processing_info'].get('check_after_secs')will returnNoneif it doesn't existYou don't need to default to
Noneasprocessing_state = response_finalize['processing_info'].get('state')will returnNoneif it doesn't exist