Check if a file type is a media file?How to find the mime type of a file in python?How do I check if a list is empty?How do I check whether a file exists without exceptions?What's the canonical way to check for type in Python?How do I check if a string is a number (float)?Check if a given key already exists in a dictionaryDetermine the type of an object?How do I list all files of a directory?How to read a file line-by-line into a list?Delete a file or folder.endswith missing file extention in a loop
Noob at soldering, can anyone explain why my circuit won't work?
Understanding basic photoresistor circuit
What does this quote in Small Gods refer to?
Will change of address affect direct deposit?
Can the sorting of a list be verified without comparing neighbors?
Thesis' "Future Work" section – is it acceptable to omit personal involvement in a mentioned project?
How to make the table in the figure in LaTeX?
What is the difference between "Plural" and "Mehrzahl"?
Pre-1993 comic in which Wolverine's claws were turned to rubber?
Was there ever any real use for a 6800-based Apple I?
How to make a language evolve quickly?
Can I do brevets (long distance rides) on my hybrid bike? If yes, how to start?
How can a Lich look like a human without magic?
How do I compare the result of "1d20+x, with advantage" to "1d20+y, without advantage", assuming x < y?
Should these notes be played as a chord or one after another?
Why use steam instead of just hot air?
histogram using edges
Cropping a message using array splits
What is the best way for a skeleton to impersonate human without using magic?
Why in a Ethernet LAN, a packet sniffer can obtain all packets sent over the LAN?
Control variables and other independent variables
Make all the squares explode
Why does a C.D.F need to be right-continuous?
Adding slope values to attribute table (QGIS 3)
Check if a file type is a media file?
How to find the mime type of a file in python?How do I check if a list is empty?How do I check whether a file exists without exceptions?What's the canonical way to check for type in Python?How do I check if a string is a number (float)?Check if a given key already exists in a dictionaryDetermine the type of an object?How do I list all files of a directory?How to read a file line-by-line into a list?Delete a file or folder.endswith missing file extention in a loop
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I am trying to loop through a list of files, and return those files that are media files (images, video, gif, audio, etc.).
Seeing as there are a lot of media types, is there a library or perhaps better way to check this, than listing all types then checking a file against that list?
Here's what I'm doing so far:
import os
types = [".mp3", ".mpeg", ".gif", ".jpg", ".jpeg"]
files = ["test.mp3", "test.tmp", "filename.mpg", ".AutoConfig"]
media_files = []
for file in files:
root, extention = os.path.splitext(file)
print(extention)
if extention in types:
media_files.append(file)
print("Found media files are:")
print(media_files)
But note it didn't include filename.mpg
, since I forgot to put .mpg
in my types
list. (Or, more likely, I didn't expect that list to include a .mpg
file, so didn't think to list it out.)
python python-3.x
|
show 1 more comment
I am trying to loop through a list of files, and return those files that are media files (images, video, gif, audio, etc.).
Seeing as there are a lot of media types, is there a library or perhaps better way to check this, than listing all types then checking a file against that list?
Here's what I'm doing so far:
import os
types = [".mp3", ".mpeg", ".gif", ".jpg", ".jpeg"]
files = ["test.mp3", "test.tmp", "filename.mpg", ".AutoConfig"]
media_files = []
for file in files:
root, extention = os.path.splitext(file)
print(extention)
if extention in types:
media_files.append(file)
print("Found media files are:")
print(media_files)
But note it didn't include filename.mpg
, since I forgot to put .mpg
in my types
list. (Or, more likely, I didn't expect that list to include a .mpg
file, so didn't think to list it out.)
python python-3.x
Yes, you can you mimetype check. Here is a example: stackoverflow.com
– Cpp Forever
Mar 22 at 21:25
If you're running on UNIX/Linux, you can usefile
to determine media type.
– tk421
Mar 22 at 21:26
@CppForever - I found that, and am studying that library, but am not sure how to check without something like -if mime.from_file("media.mp3") == "application/mp3" or ...:
? I am missing understanding something I think...
– BruceWayne
Mar 22 at 21:26
1
@CppForever so do I just heck generally "is the file a mime type" without having to check exactly what kind?
– BruceWayne
Mar 22 at 21:41
1
After you get mime type for example audio/mp3 you can split by / character and get the first part and check if it is audio or video or image
– Cpp Forever
Mar 22 at 21:43
|
show 1 more comment
I am trying to loop through a list of files, and return those files that are media files (images, video, gif, audio, etc.).
Seeing as there are a lot of media types, is there a library or perhaps better way to check this, than listing all types then checking a file against that list?
Here's what I'm doing so far:
import os
types = [".mp3", ".mpeg", ".gif", ".jpg", ".jpeg"]
files = ["test.mp3", "test.tmp", "filename.mpg", ".AutoConfig"]
media_files = []
for file in files:
root, extention = os.path.splitext(file)
print(extention)
if extention in types:
media_files.append(file)
print("Found media files are:")
print(media_files)
But note it didn't include filename.mpg
, since I forgot to put .mpg
in my types
list. (Or, more likely, I didn't expect that list to include a .mpg
file, so didn't think to list it out.)
python python-3.x
I am trying to loop through a list of files, and return those files that are media files (images, video, gif, audio, etc.).
Seeing as there are a lot of media types, is there a library or perhaps better way to check this, than listing all types then checking a file against that list?
Here's what I'm doing so far:
import os
types = [".mp3", ".mpeg", ".gif", ".jpg", ".jpeg"]
files = ["test.mp3", "test.tmp", "filename.mpg", ".AutoConfig"]
media_files = []
for file in files:
root, extention = os.path.splitext(file)
print(extention)
if extention in types:
media_files.append(file)
print("Found media files are:")
print(media_files)
But note it didn't include filename.mpg
, since I forgot to put .mpg
in my types
list. (Or, more likely, I didn't expect that list to include a .mpg
file, so didn't think to list it out.)
python python-3.x
python python-3.x
asked Mar 22 at 21:22
BruceWayneBruceWayne
18.2k113464
18.2k113464
Yes, you can you mimetype check. Here is a example: stackoverflow.com
– Cpp Forever
Mar 22 at 21:25
If you're running on UNIX/Linux, you can usefile
to determine media type.
– tk421
Mar 22 at 21:26
@CppForever - I found that, and am studying that library, but am not sure how to check without something like -if mime.from_file("media.mp3") == "application/mp3" or ...:
? I am missing understanding something I think...
– BruceWayne
Mar 22 at 21:26
1
@CppForever so do I just heck generally "is the file a mime type" without having to check exactly what kind?
– BruceWayne
Mar 22 at 21:41
1
After you get mime type for example audio/mp3 you can split by / character and get the first part and check if it is audio or video or image
– Cpp Forever
Mar 22 at 21:43
|
show 1 more comment
Yes, you can you mimetype check. Here is a example: stackoverflow.com
– Cpp Forever
Mar 22 at 21:25
If you're running on UNIX/Linux, you can usefile
to determine media type.
– tk421
Mar 22 at 21:26
@CppForever - I found that, and am studying that library, but am not sure how to check without something like -if mime.from_file("media.mp3") == "application/mp3" or ...:
? I am missing understanding something I think...
– BruceWayne
Mar 22 at 21:26
1
@CppForever so do I just heck generally "is the file a mime type" without having to check exactly what kind?
– BruceWayne
Mar 22 at 21:41
1
After you get mime type for example audio/mp3 you can split by / character and get the first part and check if it is audio or video or image
– Cpp Forever
Mar 22 at 21:43
Yes, you can you mimetype check. Here is a example: stackoverflow.com
– Cpp Forever
Mar 22 at 21:25
Yes, you can you mimetype check. Here is a example: stackoverflow.com
– Cpp Forever
Mar 22 at 21:25
If you're running on UNIX/Linux, you can use
file
to determine media type.– tk421
Mar 22 at 21:26
If you're running on UNIX/Linux, you can use
file
to determine media type.– tk421
Mar 22 at 21:26
@CppForever - I found that, and am studying that library, but am not sure how to check without something like -
if mime.from_file("media.mp3") == "application/mp3" or ...:
? I am missing understanding something I think...– BruceWayne
Mar 22 at 21:26
@CppForever - I found that, and am studying that library, but am not sure how to check without something like -
if mime.from_file("media.mp3") == "application/mp3" or ...:
? I am missing understanding something I think...– BruceWayne
Mar 22 at 21:26
1
1
@CppForever so do I just heck generally "is the file a mime type" without having to check exactly what kind?
– BruceWayne
Mar 22 at 21:41
@CppForever so do I just heck generally "is the file a mime type" without having to check exactly what kind?
– BruceWayne
Mar 22 at 21:41
1
1
After you get mime type for example audio/mp3 you can split by / character and get the first part and check if it is audio or video or image
– Cpp Forever
Mar 22 at 21:43
After you get mime type for example audio/mp3 you can split by / character and get the first part and check if it is audio or video or image
– Cpp Forever
Mar 22 at 21:43
|
show 1 more comment
2 Answers
2
active
oldest
votes
For this purpose you need to get internet media type for file, split it by / character and check if it starts with audio,video,image.
Here is a sample code:
import mimetypes
mimetypes.init()
mimestart = mimetypes.guess_type("test.mp3")[0]
if mimestart != None:
mimestart = mimestart.split('/')[0]
if mimestart == 'audio' or mimestart == 'video' or mimestart == 'image':
print("media types")
NOTE: This method assume the file type by its extension and don't open the actual file, it is based only on the file extension
1
You should check forNone
(i.e. unknown type) when using guess_type. However, you should note that this method will only check the extension, so it cannot detect the file's actual type.
– ekhumoro
Mar 22 at 22:47
Whilemimetypes
does exactly what the OP asks, maybe also point to pypi.org/project/python-libmagic which inspects file contents, not just the filename.libmagic
is the library behind the Unixfile
command.
– tripleee
Mar 23 at 10:44
1
Thanks so much for this! I really appreciate both answers too, I like this since I know the filetypes and can check without opening the file. Thanks so much! :D
– BruceWayne
Mar 23 at 18:19
1
For anyone - Here's a list of common Web MIME types. And here's a longer list (but I note it doesn't includemp3
for some reason).
– BruceWayne
Mar 23 at 21:52
add a comment |
There is another method that is based not on the file extension but on the file contents using the media type library pypi.org/project/python-libmagic:
Here is the sample code for this library:
import magic
magic = magic.Magic()
mimestart = magic.from_file("test.mp3").split('/')[0]
if mimestart == 'audio' or mimestart == 'video' or mimestart == 'image':
print("media types")
NOTE: for using this code sample you need to install python-libmagic trough pip.
1
I assume this method, where it actually checks the file contents itself, is most often used when you can't trust the extension, for whatever reason? Thanks for this!
– BruceWayne
Mar 23 at 18:27
For example in linux the executables don't have extension but have a signature.
– Cpp Forever
Mar 23 at 18:34
1
ohhh okay! I am running Windows but using raspberry pi so that will likely come in handy. Thanks again!!
– BruceWayne
Mar 23 at 18:54
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55307951%2fcheck-if-a-file-type-is-a-media-file%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
For this purpose you need to get internet media type for file, split it by / character and check if it starts with audio,video,image.
Here is a sample code:
import mimetypes
mimetypes.init()
mimestart = mimetypes.guess_type("test.mp3")[0]
if mimestart != None:
mimestart = mimestart.split('/')[0]
if mimestart == 'audio' or mimestart == 'video' or mimestart == 'image':
print("media types")
NOTE: This method assume the file type by its extension and don't open the actual file, it is based only on the file extension
1
You should check forNone
(i.e. unknown type) when using guess_type. However, you should note that this method will only check the extension, so it cannot detect the file's actual type.
– ekhumoro
Mar 22 at 22:47
Whilemimetypes
does exactly what the OP asks, maybe also point to pypi.org/project/python-libmagic which inspects file contents, not just the filename.libmagic
is the library behind the Unixfile
command.
– tripleee
Mar 23 at 10:44
1
Thanks so much for this! I really appreciate both answers too, I like this since I know the filetypes and can check without opening the file. Thanks so much! :D
– BruceWayne
Mar 23 at 18:19
1
For anyone - Here's a list of common Web MIME types. And here's a longer list (but I note it doesn't includemp3
for some reason).
– BruceWayne
Mar 23 at 21:52
add a comment |
For this purpose you need to get internet media type for file, split it by / character and check if it starts with audio,video,image.
Here is a sample code:
import mimetypes
mimetypes.init()
mimestart = mimetypes.guess_type("test.mp3")[0]
if mimestart != None:
mimestart = mimestart.split('/')[0]
if mimestart == 'audio' or mimestart == 'video' or mimestart == 'image':
print("media types")
NOTE: This method assume the file type by its extension and don't open the actual file, it is based only on the file extension
1
You should check forNone
(i.e. unknown type) when using guess_type. However, you should note that this method will only check the extension, so it cannot detect the file's actual type.
– ekhumoro
Mar 22 at 22:47
Whilemimetypes
does exactly what the OP asks, maybe also point to pypi.org/project/python-libmagic which inspects file contents, not just the filename.libmagic
is the library behind the Unixfile
command.
– tripleee
Mar 23 at 10:44
1
Thanks so much for this! I really appreciate both answers too, I like this since I know the filetypes and can check without opening the file. Thanks so much! :D
– BruceWayne
Mar 23 at 18:19
1
For anyone - Here's a list of common Web MIME types. And here's a longer list (but I note it doesn't includemp3
for some reason).
– BruceWayne
Mar 23 at 21:52
add a comment |
For this purpose you need to get internet media type for file, split it by / character and check if it starts with audio,video,image.
Here is a sample code:
import mimetypes
mimetypes.init()
mimestart = mimetypes.guess_type("test.mp3")[0]
if mimestart != None:
mimestart = mimestart.split('/')[0]
if mimestart == 'audio' or mimestart == 'video' or mimestart == 'image':
print("media types")
NOTE: This method assume the file type by its extension and don't open the actual file, it is based only on the file extension
For this purpose you need to get internet media type for file, split it by / character and check if it starts with audio,video,image.
Here is a sample code:
import mimetypes
mimetypes.init()
mimestart = mimetypes.guess_type("test.mp3")[0]
if mimestart != None:
mimestart = mimestart.split('/')[0]
if mimestart == 'audio' or mimestart == 'video' or mimestart == 'image':
print("media types")
NOTE: This method assume the file type by its extension and don't open the actual file, it is based only on the file extension
edited Mar 23 at 10:44
answered Mar 22 at 21:52
Cpp ForeverCpp Forever
1525
1525
1
You should check forNone
(i.e. unknown type) when using guess_type. However, you should note that this method will only check the extension, so it cannot detect the file's actual type.
– ekhumoro
Mar 22 at 22:47
Whilemimetypes
does exactly what the OP asks, maybe also point to pypi.org/project/python-libmagic which inspects file contents, not just the filename.libmagic
is the library behind the Unixfile
command.
– tripleee
Mar 23 at 10:44
1
Thanks so much for this! I really appreciate both answers too, I like this since I know the filetypes and can check without opening the file. Thanks so much! :D
– BruceWayne
Mar 23 at 18:19
1
For anyone - Here's a list of common Web MIME types. And here's a longer list (but I note it doesn't includemp3
for some reason).
– BruceWayne
Mar 23 at 21:52
add a comment |
1
You should check forNone
(i.e. unknown type) when using guess_type. However, you should note that this method will only check the extension, so it cannot detect the file's actual type.
– ekhumoro
Mar 22 at 22:47
Whilemimetypes
does exactly what the OP asks, maybe also point to pypi.org/project/python-libmagic which inspects file contents, not just the filename.libmagic
is the library behind the Unixfile
command.
– tripleee
Mar 23 at 10:44
1
Thanks so much for this! I really appreciate both answers too, I like this since I know the filetypes and can check without opening the file. Thanks so much! :D
– BruceWayne
Mar 23 at 18:19
1
For anyone - Here's a list of common Web MIME types. And here's a longer list (but I note it doesn't includemp3
for some reason).
– BruceWayne
Mar 23 at 21:52
1
1
You should check for
None
(i.e. unknown type) when using guess_type. However, you should note that this method will only check the extension, so it cannot detect the file's actual type.– ekhumoro
Mar 22 at 22:47
You should check for
None
(i.e. unknown type) when using guess_type. However, you should note that this method will only check the extension, so it cannot detect the file's actual type.– ekhumoro
Mar 22 at 22:47
While
mimetypes
does exactly what the OP asks, maybe also point to pypi.org/project/python-libmagic which inspects file contents, not just the filename. libmagic
is the library behind the Unix file
command.– tripleee
Mar 23 at 10:44
While
mimetypes
does exactly what the OP asks, maybe also point to pypi.org/project/python-libmagic which inspects file contents, not just the filename. libmagic
is the library behind the Unix file
command.– tripleee
Mar 23 at 10:44
1
1
Thanks so much for this! I really appreciate both answers too, I like this since I know the filetypes and can check without opening the file. Thanks so much! :D
– BruceWayne
Mar 23 at 18:19
Thanks so much for this! I really appreciate both answers too, I like this since I know the filetypes and can check without opening the file. Thanks so much! :D
– BruceWayne
Mar 23 at 18:19
1
1
For anyone - Here's a list of common Web MIME types. And here's a longer list (but I note it doesn't include
mp3
for some reason).– BruceWayne
Mar 23 at 21:52
For anyone - Here's a list of common Web MIME types. And here's a longer list (but I note it doesn't include
mp3
for some reason).– BruceWayne
Mar 23 at 21:52
add a comment |
There is another method that is based not on the file extension but on the file contents using the media type library pypi.org/project/python-libmagic:
Here is the sample code for this library:
import magic
magic = magic.Magic()
mimestart = magic.from_file("test.mp3").split('/')[0]
if mimestart == 'audio' or mimestart == 'video' or mimestart == 'image':
print("media types")
NOTE: for using this code sample you need to install python-libmagic trough pip.
1
I assume this method, where it actually checks the file contents itself, is most often used when you can't trust the extension, for whatever reason? Thanks for this!
– BruceWayne
Mar 23 at 18:27
For example in linux the executables don't have extension but have a signature.
– Cpp Forever
Mar 23 at 18:34
1
ohhh okay! I am running Windows but using raspberry pi so that will likely come in handy. Thanks again!!
– BruceWayne
Mar 23 at 18:54
add a comment |
There is another method that is based not on the file extension but on the file contents using the media type library pypi.org/project/python-libmagic:
Here is the sample code for this library:
import magic
magic = magic.Magic()
mimestart = magic.from_file("test.mp3").split('/')[0]
if mimestart == 'audio' or mimestart == 'video' or mimestart == 'image':
print("media types")
NOTE: for using this code sample you need to install python-libmagic trough pip.
1
I assume this method, where it actually checks the file contents itself, is most often used when you can't trust the extension, for whatever reason? Thanks for this!
– BruceWayne
Mar 23 at 18:27
For example in linux the executables don't have extension but have a signature.
– Cpp Forever
Mar 23 at 18:34
1
ohhh okay! I am running Windows but using raspberry pi so that will likely come in handy. Thanks again!!
– BruceWayne
Mar 23 at 18:54
add a comment |
There is another method that is based not on the file extension but on the file contents using the media type library pypi.org/project/python-libmagic:
Here is the sample code for this library:
import magic
magic = magic.Magic()
mimestart = magic.from_file("test.mp3").split('/')[0]
if mimestart == 'audio' or mimestart == 'video' or mimestart == 'image':
print("media types")
NOTE: for using this code sample you need to install python-libmagic trough pip.
There is another method that is based not on the file extension but on the file contents using the media type library pypi.org/project/python-libmagic:
Here is the sample code for this library:
import magic
magic = magic.Magic()
mimestart = magic.from_file("test.mp3").split('/')[0]
if mimestart == 'audio' or mimestart == 'video' or mimestart == 'image':
print("media types")
NOTE: for using this code sample you need to install python-libmagic trough pip.
answered Mar 23 at 11:15
Cpp ForeverCpp Forever
1525
1525
1
I assume this method, where it actually checks the file contents itself, is most often used when you can't trust the extension, for whatever reason? Thanks for this!
– BruceWayne
Mar 23 at 18:27
For example in linux the executables don't have extension but have a signature.
– Cpp Forever
Mar 23 at 18:34
1
ohhh okay! I am running Windows but using raspberry pi so that will likely come in handy. Thanks again!!
– BruceWayne
Mar 23 at 18:54
add a comment |
1
I assume this method, where it actually checks the file contents itself, is most often used when you can't trust the extension, for whatever reason? Thanks for this!
– BruceWayne
Mar 23 at 18:27
For example in linux the executables don't have extension but have a signature.
– Cpp Forever
Mar 23 at 18:34
1
ohhh okay! I am running Windows but using raspberry pi so that will likely come in handy. Thanks again!!
– BruceWayne
Mar 23 at 18:54
1
1
I assume this method, where it actually checks the file contents itself, is most often used when you can't trust the extension, for whatever reason? Thanks for this!
– BruceWayne
Mar 23 at 18:27
I assume this method, where it actually checks the file contents itself, is most often used when you can't trust the extension, for whatever reason? Thanks for this!
– BruceWayne
Mar 23 at 18:27
For example in linux the executables don't have extension but have a signature.
– Cpp Forever
Mar 23 at 18:34
For example in linux the executables don't have extension but have a signature.
– Cpp Forever
Mar 23 at 18:34
1
1
ohhh okay! I am running Windows but using raspberry pi so that will likely come in handy. Thanks again!!
– BruceWayne
Mar 23 at 18:54
ohhh okay! I am running Windows but using raspberry pi so that will likely come in handy. Thanks again!!
– BruceWayne
Mar 23 at 18:54
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55307951%2fcheck-if-a-file-type-is-a-media-file%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Yes, you can you mimetype check. Here is a example: stackoverflow.com
– Cpp Forever
Mar 22 at 21:25
If you're running on UNIX/Linux, you can use
file
to determine media type.– tk421
Mar 22 at 21:26
@CppForever - I found that, and am studying that library, but am not sure how to check without something like -
if mime.from_file("media.mp3") == "application/mp3" or ...:
? I am missing understanding something I think...– BruceWayne
Mar 22 at 21:26
1
@CppForever so do I just heck generally "is the file a mime type" without having to check exactly what kind?
– BruceWayne
Mar 22 at 21:41
1
After you get mime type for example audio/mp3 you can split by / character and get the first part and check if it is audio or video or image
– Cpp Forever
Mar 22 at 21:43