twython icon indicating copy to clipboard operation
twython copied to clipboard

upload_video infinite loop with check progress

Open jvazquez opened this issue 2 years ago • 0 comments

Hey there, I noticed a particular behavior when uploading the attached video, I'm consuming v1.1 standard

When https://github.com/ryanmcgrath/twython/blob/master/twython/endpoints.py#L174 is called with check_progress = True

The file uploads correctly.

https://github.com/ryanmcgrath/twython/blob/master/twython/endpoints.py#L235 starts, because check_progress = True

https://github.com/ryanmcgrath/twython/blob/master/twython/endpoints.py#L246 is "pending"

The code ends up looping in https://github.com/ryanmcgrath/twython/blob/master/twython/endpoints.py#L251, because response changes from

{'media_id': 1618986262236372992, 'media_id_string': '1618986262236372992', 'media_key': '7_1618986262236372992', 'size': 902118, 'expires_after_secs': 86400, 'processing_info': {'state': 'pending', 'check_after_secs': 1}}

to

{'media_id': 1618986262236372992, 'media_id_string': '1618986262236372992', 'media_key': '7_1618986262236372992', 'size': 902118, 'processing_info': {'state': 'in_progress', 'progress_percent': 100, 'error': {'code': 1, 'name': 'InvalidMedia', 'message': 'file is invalid'}}}

So you end up in an infinite loop.

I ran the video through ffmpeg and initially it seems to be ok according to https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/uploading-media/media-best-practices

I attempted the code without doing check progress and it fails with Twitter API returned a 400 (Bad Request), Not valid video

I know this bug report seems way too specific, but perhaps that particular behavior should change under these circumstances ?.

I know it's terribly specific and it may not happen to anyone and perhaps this should be closed, but just in case the same thing happens to someone else.

https://user-images.githubusercontent.com/55306/215115163-b52025d8-6155-45b4-b1e2-d4e7145d80a6.mp4

jvazquez avatar Jan 27 '23 15:01 jvazquez