guessit icon indicating copy to clipboard operation
guessit copied to clipboard

SVG handling

Open jayvdb opened this issue 8 years ago • 8 comments

SVG's are partially understood, with the correct mime type.

e.g. https://upload.wikimedia.org/wikipedia/commons/e/e9/Brodnopis_i_pioro.svg results are

$ guessit Brodnopis_i_pioro.svg
For: Brodnopis_i_pioro.svg
GuessIt found: {
    "title": "Brodnopis i pioro svg", 
    "mimetype": "image/svg+xml", 
    "type": "movie"
}

However it isn't a movie, and the title should not contain svg as that was from the extension.

jayvdb avatar Jun 06 '16 08:06 jayvdb

This is possibly related to #273

jayvdb avatar Jun 06 '16 08:06 jayvdb

why do you try to feed guessit with svg files ? I'm not sure it's guessit responsibility to filter out image filetypes.

Toilal avatar Jun 07 '16 14:06 Toilal

It would be nice to use guessit as part of heuristics to guess whether a file (on a remote server) of an unknown type is likely to be a movie, or some other class, as it is incredibly cheap to run guessit compared to downloading and analysing the file. .svg is just an example. It would be great if guessit said 'unknown' for types it doesnt recognise. If you're not interested, feel free to close.

jayvdb avatar Jun 07 '16 14:06 jayvdb

I think it was the behavior in guessit 1.x, but this "feature" has been dropped during the 2.x rewriting. I let the issue open, i'll think about it.

Toilal avatar Jun 07 '16 15:06 Toilal

@Toilal detection of image media types would be helpful for show-art

labrys avatar Jun 07 '16 22:06 labrys

I understand and it make sense. It could be based on mimetype, but i fear that it may leads to inconsistent results because mimetype property is delegated to native implementation, and various OS may lead to various results.

Maybe we could use a pure python library for mimetype guessing, and then rely on this to solve this issue.

Toilal avatar Jun 08 '16 12:06 Toilal

Maybe this can be useful: https://github.com/cdgriffith/puremagic

Shouldn't we detect image extensions as containers as well?

ratoaq2 avatar Feb 11 '18 07:02 ratoaq2

Kinda forgot about this issue, but @Toilal for filenames you could use mimetypes from the standard library to create your own mimetype registry so results are consistent across all platforms. It would take a little leg work to add any desired types, but shouldnt be too troublesome.

~~@ratoaq2 puremagic wouldn't work for instances where you just have the name but have not yet downloaded the file.~~

It looks like puremagic also does filename matching, so that could be an option too.

labrys avatar Jun 10 '20 22:06 labrys