From: Jozef Kruszynski <60214390+jozefKruszynski@users.noreply.github.com> Date: Thu, 26 Feb 2026 08:02:18 +0000 (+0100) Subject: Add manual mediaitem linking to genre (#3248) X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=2ee9bcefa9bf55e80d199e59370a2cc013ba470c;p=music-assistant-server.git Add manual mediaitem linking to genre (#3248) feat(genres): manual mediaitem linking to genre --- diff --git a/music_assistant/controllers/media/genres.py b/music_assistant/controllers/media/genres.py index 1d26d8e7..14f5cd99 100644 --- a/music_assistant/controllers/media/genres.py +++ b/music_assistant/controllers/media/genres.py @@ -868,15 +868,23 @@ class GenreController(MediaControllerBase[Genre]): return updated async def add_media_mapping( - self, genre_id: str | int, media_type: MediaType, media_id: str | int, alias: str + self, + genre_id: str | int, + media_type: MediaType, + media_id: str | int, + alias: str | None = None, ) -> None: """Map a media item to a genre. :param genre_id: Database ID of the genre. :param media_type: Type of media item (track, album, artist). :param media_id: Database ID of the media item. - :param alias: The alias string that caused this mapping. + :param alias: The alias string that caused this mapping. If not provided, + the genre's primary name is used. """ + if alias is None: + genre = await self.get_library_item(int(genre_id)) + alias = genre.name await self.mass.music.database.insert( DB_TABLE_GENRE_MEDIA_ITEM_MAPPING, {