Add missing MIME types for comicbook formats (#11010)

* Correct MIME types for comicbook file extensions

cb7, cba, cbr, cbt and cbz all refer to different types of digital
comicbooks. The last letter of the extension indicates the compression
algorithm that was used: 7zip, arc, rar, tar or zip.

All these filetypes used to have the `application/x-cbr` MIME type
assigned to them. However, that has since been deprecated and was
replaced with

- `application/vnd.comicbook-rar` for rar compressed files and
- `application/vnd.comicbook+zip` for rar compressed files.

Only these two are officially listed by IANA

https://www.iana.org/assignments/media-types/application/vnd.comicbook+zip

. cbr and cbz are by far the most common file extensions for comicbooks.

There's no official MIME type for cb7, cba or cbt files. However, with
rar being a proprietary compression algorithm, FOSS applications will
often refuse to handle files that identify themselves as
`application/x-cbr`, so I decided to assign extension specific MIME
types to them. I've seen these being used by other applications,
specifically comic book readers.

I've read through the docs on iana.org, but haven't figured out why they
chose `-rar`, but `+zip`.

* Add conversions from MIME type to file extensions for comicbook formats

cb7, cba, cbr, cbt and cbz all refer to different types of digital
comicbooks. The last letter of the extension indicates the compression
algorithm that was used: 7zip, arc, rar, tar or zip.

All these filetypes used to have the `application/x-cbr` MIME type
assigned to them. However, that has since been deprecated and was
replaced with

- `application/vnd.comicbook-rar` for rar compressed files and
- `application/vnd.comicbook+zip` for rar compressed files.

Only these two are officially listed by IANA

https://www.iana.org/assignments/media-types/application/vnd.comicbook+zip

. cbr and cbz are by far the most common file extensions for comicbooks.

There's no official MIME type for cb7, cba or cbt files. However, with
rar being a proprietary compression algorithm, FOSS applications will
often refuse to handle files that identify themselves as
`application/x-cbr`, so I decided to assign extension specific MIME
types to them. I've seen these being used by other applications,
specifically comic book readers.

* Update CONTRIBUTORS.md
This commit is contained in:
Robert Lützner 2024-02-15 22:15:14 +00:00 committed by GitHub
parent 6c1025f2cd
commit 2bd85df383
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 23 additions and 0 deletions

View File

@ -251,3 +251,4 @@
- [Utku Özdemir](https://github.com/utkuozdemir)
- [JPUC1143](https://github.com/Jpuc1143/)
- [0x25CBFC4F](https://github.com/0x25CBFC4F)
- [Robert Lützner](https://github.com/rluetzner)

View File

@ -66,6 +66,11 @@ namespace MediaBrowser.Model.Net
{
// Type application
{ ".azw3", "application/vnd.amazon.ebook" },
{ ".cb7", "application/x-cb7" },
{ ".cba", "application/x-cba" },
{ ".cbr", "application/vnd.comicbook-rar" },
{ ".cbt", "application/x-cbt" },
{ ".cbz", "application/vnd.comicbook+zip" },
// Type image
{ ".tbn", "image/jpeg" },
@ -98,6 +103,12 @@ namespace MediaBrowser.Model.Net
private static readonly Dictionary<string, string> _extensionLookup = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
{
// Type application
{ "application/vnd.comicbook-rar", ".cbr" },
{ "application/vnd.comicbook+zip", ".cbz" },
{ "application/x-cb7", ".cb7" },
{ "application/x-cba", ".cba" },
{ "application/x-cbr", ".cbr" },
{ "application/x-cbt", ".cbt" },
{ "application/x-cbz", ".cbz" },
{ "application/x-javascript", ".js" },
{ "application/xml", ".xml" },

View File

@ -6,6 +6,11 @@ namespace Jellyfin.Model.Tests.Net
public class MimeTypesTests
{
[Theory]
[InlineData(".cb7", "application/x-cb7")]
[InlineData(".cba", "application/x-cba")]
[InlineData(".cbr", "application/vnd.comicbook-rar")]
[InlineData(".cbt", "application/x-cbt")]
[InlineData(".cbz", "application/vnd.comicbook+zip")]
[InlineData(".dll", "application/octet-stream")]
[InlineData(".log", "text/plain")]
[InlineData(".srt", "application/x-subrip")]
@ -94,10 +99,16 @@ namespace Jellyfin.Model.Tests.Net
[InlineData("application/pdf", ".pdf")]
[InlineData("application/ttml+xml", ".ttml")]
[InlineData("application/vnd.amazon.ebook", ".azw")]
[InlineData("application/vnd.comicbook-rar", ".cbr")]
[InlineData("application/vnd.comicbook+zip", ".cbz")]
[InlineData("application/vnd.ms-fontobject", ".eot")]
[InlineData("application/vnd.rar", ".rar")]
[InlineData("application/wasm", ".wasm")]
[InlineData("application/x-7z-compressed", ".7z")]
[InlineData("application/x-cb7", ".cb7")]
[InlineData("application/x-cba", ".cba")]
[InlineData("application/x-cbr", ".cbr")]
[InlineData("application/x-cbt", ".cbt")]
[InlineData("application/x-cbz", ".cbz")]
[InlineData("application/x-javascript", ".js")]
[InlineData("application/x-mobipocket-ebook", ".mobi")]