mirror of
https://github.com/k4yt3x/video2x.git
synced 2025-11-03 14:10:59 +01:00
use mimetypes when python-magic binaries are not found
This commit is contained in:
parent
e646825c57
commit
8fd3292cd6
@ -4,7 +4,7 @@
|
|||||||
Name: Video2X Upscaler
|
Name: Video2X Upscaler
|
||||||
Author: K4YT3X
|
Author: K4YT3X
|
||||||
Date Created: December 10, 2018
|
Date Created: December 10, 2018
|
||||||
Last Modified: May 29, 2020
|
Last Modified: June 4, 2020
|
||||||
|
|
||||||
Description: This file contains the Upscaler class. Each
|
Description: This file contains the Upscaler class. Each
|
||||||
instance of the Upscaler class is an upscaler on an image or
|
instance of the Upscaler class is an upscaler on an image or
|
||||||
@ -50,7 +50,7 @@ language.install()
|
|||||||
_ = language.gettext
|
_ = language.gettext
|
||||||
|
|
||||||
# version information
|
# version information
|
||||||
UPSCALER_VERSION = '4.2.0'
|
UPSCALER_VERSION = '4.2.1'
|
||||||
|
|
||||||
# these names are consistent for
|
# these names are consistent for
|
||||||
# - driver selection in command line
|
# - driver selection in command line
|
||||||
@ -469,9 +469,12 @@ class Upscaler:
|
|||||||
self.current_input_file, output_path = self.processing_queue.get()
|
self.current_input_file, output_path = self.processing_queue.get()
|
||||||
|
|
||||||
# get file type
|
# get file type
|
||||||
|
try:
|
||||||
input_file_mime_type = magic.from_file(str(self.current_input_file.absolute()), mime=True)
|
input_file_mime_type = magic.from_file(str(self.current_input_file.absolute()), mime=True)
|
||||||
input_file_type = input_file_mime_type.split('/')[0]
|
input_file_type = input_file_mime_type.split('/')[0]
|
||||||
input_file_subtype = input_file_mime_type.split('/')[1]
|
input_file_subtype = input_file_mime_type.split('/')[1]
|
||||||
|
except magic.magic.MagicException:
|
||||||
|
input_file_type = input_file_subtype = None
|
||||||
|
|
||||||
# in case python-magic fails to detect file type
|
# in case python-magic fails to detect file type
|
||||||
# try guessing file mime type with mimetypes
|
# try guessing file mime type with mimetypes
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
Creator: Video2X GUI
|
Creator: Video2X GUI
|
||||||
Author: K4YT3X
|
Author: K4YT3X
|
||||||
Date Created: May 5, 2020
|
Date Created: May 5, 2020
|
||||||
Last Modified: May 26, 2020
|
Last Modified: June 4, 2020
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
@ -32,7 +32,7 @@ from PyQt5.QtGui import *
|
|||||||
from PyQt5.QtWidgets import *
|
from PyQt5.QtWidgets import *
|
||||||
import magic
|
import magic
|
||||||
|
|
||||||
GUI_VERSION = '2.5.0'
|
GUI_VERSION = '2.5.1'
|
||||||
|
|
||||||
LEGAL_INFO = f'''Video2X GUI Version: {GUI_VERSION}\\
|
LEGAL_INFO = f'''Video2X GUI Version: {GUI_VERSION}\\
|
||||||
Upscaler Version: {UPSCALER_VERSION}\\
|
Upscaler Version: {UPSCALER_VERSION}\\
|
||||||
@ -131,9 +131,12 @@ class InputTableModel(QAbstractTableModel):
|
|||||||
# if path is single file
|
# if path is single file
|
||||||
# determine file type
|
# determine file type
|
||||||
elif file_path.is_file():
|
elif file_path.is_file():
|
||||||
|
try:
|
||||||
input_file_mime_type = magic.from_file(str(file_path.absolute()), mime=True)
|
input_file_mime_type = magic.from_file(str(file_path.absolute()), mime=True)
|
||||||
input_file_type = input_file_mime_type.split('/')[0]
|
input_file_type = input_file_mime_type.split('/')[0]
|
||||||
input_file_subtype = input_file_mime_type.split('/')[1]
|
input_file_subtype = input_file_mime_type.split('/')[1]
|
||||||
|
except magic.magic.MagicException:
|
||||||
|
input_file_type = input_file_subtype = None
|
||||||
|
|
||||||
# in case python-magic fails to detect file type
|
# in case python-magic fails to detect file type
|
||||||
# try guessing file mime type with mimetypes
|
# try guessing file mime type with mimetypes
|
||||||
@ -890,9 +893,12 @@ class Video2XMainWindow(QMainWindow):
|
|||||||
if input_path.is_file():
|
if input_path.is_file():
|
||||||
|
|
||||||
# generate suffix automatically
|
# generate suffix automatically
|
||||||
|
try:
|
||||||
input_file_mime_type = magic.from_file(str(input_path.absolute()), mime=True)
|
input_file_mime_type = magic.from_file(str(input_path.absolute()), mime=True)
|
||||||
input_file_type = input_file_mime_type.split('/')[0]
|
input_file_type = input_file_mime_type.split('/')[0]
|
||||||
input_file_subtype = input_file_mime_type.split('/')[1]
|
input_file_subtype = input_file_mime_type.split('/')[1]
|
||||||
|
except magic.magic.MagicException:
|
||||||
|
input_file_type = input_file_subtype = None
|
||||||
|
|
||||||
# in case python-magic fails to detect file type
|
# in case python-magic fails to detect file type
|
||||||
# try guessing file mime type with mimetypes
|
# try guessing file mime type with mimetypes
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user