Add type hints to media_player (part 2) (#64006)

pull/64030/head
epenet 2022-01-13 10:43:52 +01:00 committed by GitHub
parent 5cd73170de
commit ed5e1af10a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 11 deletions

View File

@ -913,8 +913,11 @@ class KodiEntity(MediaPlayerEntity):
return response return response
async def async_get_browse_image( async def async_get_browse_image(
self, media_content_type, media_content_id, media_image_id=None self,
): media_content_type: str,
media_content_id: str,
media_image_id: str | None = None,
) -> tuple[bytes | None, str | None]:
"""Get media image from kodi server.""" """Get media image from kodi server."""
try: try:
image_url, _, _ = await get_media_info( image_url, _, _ = await get_media_info(

View File

@ -457,8 +457,11 @@ class PhilipsTVMediaPlayer(CoordinatorEntity, MediaPlayerEntity):
raise BrowseError(f"Media not found: {media_content_type} / {media_content_id}") raise BrowseError(f"Media not found: {media_content_type} / {media_content_id}")
async def async_get_browse_image( async def async_get_browse_image(
self, media_content_type, media_content_id, media_image_id=None self,
): media_content_type: str,
media_content_id: str,
media_image_id: str | None = None,
) -> tuple[bytes | None, str | None]:
"""Serve album art. Returns (content, content_type).""" """Serve album art. Returns (content, content_type)."""
try: try:
if media_content_type == MEDIA_TYPE_APP and media_content_id: if media_content_type == MEDIA_TYPE_APP and media_content_id:

View File

@ -1,4 +1,6 @@
"""Support to interface with the Plex API.""" """Support to interface with the Plex API."""
from __future__ import annotations
from functools import wraps from functools import wraps
import json import json
import logging import logging
@ -571,8 +573,11 @@ class PlexMediaPlayer(MediaPlayerEntity):
) )
async def async_get_browse_image( async def async_get_browse_image(
self, media_content_type, media_content_id, media_image_id=None self,
): media_content_type: str,
media_content_id: str,
media_image_id: str | None = None,
) -> tuple[bytes | None, str | None]:
"""Get media image from Plex server.""" """Get media image from Plex server."""
image_url = self.plex_server.thumbnail_cache.get(media_content_id) image_url = self.plex_server.thumbnail_cache.get(media_content_id)
if image_url: if image_url:

View File

@ -606,10 +606,10 @@ class SonosMediaPlayerEntity(SonosEntity, MediaPlayerEntity):
async def async_get_browse_image( async def async_get_browse_image(
self, self,
media_content_type: str | None, media_content_type: str,
media_content_id: str | None, media_content_id: str,
media_image_id: str | None = None, media_image_id: str | None = None,
) -> tuple[None | str, None | str]: ) -> tuple[bytes | None, str | None]:
"""Fetch media browser image to serve via proxy.""" """Fetch media browser image to serve via proxy."""
if ( if (
media_content_type in [MEDIA_TYPE_ALBUM, MEDIA_TYPE_ARTIST] media_content_type in [MEDIA_TYPE_ALBUM, MEDIA_TYPE_ARTIST]

View File

@ -1,4 +1,6 @@
"""Support for interfacing to the Logitech SqueezeBox API.""" """Support for interfacing to the Logitech SqueezeBox API."""
from __future__ import annotations
import asyncio import asyncio
import json import json
import logging import logging
@ -562,8 +564,11 @@ class SqueezeBoxEntity(MediaPlayerEntity):
return await build_item_response(self, self._player, payload) return await build_item_response(self, self._player, payload)
async def async_get_browse_image( async def async_get_browse_image(
self, media_content_type, media_content_id, media_image_id=None self,
): media_content_type: str,
media_content_id: str,
media_image_id: str | None = None,
) -> tuple[bytes | None, str | None]:
"""Get album art from Squeezebox server.""" """Get album art from Squeezebox server."""
if media_image_id: if media_image_id:
image_url = self._player.generate_image_url_from_track_id(media_image_id) image_url = self._player.generate_image_url_from_track_id(media_image_id)