Skip to content

Commit

Permalink
Add podcast episode splitter.
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinSchenkel committed Jan 30, 2025
1 parent c885094 commit bdb84ec
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions music_assistant/providers/ytmusic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
# Playlist ID's are not unique across instances for lists like 'Liked videos', 'SuperMix' etc.
# So we need to add a delimiter to make them unique
YT_PLAYLIST_ID_DELIMITER = "🎵"
PODCAST_EPISODE_SPLITTER = "|"
YT_PERSONAL_PLAYLISTS = (
"LM", # Liked songs
"SE" # Episodes for Later
Expand Down Expand Up @@ -422,7 +423,7 @@ async def get_podcast_episodes(self, prov_podcast_id: str) -> list[PodcastEpisod

async def get_podcast_episode(self, prov_episode_id: str) -> PodcastEpisode:
"""Get a single Podcast Episode."""
podcast_id, episode_id = prov_episode_id.split("|")
podcast_id, episode_id = prov_episode_id.split(PODCAST_EPISODE_SPLITTER)
podcast = await self.get_podcast(podcast_id)
episode_obj = await get_podcast_episode(episode_id, headers=self._headers)
episode = self._parse_podcast_episode(episode_obj, podcast)
Expand Down Expand Up @@ -541,7 +542,7 @@ async def get_stream_details(
) -> StreamDetails:
"""Return the content details for the given track when it will be streamed."""
if media_type == MediaType.PODCAST_EPISODE:
item_id = item_id.split("|")[1]
item_id = item_id.split(PODCAST_EPISODE_SPLITTER)[1]
stream_format = await self._get_stream_format(item_id=item_id)
self.logger.debug("Found stream_format: %s for song %s", stream_format["format"], item_id)
stream_details = StreamDetails(
Expand Down Expand Up @@ -809,7 +810,7 @@ def _parse_podcast_episode(self, episode_obj: dict, podcast: Podcast | None) ->
if not episode_id:
msg = "Podcast episode is missing videoId"
raise InvalidDataError(msg)
item_id = f"{podcast.item_id}|{episode_id}"
item_id = f"{podcast.item_id}{PODCAST_EPISODE_SPLITTER}{episode_id}"
episode = PodcastEpisode(
item_id=item_id,
provider=self.lookup_key,
Expand Down

0 comments on commit bdb84ec

Please sign in to comment.