Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' of git://github.com/tgbot-collection/python-twi…
Browse files Browse the repository at this point in the history
…tter into tgbot-collection-master
  • Loading branch information
bear committed Dec 19, 2021
2 parents 0b325af + 913644a commit c6c87fe
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
requests
requests-oauthlib
filetype
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def extract_metaitem(meta):
download_url=extract_metaitem('download_url'),
packages=find_packages(exclude=('tests', 'docs')),
platforms=['Any'],
install_requires=['requests', 'requests-oauthlib'],
install_requires=['requests', 'requests-oauthlib', 'filetype'],
tests_require=['pytest'],
keywords='twitter api',
classifiers=[
Expand Down
7 changes: 2 additions & 5 deletions twitter/twitter_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""Collection of utilities for use in API calls, functions."""
from __future__ import unicode_literals

import mimetypes
import filetype
import os
import re
import sys
Expand Down Expand Up @@ -274,10 +274,7 @@ def parse_media_file(passed_media, async_upload=False):
except Exception as e:
pass

media_type = mimetypes.guess_type(os.path.basename(filename))[0]
# The .srt extension is not recognised by the mimetypes module.
if os.path.basename(filename).endswith('.srt'):
media_type = 'text/srt'
media_type = filetype.guess_mime(data_file.name)
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.'})
Expand Down

0 comments on commit c6c87fe

Please sign in to comment.