From 4bc9b5c0d2e8b24700aa1a2283b9eeda55d17204 Mon Sep 17 00:00:00 2001 From: blank X Date: Sun, 13 Dec 2020 21:34:55 +0700 Subject: [PATCH] Revert "Use ffprobe to try to get file extension" This reverts commit 1caef9097bc25f0fa33416e17c75ffab32323ba3. --- redditbot.py | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/redditbot.py b/redditbot.py index e70dcb7..8075c59 100644 --- a/redditbot.py +++ b/redditbot.py @@ -230,22 +230,6 @@ async def main(): proc = await asyncio.create_subprocess_exec('file', '--brief', '--extension', filename, stdout=asyncio.subprocess.PIPE) stdout, _ = await proc.communicate() ext = stdout.decode().strip().split('/', maxsplit=1)[0] - if not ext or ext == '???': - ffprobe_exists = any(True for i in os.environ.get('PATH', '').split(':') if os.path.exists(os.path.join(i, 'ffprobe'))) - if ffprobe_exists: - proc = await asyncio.create_subprocess_exec('ffprobe', '-print_format', 'json', '-show_format', filename, stdout=asyncio.subprocess.PIPE) - stdout, _ = await proc.communicate() - format = json.loads(stdout).get('format') - if format: - format_name = format.get('format_name') - if format_name: - proc = await asyncio.create_subprocess_exec('ffprobe', '-h', f'demuxer={format_name}', stdout=asyncio.subprocess.PIPE) - stdout, _ = await proc.communicate() - text = stdout.decode().split('\n', 2) - if len(text) > 1: - text = text[1].strip().rstrip('.') - if text.startswith('Common extensions: '): - ext = text[19:].split(',', 1)[0] if not ext or ext == '???': mimetype = await _get_file_mimetype(filename) ext = mimetypes.guess_extension(mimetype) or '.bin'