Open nishant842 opened 4 years ago
I kind of solved this in two steps.
I added media_category = 'tweet_video' to the PostUpdate, but that fails with "Not valid video" message.
I then added time.sleep(5) in api.py before resp = self._RequestUrl(url, 'POST', data=parameters) near the end PostUpdate. The video is apparently still being processed so the sleep is necessary. This now works.
https://github.com/liu044100/SocialVideoHelper/issues/10
There is doubtlessly a more correct way of solving this.
The official documentation Media Best Practices - Twitter Developer says
Duration must be between 0.5 seconds and 140 seconds
, meaning Twitter API itself does support uploading videos longer than 30 seconds. So it would be nice if python-twitter
supported it. (Or perhaps it is already implemented in python-twitter
but we're calling incorrect functions?)
My current workaround (which doesn't require editing the source code of python-twitter
):
def upload_(self, tweet_content: str, filepath: str) -> None:
video_id: int = self.twitter_client.UploadMediaChunked(media = filepath, media_category = 'tweet_video')
time.sleep(10) #Waits until the async processing of the uploaded media finishes and `video_id` becomes valid.
self.twitter_client.PostUpdate(status = tweet_content, media = video_id)
When trying to upload an mp4 file with duration 70 seconds PostUpdate fails with
TwitterError: [{'code': 324, 'message': 'Duration too long, maximum:30000, actual:77000 (MediaId: snf:1240015325195915269)'}
I believe twitter allows uploading file upto 140 seconds long. Any ideas why this is failing? I am able to upload 30 second files.