From: keatonconrad Date: Wed, 16 Dec 2020 04:43:54 +0000 (-0600) Subject: Image type bug fixes X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=86f963c5acad2b6ffe25598f19c455b483e18de2;p=tweepy.git Image type bug fixes --- diff --git a/tweepy/api.py b/tweepy/api.py index 1bb16e0..b426d79 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -221,7 +221,7 @@ class API(object): """ f = kwargs.pop('file', None) - file_type = imghdr.what(filename) or mimetypes.guess_type(filename)[0] + file_type = imghdr.what(filename, h=f.read()) or mimetypes.guess_type(filename)[0] if file_type == 'gif': max_size = 14649 else: @@ -828,7 +828,7 @@ class API(object): allowed_param=['cursor'], require_auth=True ) - + @property def mutes(self): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/mute-block-report-users/api-reference/get-mutes-users-list @@ -841,7 +841,7 @@ class API(object): allowed_param=['cursor', 'include_entities', 'skip_status'], required_auth=True ) - + @property def create_mute(self): @@ -1288,7 +1288,7 @@ class API(object): 'max_id', 'until', 'result_type', 'count', 'include_entities'] ) - + @pagination(mode='next') def search_30_day(self, environment_name, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/tweets/search/api-reference/premium-search @@ -1303,7 +1303,7 @@ class API(object): 'next'], require_auth=True )(*args, **kwargs) - + @pagination(mode='next') def search_full_archive(self, environment_name, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/tweets/search/api-reference/premium-search @@ -1418,7 +1418,7 @@ class API(object): # image must be gif, jpeg, png, webp if not file_type: - file_type = imghdr.what(filename, h=f) or mimetypes.guess_type(filename)[0] + file_type = imghdr.what(filename, h=f.read()) or mimetypes.guess_type(filename)[0] if file_type is None: raise TweepError('Could not determine file type') if file_type in ['gif', 'jpeg', 'png', 'webp']: