Fix TypeError
This commit is contained in:
@@ -3,6 +3,7 @@ from __future__ import annotations
|
||||
import logging
|
||||
import sched
|
||||
import time
|
||||
import typing
|
||||
|
||||
from librespot.core.Session import Session
|
||||
from librespot.player import PlayerConfiguration
|
||||
@@ -22,7 +23,7 @@ class Player(Closeable, PlayerSession.Listener, AudioSink.Listener):
|
||||
_conf: PlayerConfiguration = None
|
||||
_events: Player.EventsDispatcher = None
|
||||
_sink: AudioSink = None
|
||||
_metrics: dict[str, PlaybackMetrics] = {}
|
||||
_metrics: typing.Dict[str, PlaybackMetrics] = {}
|
||||
_state: StateWrapper = None
|
||||
_playerSession: PlayerSession = None
|
||||
_releaseLineFuture = None
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import typing
|
||||
|
||||
from librespot.core import Session
|
||||
from librespot.dealer import DealerClient
|
||||
from librespot.player import Player
|
||||
@@ -53,5 +55,5 @@ class StateWrapper(DeviceStateHandler.Listener, DealerClient.MessageListener):
|
||||
self._device.update_state(Connect.PutStateReason.NEW_DEVICE, 0,
|
||||
self._state)
|
||||
|
||||
def on_message(self, uri: str, headers: dict[str, str], payload: bytes):
|
||||
def on_message(self, uri: str, headers: typing.Dict[str, str], payload: bytes):
|
||||
pass
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
from librespot.proto.Metadata import AudioFile
|
||||
import enum
|
||||
import typing
|
||||
|
||||
|
||||
class AudioQuality(enum.Enum):
|
||||
@@ -26,7 +27,7 @@ class AudioQuality(enum.Enum):
|
||||
return AudioQuality.VERY_HIGH
|
||||
raise RuntimeError("Unknown format: {}".format(format))
|
||||
|
||||
def get_matches(self, files: list[AudioFile]) -> list[AudioFile]:
|
||||
def get_matches(self, files: typing.List[AudioFile]) -> typing.List[AudioFile]:
|
||||
file_list = []
|
||||
for file in files:
|
||||
if hasattr(file, "format") and AudioQuality.get_quality(
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import typing
|
||||
|
||||
from librespot.audio.format.AudioQualityPicker import AudioQualityPicker
|
||||
from librespot.audio.format.SuperAudioFormat import SuperAudioFormat
|
||||
@@ -16,7 +17,7 @@ class VorbisOnlyAudioQuality(AudioQualityPicker):
|
||||
self.preferred = preferred
|
||||
|
||||
@staticmethod
|
||||
def get_vorbis_file(files: list[Metadata.AudioFile]):
|
||||
def get_vorbis_file(files: typing.List[Metadata.AudioFile]):
|
||||
for file in files:
|
||||
if hasattr(file, "format") and SuperAudioFormat.get(
|
||||
file.format) == SuperAudioFormat.VORBIS:
|
||||
@@ -24,8 +25,8 @@ class VorbisOnlyAudioQuality(AudioQualityPicker):
|
||||
|
||||
return None
|
||||
|
||||
def get_file(self, files: list[Metadata.AudioFile]):
|
||||
matches: list[Metadata.AudioFile] = self.preferred.get_matches(files)
|
||||
def get_file(self, files: typing.List[Metadata.AudioFile]):
|
||||
matches: typing.List[Metadata.AudioFile] = self.preferred.get_matches(files)
|
||||
vorbis: Metadata.AudioFile = VorbisOnlyAudioQuality.get_vorbis_file(
|
||||
matches)
|
||||
if vorbis is None:
|
||||
|
||||
@@ -19,7 +19,7 @@ class DeviceStateHandler:
|
||||
_LOGGER: logging = logging.getLogger(__name__)
|
||||
_session: Session = None
|
||||
_deviceInfo: Connect.DeviceInfo = None
|
||||
_listeners: list[DeviceStateHandler.Listener] = []
|
||||
_listeners: typing.List[DeviceStateHandler.Listener] = []
|
||||
_putState: Connect.PutStateRequest = None
|
||||
_putStateWorker: concurrent.futures.ThreadPoolExecutor = (
|
||||
concurrent.futures.ThreadPoolExecutor())
|
||||
|
||||
Reference in New Issue
Block a user