self.mass.create_task(
music_prov.on_played(
media_type=media_item.media_type,
- item_id=prov_mapping.item_id,
+ prov_item_id=prov_mapping.item_id,
fully_played=fully_played,
position=seconds_played,
- is_playing=is_playing,
media_item=media_item,
+ is_playing=is_playing,
)
)
self.mass.create_task(
music_prov.on_played(
media_type=media_item.media_type,
- item_id=prov_mapping.item_id,
+ prov_item_id=prov_mapping.item_id,
fully_played=False,
position=0,
media_item=media_item,
async def on_played(
self,
media_type: MediaType,
- item_id: str,
+ prov_item_id: str,
fully_played: bool,
position: int,
+ media_item: MediaItemType,
is_playing: bool = False,
- media_item: MediaItemType | None = None,
) -> None:
"""
Handle callback when a (playable) media item has been played.
When fully_played is set to false and position is 0,
the user marked the item as unplayed in the UI.
- is_playing is True when the track is currently playing.
-
media_item is the full media item details of the played/playing track.
+
+ is_playing is True when the track is currently playing.
"""
async def resolve_image(self, path: str) -> str | bytes:
async def on_played(
self,
media_type: MediaType,
- item_id: str,
+ prov_item_id: str,
fully_played: bool,
position: int,
+ media_item: MediaItemType,
is_playing: bool = False,
- media_item: MediaItemType | None = None,
) -> None:
"""
Handle callback when a (playable) media item has been played.
async def on_played(
self,
media_type: MediaType,
- item_id: str,
+ prov_item_id: str,
fully_played: bool,
position: int,
+ media_item: MediaItemType,
is_playing: bool = False,
- media_item: MediaItemType | None = None,
) -> None:
"""
Handle callback when a (playable) media item has been played.
media_item is the full media item details of the played/playing track.
"""
- await self.helper.set_last_position(item_id, position)
+ await self.helper.set_last_position(prov_item_id, position)
async def unload(self, is_removed: bool = False) -> None:
"""
async def on_played(
self,
media_type: MediaType,
- item_id: str,
+ prov_item_id: str,
fully_played: bool,
position: int,
+ media_item: MediaItemType,
is_playing: bool = False,
- media_item: MediaItemType | None = None,
) -> None:
"""Update progress in Audiobookshelf.
"""
if media_type == MediaType.PODCAST_EPISODE:
- abs_podcast_id, abs_episode_id = item_id.split(" ")
- mass_podcast_episode = await self.get_podcast_episode(item_id)
+ abs_podcast_id, abs_episode_id = prov_item_id.split(" ")
+ mass_podcast_episode = await self.get_podcast_episode(prov_item_id)
duration = mass_podcast_episode.duration
self.logger.debug(
f"Updating media progress of {media_type.value}, title {mass_podcast_episode.name}."
is_finished=fully_played,
)
if media_type == MediaType.AUDIOBOOK:
- mass_audiobook = await self.get_audiobook(item_id)
+ mass_audiobook = await self.get_audiobook(prov_item_id)
duration = mass_audiobook.duration
self.logger.debug(f"Updating {media_type.value} named {mass_audiobook.name} progress")
await self._client.update_my_media_progress(
- item_id=item_id,
+ item_id=prov_item_id,
duration_seconds=duration,
progress_seconds=position,
is_finished=fully_played,
async def on_played(
self,
media_type: MediaType,
- item_id: str,
+ prov_item_id: str,
fully_played: bool,
position: int,
+ media_item: MediaItemType,
is_playing: bool = False,
- media_item: MediaItemType | None = None,
) -> None:
"""
Handle callback when a (playable) media item has been played.