diff --git a/Dockerfile b/Dockerfile index a6abc42..9607b9d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/mgoltzsche/beets-plugins:0.15.0 +FROM ghcr.io/mgoltzsche/beets-plugins:0.18.1 # Install bats USER root:root diff --git a/beetsplug/autogenre/__init__.py b/beetsplug/autogenre/__init__.py index 5cc4713..8a2e3d0 100644 --- a/beetsplug/autogenre/__init__.py +++ b/beetsplug/autogenre/__init__.py @@ -203,8 +203,6 @@ def _item_genres(self, item, all, force, force_genre): if not genre: genre = item.get('genre') source = item.get('genre_source') - orig_genre = genre - orig_source = source if _filter_item(item, all, force): if force_genre is not None: source = force_genre and 'user' or None @@ -273,9 +271,13 @@ def _fix_remix_genre(self, item, genre): return genre, False def _essentia_genre(self, item): - if not item.get('bpm'): # run essentia analysis if result not known yet + if not item.get('bpm') or not item.get('genre_rosamerica'): + # Run essentia analysis if result not known yet. self._log.debug('Analyzing item using essentia: {}', item) self._xtractor._run_analysis(item) + if 'genre_rosamerica' not in item: + # Essentia analysis may not provide data in some cases. + return None # Use Essentia's mapped genre_rosamerica value genre_rosamerica = item.genre_rosamerica genre_rosamerica_probability = float(item.genre_rosamerica_probability) diff --git a/tests/e2e/tests.bats b/tests/e2e/tests.bats index 17326de..aba5b6d 100644 --- a/tests/e2e/tests.bats +++ b/tests/e2e/tests.bats @@ -91,10 +91,19 @@ tempConfigWithAutoEnabled() { # EttoreTechnoChannel - Hector Couto- Amanece beet ytimport -q --quiet-fallback=asis https://www.youtube.com/watch?v=8CI2GjcCkuM QUERY='title:Hector Couto- Amanece' - beet autogenre -f $QUERY + beet autogenre -f --no-lastgenre $QUERY assertGenre "$QUERY" 'essentia | Electronic | Electronic, Hip Hop, House' } +@test "don't fail when essentia analysis did not provide data" { + # Amadou & Mariam feat. K'naan - Africa + beet ytimport -q --quiet-fallback=asis https://www.youtube.com/watch?v=WJ-rI2i9VGE + QUERY='artist:Amadou title:Africa' + beet autogenre -f --no-lastgenre $QUERY + assertGenre "$QUERY" '' + # TODO: implement fallback to using the most common genre of other tracks of the same artist +} + @test 'specify genre manually' { ALBUM='Reggae Jungle Drum and Bass Mix #9 New 2022'