Giter VIP home page Giter VIP logo

Comments (1)

mbeijen avatar mbeijen commented on September 28, 2024 1

Hi, thanks for opening your issue.
The problem is that the 'magic' tests are detecting your file as video/mp2t. You can check this with the --debug --all flags; the --debug provides you with more info about where the result was obtained from and the --all flag makes sure that all types of detection are used.

By default, mimetype will try to use the mimeinfo database from freedesktop, that source correctly determines the file as being 'text'. You do not have the mimeinfo database installed, you can install it on Ubuntu using apt install desktop-file-utils. It is pre-installed with most graphical desktops on Ubuntu.

The magic database, which incorrectly labels the file as video/mp2t, is not part of this Perl module; it is used by the file command. However the file command uses different heuristics before it tries to use the magic database, it uses a stat first.

I hope this helps... even if a little.

$ mimetype --debug --all  out.txt
> Data dirs are: /home/michiel/.local/share, /usr/share/gnome, /usr/local/share, /usr/share
> Checking inode type
> Checking globs for basename 'out.txt'
> Checking for extension '.txt'
out.txt: text/plain
> Checking all magic rules
> Value "G" at offset 5 matches at /usr/share/mime/magic line 1695
>> Value "G" at offset 197 matches at /usr/share/mime/magic line 1696
>>> Value "G" at offset 389 matches at /usr/share/mime/magic line 1697
>>>> Value "G" at offset 581 matches at /usr/share/mime/magic line 1698
>>>>> Value "G" at offset 773 matches at /usr/share/mime/magic line 1699
out.txt: video/mp2t
> File exists, trying default method
out.txt: text/plain

from file-mimeinfo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.