How to add a new mime type for specific extension?

I follow the steps Here.

This is my m3u.xml file

<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
  <mime-type type="video/m3u">
    <sub-class-of type="video/mp4"/>
    <glob pattern="*.m3u"/>
    <comment>m3u file</comment>
  </mime-type>
</mime-info>

After I run command update-mime-database ~/.local/share/mime/.
Seems not work.

> file -bL --mime-type pl.m3u                                      ─╯
text/plain

How to fix it?

It is my (very limited) understanding that file does not include file extensions in its tests to determine a file type. You may get something more like the result you are expecting from something like

xdg-mime query filetype pl.m3u

I also note that Wikipedia states that

An M3U file is a plain text file …

and

The only Internet media type registered for M3U and M3U8 is application/vnd.apple.mpegurl

So I am curious as to what you hope to accomplish.

2 Likes

That is correct. file looks at the starting bytes of the file itself to determine what type of file it is.

That is correct as well. An .m3u filename suffix — note to the OP: “filename suffix”, not “extension”, which is a Microsoftism™ — is merely a convention that allows multimedia players to recognize the file as being a playlist.

It is indeed nothing other than a plain text file with a list of filespecs.

5 Likes

…and thus magic is forever removed from the equation…

1 Like

Any way to change the file type get by file command?

Yes — change the nature of the file. :stuck_out_tongue:

Look, perhaps we need to make it more clear to you. The command file reads the first couple of bytes of the target file and compares those to a database with “magic bytes”, which indicate which file it is.

An .m3u file does not have any “magic bytes” because it is a plain text file. And that is exactly how it should be regarded by the operating system. Tampering with this mechanism would be a security hazard.

1 Like

This seems like an xy problem. What are you trying to do?

3 Likes

I am 100% convinced that it is. :+1:

2 Likes

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.