Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How should I upload video? #418

Open
du5 opened this issue Nov 12, 2020 · 1 comment
Open

How should I upload video? #418

du5 opened this issue Nov 12, 2020 · 1 comment

Comments

@du5
Copy link

du5 commented Nov 12, 2020

Everything works fine when i upload the picture, it's broke while uploading the video.Where am I doing wrong?

# url example
# http://abc.com/1.mp4
# http://abc.com/2.png
# http://abc.com/3.jpg
if (os.path.splitext(url)[-1][1:]).lower() not in ["jpg", "jpeg", "gif", "png", "webp", "mp4", "mov"]:
    return
response = requests.get(url)
old_domain = twitter.domain
twitter.domain = 'upload.twitter.com'
id_img1 = twitter.media.upload(media=response.content)["media_id_string"]
twitter.domain = old_domain
twitter.statuses.update(status=text, media_ids=",".join([id_img1]))
details: {'request': '/1.1/media/upload.json', 'error': 'media type unrecognized.'}
@RouxRC
Copy link
Member

RouxRC commented Nov 12, 2020

I'm not sure videos upload is supported in this library yet: as it says on Twitter's official API documentation https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/api-reference/post-media-upload the regular media.upload route only supports images, and it should be called differently to post videos or big images, through multiple different calls using the same route but with different arguments:

I've never tried it before and will be curious of your feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants