bear / python-twitter

A Python wrapper around the Twitter API.
Apache License 2.0
3.41k stars 957 forks source link

Add ability to upload subtitles and link to media #645

Closed danielthepope closed 4 years ago

danielthepope commented 4 years ago

This PR fixes #643

I've added support for uploading subtitle files (.srt). Twitter's API documentation around it isn't great, but I've cobbled it together from https://developer.twitter.com/en/docs/media/upload-media/uploading-media/media-best-practices and https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-subtitles-create.

You can now upload an .srt file using UploadMediaChunked (with media_category set to "Subtitles"). When you also upload a video using the same function (but with media_category set to "TweetVideo"), you then need to call the new function PostMediaSubtitlesCreate to associate the video with the subtitles.

You can see how I used the library at https://github.com/danielthepope/tfl-tree/blob/master/tfltree/raspberrypi/tweets.py#L45


This change is Reviewable