vnrecode: rewrite get_type method
This commit is contained in:
parent
a69b17c624
commit
03647d4b84
1 changed files with 11 additions and 12 deletions
|
@ -8,19 +8,18 @@ class File:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_type(filename):
|
def get_type(filename):
|
||||||
audio_ext = ['.aac', '.flac', '.m4a', '.mp3', '.ogg', '.opus', '.raw', '.wav', '.wma']
|
|
||||||
image_ext = ['.apng', '.avif', '.bmp', '.tga', '.tiff', '.dds', '.svg', '.webp', '.jpg', '.jpeg', '.png']
|
|
||||||
video_ext = ['.3gp' '.amv', '.avi', '.m2t', '.m4v', '.mkv', '.mov', '.mp4', '.m4v', '.mpeg', '.mpv',
|
|
||||||
'.webm', '.ogv']
|
|
||||||
|
|
||||||
if os.path.splitext(filename)[1] in audio_ext:
|
extensions = {
|
||||||
return "audio"
|
"audio": ['.aac', '.flac', '.m4a', '.mp3', '.ogg', '.opus', '.raw', '.wav', '.wma'],
|
||||||
elif os.path.splitext(filename)[1] in image_ext:
|
"image": ['.apng', '.avif', '.bmp', '.tga', '.tiff', '.dds', '.svg', '.webp', '.jpg', '.jpeg', '.png'],
|
||||||
return "image"
|
"video": ['.3gp' '.amv', '.avi', '.m2t', '.m4v', '.mkv', '.mov', '.mp4', '.m4v', '.mpeg', '.mpv',
|
||||||
elif os.path.splitext(filename)[1] in video_ext:
|
'.webm', '.ogv']
|
||||||
return "video"
|
}
|
||||||
else:
|
|
||||||
return "unknown"
|
for file_type in extensions:
|
||||||
|
if os.path.splitext(filename)[1] in extensions[file_type]:
|
||||||
|
return file_type
|
||||||
|
return "unknown"
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def has_transparency(img: Image) -> bool:
|
def has_transparency(img: Image) -> bool:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue