henniaufmrenni / boum

a sleek and modern music app for Jellyfin
https://eindm.de/boum
Mozilla Public License 2.0
78 stars 0 forks source link

[Feat]: Better mimetype parsing for downloads #73

Closed henniaufmrenni closed 1 year ago

henniaufmrenni commented 1 year ago

Description

Currently we're simply parsing the audio/${mimeType} mimetype and appending the mimetype as the file extensions. This method works well for containers where the file extension matches the mimetype - for example flac - but for containers where these don't match - like mp3 which uses audio/mpeg - this leads to undesirable behaviours. For example downloads with an .mpeg - while totally playable - extensions are shown in the gallery.

We should thus maintain a list which maps mimetype to extension for the most common containers and parse them for example like this:

const parseMimeType = (headers: Headers): string => {
  const mimeType = headers['Content-Type'].slice(6);
  if (mimeType === 'mpeg') {
  return '.mp3' 
  } else if (...) {
  ... 
  } else {
  return mimeType  
  }
}

Reference: https://github.com/jellyfin/jellyfin/blob/master/MediaBrowser.Model/Net/MimeTypes.cs

Understanding that boum is open-source software