diff --git a/CHANGELOG b/CHANGELOG index c02e7665e..1b98df96e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,17 @@ Changelog ---------------- +0.5.2 (2018-02-26) +------------------ + +- Fixed broken file import due to wrong url (#73) +- More accurate mimetype detection +- Fixed really small size on small screens +- Added masonry layout for artists, requests and radios (#68) +- We now have a favicon! +- Fixed truncated play icon (#65) + + 0.5.1 (2018-02-24) ------------------ diff --git a/api/funkwhale_api/__init__.py b/api/funkwhale_api/__init__.py index d3e404f12..2df7e2034 100644 --- a/api/funkwhale_api/__init__.py +++ b/api/funkwhale_api/__init__.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- -__version__ = '0.5.1' +__version__ = '0.5.2' __version_info__ = tuple([int(num) if num.isdigit() else num for num in __version__.replace('-', '.', 1).split('.')]) diff --git a/api/funkwhale_api/music/utils.py b/api/funkwhale_api/music/utils.py index a75cf5de8..df659cb80 100644 --- a/api/funkwhale_api/music/utils.py +++ b/api/funkwhale_api/music/utils.py @@ -1,4 +1,5 @@ import magic +import mimetypes import re from django.db.models import Q @@ -42,7 +43,13 @@ def get_query(query_string, search_fields): def guess_mimetype(f): b = min(100000, f.size) - return magic.from_buffer(f.read(b), mime=True) + t = magic.from_buffer(f.read(b), mime=True) + if t == 'application/octet-stream': + # failure, we try guessing by extension + mt, _ = mimetypes.guess_type(f.path) + if mt: + t = mt + return t def compute_status(jobs): diff --git a/api/tests/music/test_utils.py b/api/tests/music/test_utils.py new file mode 100644 index 000000000..0a4f4b994 --- /dev/null +++ b/api/tests/music/test_utils.py @@ -0,0 +1,19 @@ +from funkwhale_api.music import utils + + +def test_guess_mimetype_try_using_extension(factories, mocker): + mocker.patch( + 'magic.from_buffer', return_value='audio/mpeg') + f = factories['music.TrackFile'].build( + audio_file__filename='test.ogg') + + assert utils.guess_mimetype(f.audio_file) == 'audio/mpeg' + + +def test_guess_mimetype_try_using_extension_if_fail(factories, mocker): + mocker.patch( + 'magic.from_buffer', return_value='application/octet-stream') + f = factories['music.TrackFile'].build( + audio_file__filename='test.mp3') + + assert utils.guess_mimetype(f.audio_file) == 'audio/mpeg' diff --git a/front/index.html b/front/index.html index 55e32a7ee..da815d619 100644 --- a/front/index.html +++ b/front/index.html @@ -3,6 +3,8 @@