diff --git a/twitter/api.py b/twitter/api.py index f0541b85..47a8709d 100644 --- a/twitter/api.py +++ b/twitter/api.py @@ -1262,7 +1262,7 @@ def _UploadMediaChunkedInit(self, """ url = '%s/media/upload.json' % self.upload_url - media_fp, filename, file_size, media_type = parse_media_file(media) + media_fp, filename, file_size, media_type = parse_media_file(media, media_category) if not all([media_fp, filename, file_size, media_type]): raise TwitterError({'message': 'Could not process media file'}) diff --git a/twitter/twitter_utils.py b/twitter/twitter_utils.py index e68804cc..7ebc5d23 100644 --- a/twitter/twitter_utils.py +++ b/twitter/twitter_utils.py @@ -216,7 +216,7 @@ def http_to_file(http): return data_file -def parse_media_file(passed_media): +def parse_media_file(passed_media, media_category=None): """ Parses a media file and attempts to return a file-like object and information about the media file. @@ -265,7 +265,8 @@ def parse_media_file(passed_media): media_type = mimetypes.guess_type(os.path.basename(filename))[0] if media_type is not None: if media_type in img_formats and file_size > 5 * 1048576: - raise TwitterError({'message': 'Images must be less than 5MB.'}) + if media_category is not 'tweet_gif': + raise TwitterError({'message': 'Images must be less than 5MB.'}) elif media_type in video_formats and file_size > 15 * 1048576: raise TwitterError({'message': 'Videos must be less than 15MB.'}) elif media_type not in img_formats and media_type not in video_formats: