Browse Source

Use strict=False

master
blank X 1 year ago
parent
commit
fb1b228d5b
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
  1. 4
      redditbot.py

4
redditbot.py

@ -219,7 +219,7 @@ async def main():
file.write(chunk)
async def _get_file_mimetype(filename):
mimetype = mimetypes.guess_type(filename)[0]
mimetype = mimetypes.guess_type(filename, strict=False)[0]
if not mimetype:
proc = await asyncio.create_subprocess_exec('file', '--brief', '--mime-type', filename, stdout=asyncio.subprocess.PIPE)
stdout, _ = await proc.communicate()
@ -232,7 +232,7 @@ async def main():
ext = stdout.decode().strip().split('/', maxsplit=1)[0]
if not ext or ext == '???':
mimetype = await _get_file_mimetype(filename)
ext = mimetypes.guess_extension(mimetype) or '.bin'
ext = mimetypes.guess_extension(mimetype, strict=False) or '.bin'
if not ext.startswith('.'):
ext = '.' + ext
return ext

Loading…
Cancel
Save