Prevent crash of filesystem provider when invalid ID3 tag found
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Mon, 9 May 2022 12:25:01 +0000 (14:25 +0200)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Mon, 9 May 2022 12:25:01 +0000 (14:25 +0200)
music_assistant/controllers/music/__init__.py
music_assistant/controllers/music/albums.py
music_assistant/providers/filesystem.py

index abac150fcc590bfdbd4389c8fbf60ecfd00b39e3..74c0190fd49925419a99ca71e13e855a0d8e6a2d 100755 (executable)
@@ -416,7 +416,7 @@ class MusicController:
                 # in case of filestem, removal from library means the whole item is
                 # moved/deleted so we remove the prov mapping from db.
                 if provider_id == "filesystem":
-                    if db_item := controller.get_db_item(item_id):
+                    if db_item := await controller.get_db_item(item_id):
                         db_item.provider_ids = {
                             x
                             for x in db_item.provider_ids
index a9d976b4198c0f0fa18f14e9b09111c9bebf9c7b..188a4a9373b68824e0620393a9486c13acf1037a 100644 (file)
@@ -150,7 +150,11 @@ class AlbumsController(MediaControllerBase[Album]):
         """Update Album record in the database."""
         async with self.mass.database.get_db() as _db:
             cur_item = await self.get_db_item(item_id)
-            if album.artist.musicbrainz_id and album.artist.provider != "database":
+            if (
+                not isinstance(album.artist, ItemMapping)
+                and album.artist.musicbrainz_id
+                and album.artist.provider != "database"
+            ):
                 album_artist = await self.mass.music.artists.add_db_item(album.artist)
             else:
                 album_artist = (
index e87334ce3e4d88ceb53c333c7faf1f947efcaefc..7ceeb6c792a0f64f4d196406a2ffca123d686fd5 100644 (file)
@@ -303,6 +303,12 @@ class FileSystemProvider(MusicProvider):
 
         # TODO: Fall back to parsing base details from filename if no tags found/supported
         tag = await self.mass.loop.run_in_executor(None, parse_tag)
+
+        # we need at least a title and artist
+        if tag.title is None or tag.artist is None:
+            self.logger.warning("Skipping track due to invalid ID3 tags: %s", filename)
+            return None
+
         prov_item_id = await self._get_item_id(filename, MediaType.TRACK)
         name, version = parse_title_and_version(tag.title)
         track = Track(