diff --git a/src/librespot/Version.py b/librespot/Version.py similarity index 100% rename from src/librespot/Version.py rename to librespot/Version.py diff --git a/src/librespot/__init__.py b/librespot/__init__.py similarity index 100% rename from src/librespot/__init__.py rename to librespot/__init__.py diff --git a/src/librespot/audio/AbsChunkedInputStream.py b/librespot/audio/AbsChunkedInputStream.py similarity index 100% rename from src/librespot/audio/AbsChunkedInputStream.py rename to librespot/audio/AbsChunkedInputStream.py diff --git a/src/librespot/audio/AudioKeyManager.py b/librespot/audio/AudioKeyManager.py similarity index 100% rename from src/librespot/audio/AudioKeyManager.py rename to librespot/audio/AudioKeyManager.py diff --git a/src/librespot/audio/GeneralAudioStream.py b/librespot/audio/GeneralAudioStream.py similarity index 100% rename from src/librespot/audio/GeneralAudioStream.py rename to librespot/audio/GeneralAudioStream.py diff --git a/src/librespot/audio/GeneralWritableStream.py b/librespot/audio/GeneralWritableStream.py similarity index 100% rename from src/librespot/audio/GeneralWritableStream.py rename to librespot/audio/GeneralWritableStream.py diff --git a/src/librespot/audio/HaltListener.py b/librespot/audio/HaltListener.py similarity index 100% rename from src/librespot/audio/HaltListener.py rename to librespot/audio/HaltListener.py diff --git a/src/librespot/audio/NormalizationData.py b/librespot/audio/NormalizationData.py similarity index 100% rename from src/librespot/audio/NormalizationData.py rename to librespot/audio/NormalizationData.py diff --git a/src/librespot/audio/PlayableContentFeeder.py b/librespot/audio/PlayableContentFeeder.py similarity index 100% rename from src/librespot/audio/PlayableContentFeeder.py rename to librespot/audio/PlayableContentFeeder.py diff --git a/src/librespot/audio/StreamId.py b/librespot/audio/StreamId.py similarity index 100% rename from src/librespot/audio/StreamId.py rename to librespot/audio/StreamId.py diff --git a/src/librespot/audio/__init__.py b/librespot/audio/__init__.py similarity index 100% rename from src/librespot/audio/__init__.py rename to librespot/audio/__init__.py diff --git a/src/librespot/audio/cdn/CdnFeedHelper.py b/librespot/audio/cdn/CdnFeedHelper.py similarity index 100% rename from src/librespot/audio/cdn/CdnFeedHelper.py rename to librespot/audio/cdn/CdnFeedHelper.py diff --git a/src/librespot/audio/cdn/CdnManager.py b/librespot/audio/cdn/CdnManager.py similarity index 100% rename from src/librespot/audio/cdn/CdnManager.py rename to librespot/audio/cdn/CdnManager.py diff --git a/src/librespot/audio/cdn/__init__.py b/librespot/audio/cdn/__init__.py similarity index 100% rename from src/librespot/audio/cdn/__init__.py rename to librespot/audio/cdn/__init__.py diff --git a/src/librespot/audio/decrypt/AesAudioDecrypt.py b/librespot/audio/decrypt/AesAudioDecrypt.py similarity index 100% rename from src/librespot/audio/decrypt/AesAudioDecrypt.py rename to librespot/audio/decrypt/AesAudioDecrypt.py diff --git a/src/librespot/audio/decrypt/AudioDecrypt.py b/librespot/audio/decrypt/AudioDecrypt.py similarity index 100% rename from src/librespot/audio/decrypt/AudioDecrypt.py rename to librespot/audio/decrypt/AudioDecrypt.py diff --git a/src/librespot/audio/decrypt/NoopAudioDecrypt.py b/librespot/audio/decrypt/NoopAudioDecrypt.py similarity index 100% rename from src/librespot/audio/decrypt/NoopAudioDecrypt.py rename to librespot/audio/decrypt/NoopAudioDecrypt.py diff --git a/src/librespot/audio/decrypt/__init__.py b/librespot/audio/decrypt/__init__.py similarity index 100% rename from src/librespot/audio/decrypt/__init__.py rename to librespot/audio/decrypt/__init__.py diff --git a/src/librespot/audio/format/AudioQualityPicker.py b/librespot/audio/format/AudioQualityPicker.py similarity index 100% rename from src/librespot/audio/format/AudioQualityPicker.py rename to librespot/audio/format/AudioQualityPicker.py diff --git a/src/librespot/audio/format/SuperAudioFormat.py b/librespot/audio/format/SuperAudioFormat.py similarity index 100% rename from src/librespot/audio/format/SuperAudioFormat.py rename to librespot/audio/format/SuperAudioFormat.py diff --git a/src/librespot/audio/format/__init__.py b/librespot/audio/format/__init__.py similarity index 100% rename from src/librespot/audio/format/__init__.py rename to librespot/audio/format/__init__.py diff --git a/src/librespot/audio/storage/AudioFile.py b/librespot/audio/storage/AudioFile.py similarity index 100% rename from src/librespot/audio/storage/AudioFile.py rename to librespot/audio/storage/AudioFile.py diff --git a/src/librespot/audio/storage/AudioFileStreaming.py b/librespot/audio/storage/AudioFileStreaming.py similarity index 100% rename from src/librespot/audio/storage/AudioFileStreaming.py rename to librespot/audio/storage/AudioFileStreaming.py diff --git a/src/librespot/audio/storage/ChannelManager.py b/librespot/audio/storage/ChannelManager.py similarity index 100% rename from src/librespot/audio/storage/ChannelManager.py rename to librespot/audio/storage/ChannelManager.py diff --git a/src/librespot/audio/storage/__init__.py b/librespot/audio/storage/__init__.py similarity index 100% rename from src/librespot/audio/storage/__init__.py rename to librespot/audio/storage/__init__.py diff --git a/src/librespot/cache/CacheManager.py b/librespot/cache/CacheManager.py similarity index 100% rename from src/librespot/cache/CacheManager.py rename to librespot/cache/CacheManager.py diff --git a/src/librespot/cache/__init__.py b/librespot/cache/__init__.py similarity index 100% rename from src/librespot/cache/__init__.py rename to librespot/cache/__init__.py diff --git a/src/librespot/common/Base62.py b/librespot/common/Base62.py similarity index 100% rename from src/librespot/common/Base62.py rename to librespot/common/Base62.py diff --git a/src/librespot/common/Utils.py b/librespot/common/Utils.py similarity index 73% rename from src/librespot/common/Utils.py rename to librespot/common/Utils.py index 40bc3d7..2a9b18c 100644 --- a/src/librespot/common/Utils.py +++ b/librespot/common/Utils.py @@ -8,6 +8,17 @@ class Utils: buffer = os.urandom(int(length / 2)) return Utils.bytes_to_hex(buffer) + @staticmethod + def truncate_middle(s: str, length: int) -> str: + if length <= 1: + raise TypeError() + + first = length / 2 + result = s[:first] + result += "..." + result += s[len(s) - (length - first):] + return result + @staticmethod def split(s: str, c: str): return s.split(c) diff --git a/src/librespot/common/__init__.py b/librespot/common/__init__.py similarity index 100% rename from src/librespot/common/__init__.py rename to librespot/common/__init__.py diff --git a/src/librespot/core/ApResolver.py b/librespot/core/ApResolver.py similarity index 100% rename from src/librespot/core/ApResolver.py rename to librespot/core/ApResolver.py diff --git a/src/librespot/core/EventService.py b/librespot/core/EventService.py similarity index 100% rename from src/librespot/core/EventService.py rename to librespot/core/EventService.py diff --git a/src/librespot/core/PacketsReceiver.py b/librespot/core/PacketsReceiver.py similarity index 100% rename from src/librespot/core/PacketsReceiver.py rename to librespot/core/PacketsReceiver.py diff --git a/src/librespot/core/SearchManager.py b/librespot/core/SearchManager.py similarity index 100% rename from src/librespot/core/SearchManager.py rename to librespot/core/SearchManager.py diff --git a/src/librespot/core/Session.py b/librespot/core/Session.py similarity index 100% rename from src/librespot/core/Session.py rename to librespot/core/Session.py diff --git a/src/librespot/core/TimeProvider.py b/librespot/core/TimeProvider.py similarity index 100% rename from src/librespot/core/TimeProvider.py rename to librespot/core/TimeProvider.py diff --git a/src/librespot/core/TokenProvider.py b/librespot/core/TokenProvider.py similarity index 100% rename from src/librespot/core/TokenProvider.py rename to librespot/core/TokenProvider.py diff --git a/src/librespot/core/__init__.py b/librespot/core/__init__.py similarity index 100% rename from src/librespot/core/__init__.py rename to librespot/core/__init__.py diff --git a/src/librespot/crypto/CipherPair.py b/librespot/crypto/CipherPair.py similarity index 100% rename from src/librespot/crypto/CipherPair.py rename to librespot/crypto/CipherPair.py diff --git a/src/librespot/crypto/DiffieHellman.py b/librespot/crypto/DiffieHellman.py similarity index 100% rename from src/librespot/crypto/DiffieHellman.py rename to librespot/crypto/DiffieHellman.py diff --git a/src/librespot/crypto/Packet.py b/librespot/crypto/Packet.py similarity index 100% rename from src/librespot/crypto/Packet.py rename to librespot/crypto/Packet.py diff --git a/src/librespot/crypto/Shannon.py b/librespot/crypto/Shannon.py similarity index 100% rename from src/librespot/crypto/Shannon.py rename to librespot/crypto/Shannon.py diff --git a/src/librespot/crypto/Shannon_DEV.py b/librespot/crypto/Shannon_DEV.py similarity index 100% rename from src/librespot/crypto/Shannon_DEV.py rename to librespot/crypto/Shannon_DEV.py diff --git a/src/librespot/crypto/__init__.py b/librespot/crypto/__init__.py similarity index 100% rename from src/librespot/crypto/__init__.py rename to librespot/crypto/__init__.py diff --git a/src/librespot/dealer/ApiClient.py b/librespot/dealer/ApiClient.py similarity index 100% rename from src/librespot/dealer/ApiClient.py rename to librespot/dealer/ApiClient.py diff --git a/src/librespot/dealer/DealerClient.py b/librespot/dealer/DealerClient.py similarity index 100% rename from src/librespot/dealer/DealerClient.py rename to librespot/dealer/DealerClient.py diff --git a/src/librespot/dealer/__init__.py b/librespot/dealer/__init__.py similarity index 100% rename from src/librespot/dealer/__init__.py rename to librespot/dealer/__init__.py diff --git a/src/librespot/mercury/JsonMercuryRequest.py b/librespot/mercury/JsonMercuryRequest.py similarity index 100% rename from src/librespot/mercury/JsonMercuryRequest.py rename to librespot/mercury/JsonMercuryRequest.py diff --git a/src/librespot/mercury/MercuryClient.py b/librespot/mercury/MercuryClient.py similarity index 100% rename from src/librespot/mercury/MercuryClient.py rename to librespot/mercury/MercuryClient.py diff --git a/src/librespot/mercury/MercuryRequests.py b/librespot/mercury/MercuryRequests.py similarity index 100% rename from src/librespot/mercury/MercuryRequests.py rename to librespot/mercury/MercuryRequests.py diff --git a/src/librespot/mercury/ProtobufMercuryRequest.py b/librespot/mercury/ProtobufMercuryRequest.py similarity index 100% rename from src/librespot/mercury/ProtobufMercuryRequest.py rename to librespot/mercury/ProtobufMercuryRequest.py diff --git a/src/librespot/mercury/RawMercuryRequest.py b/librespot/mercury/RawMercuryRequest.py similarity index 100% rename from src/librespot/mercury/RawMercuryRequest.py rename to librespot/mercury/RawMercuryRequest.py diff --git a/src/librespot/mercury/SubListener.py b/librespot/mercury/SubListener.py similarity index 100% rename from src/librespot/mercury/SubListener.py rename to librespot/mercury/SubListener.py diff --git a/src/librespot/mercury/__init__.py b/librespot/mercury/__init__.py similarity index 100% rename from src/librespot/mercury/__init__.py rename to librespot/mercury/__init__.py diff --git a/src/librespot/metadata/AlbumId.py b/librespot/metadata/AlbumId.py similarity index 100% rename from src/librespot/metadata/AlbumId.py rename to librespot/metadata/AlbumId.py diff --git a/src/librespot/metadata/ArtistId.py b/librespot/metadata/ArtistId.py similarity index 100% rename from src/librespot/metadata/ArtistId.py rename to librespot/metadata/ArtistId.py diff --git a/src/librespot/metadata/EpisodeId.py b/librespot/metadata/EpisodeId.py similarity index 100% rename from src/librespot/metadata/EpisodeId.py rename to librespot/metadata/EpisodeId.py diff --git a/src/librespot/metadata/PlayableId.py b/librespot/metadata/PlayableId.py similarity index 100% rename from src/librespot/metadata/PlayableId.py rename to librespot/metadata/PlayableId.py diff --git a/src/librespot/metadata/ShowId.py b/librespot/metadata/ShowId.py similarity index 100% rename from src/librespot/metadata/ShowId.py rename to librespot/metadata/ShowId.py diff --git a/src/librespot/metadata/SpotifyId.py b/librespot/metadata/SpotifyId.py similarity index 100% rename from src/librespot/metadata/SpotifyId.py rename to librespot/metadata/SpotifyId.py diff --git a/src/librespot/metadata/TrackId.py b/librespot/metadata/TrackId.py similarity index 100% rename from src/librespot/metadata/TrackId.py rename to librespot/metadata/TrackId.py diff --git a/src/librespot/metadata/UnsupportedId.py b/librespot/metadata/UnsupportedId.py similarity index 100% rename from src/librespot/metadata/UnsupportedId.py rename to librespot/metadata/UnsupportedId.py diff --git a/src/librespot/metadata/__init__.py b/librespot/metadata/__init__.py similarity index 100% rename from src/librespot/metadata/__init__.py rename to librespot/metadata/__init__.py diff --git a/librespot/player/Player.py b/librespot/player/Player.py new file mode 100644 index 0000000..1b9ff4e --- /dev/null +++ b/librespot/player/Player.py @@ -0,0 +1,52 @@ +from __future__ import annotations +from librespot.core.Session import Session +from librespot.player import PlayerConfiguration, StateWrapper +from librespot.player.metrics import PlaybackMetrics +from librespot.player.mixing import AudioSink +from librespot.player.playback.PlayerSession import PlayerSession +from librespot.player.state.DeviceStateHandler import DeviceStateHandler +from librespot.standard.Closeable import Closeable +import sched +import time + + +class Player(Closeable, PlayerSession.Listener, AudioSink.Listener): + VOLUME_MAX: int = 65536 + _scheduler: sched.scheduler = sched.scheduler(time.time) + _session: Session = None + _conf: PlayerConfiguration = None + _events: Player.EventsDispatcher = None + _sink: AudioSink = None + _metrics: dict[str, PlaybackMetrics] = dict() + _state: StateWrapper = None + _playerSession: PlayerSession = None + _releaseLineFuture = None + _deviceStateListener: DeviceStateHandler.Listener = None + + def __init__(self, conf: PlayerConfiguration, session: Session): + self._conf = conf + self._session = session + self._events = Player.EventsDispatcher(conf) + self._sink = AudioSink(conf, self) + + def init_state(self): + self._state = StateWrapper(self._session, self, self._conf) + + class Anonymous(DeviceStateHandler.Listener): + def ready(self) -> None: + pass + + def command(self, endpoint: DeviceStateHandler.Endpoint, data: DeviceStateHandler.CommandBody) -> None: + pass + + self._deviceStateListener = Anonymous() + + + def volume_up(self, steps: int = 1): + if self.state is None: + return + + + class EventsDispatcher: + def __init__(self, conf: PlayerConfiguration): + pass diff --git a/src/librespot/player/PlayerConfiguration.py b/librespot/player/PlayerConfiguration.py similarity index 100% rename from src/librespot/player/PlayerConfiguration.py rename to librespot/player/PlayerConfiguration.py diff --git a/librespot/player/StateWrapper.py b/librespot/player/StateWrapper.py new file mode 100644 index 0000000..40b9a53 --- /dev/null +++ b/librespot/player/StateWrapper.py @@ -0,0 +1,38 @@ +from __future__ import annotations +from librespot.core import Session +from librespot.player import Player, PlayerConfiguration +from librespot.player.state import DeviceStateHandler +from librespot.proto import Connect +from librespot.proto.Player import ContextPlayerOptions, PlayerState, Restrictions, Suppressions + + +class StateWrapper(DeviceStateHandler.Listener): + _state: PlayerState = None + _session: Session = None + _player: Player = None + _device: DeviceStateHandler = None + + def __init__(self, session: Session, player: Player, + conf: PlayerConfiguration): + self._session = session + self._player = player + self._device = DeviceStateHandler(session, self, conf) + self._state = self._init_state() + + def _init_state(self) -> PlayerState: + return PlayerState( + playback_speed=1.0, + suppressions=Suppressions(), + context_restrictions=Restrictions(), + options=ContextPlayerOptions( + repeating_context=False, + shuffling_context=False, + repeating_track=False + ), + position_as_of_timestamp=0, + position=0, + is_playing=False + ) + + def ready(self) -> None: + self._device.update_state(Connect.PutStateReason.NEW_DEVICE, 0, self._state) diff --git a/src/librespot/player/__init__.py b/librespot/player/__init__.py similarity index 100% rename from src/librespot/player/__init__.py rename to librespot/player/__init__.py diff --git a/src/librespot/player/codecs/AudioQuality.py b/librespot/player/codecs/AudioQuality.py similarity index 100% rename from src/librespot/player/codecs/AudioQuality.py rename to librespot/player/codecs/AudioQuality.py diff --git a/src/librespot/player/codecs/VorbisOnlyAudioQuality.py b/librespot/player/codecs/VorbisOnlyAudioQuality.py similarity index 100% rename from src/librespot/player/codecs/VorbisOnlyAudioQuality.py rename to librespot/player/codecs/VorbisOnlyAudioQuality.py diff --git a/src/librespot/player/codecs/__init__.py b/librespot/player/codecs/__init__.py similarity index 100% rename from src/librespot/player/codecs/__init__.py rename to librespot/player/codecs/__init__.py diff --git a/librespot/player/metrics/PlaybackMetrics.py b/librespot/player/metrics/PlaybackMetrics.py new file mode 100644 index 0000000..a4c3a97 --- /dev/null +++ b/librespot/player/metrics/PlaybackMetrics.py @@ -0,0 +1,6 @@ +from __future__ import annotations +import logging + + +class PlaybackMetrics: + _LOGGER = logging.getLogger(__name__) diff --git a/src/librespot/proto/__init__.py b/librespot/player/metrics/__init__.py similarity index 100% rename from src/librespot/proto/__init__.py rename to librespot/player/metrics/__init__.py diff --git a/librespot/player/mixing/AudioSink.py b/librespot/player/mixing/AudioSink.py new file mode 100644 index 0000000..5e4234b --- /dev/null +++ b/librespot/player/mixing/AudioSink.py @@ -0,0 +1,11 @@ +from __future__ import annotations +from librespot.player import PlayerConfiguration + + +class AudioSink: + def __init__(self, conf: PlayerConfiguration, listener: AudioSink.Listener): + pass + + class Listener: + def sink_error(self, ex: Exception): + pass diff --git a/librespot/player/mixing/__init__.py b/librespot/player/mixing/__init__.py new file mode 100644 index 0000000..bc7cf51 --- /dev/null +++ b/librespot/player/mixing/__init__.py @@ -0,0 +1 @@ +from librespot.player.mixing.AudioSink import AudioSink diff --git a/src/librespot/player/playback/PlayerSession.py b/librespot/player/playback/PlayerSession.py similarity index 76% rename from src/librespot/player/playback/PlayerSession.py rename to librespot/player/playback/PlayerSession.py index 2cd1530..facd163 100644 --- a/src/librespot/player/playback/PlayerSession.py +++ b/librespot/player/playback/PlayerSession.py @@ -3,4 +3,5 @@ from librespot.standard import Closeable class PlayerSession(Closeable): - pass + class Listener: + pass diff --git a/src/librespot/player/playback/__init__.py b/librespot/player/playback/__init__.py similarity index 100% rename from src/librespot/player/playback/__init__.py rename to librespot/player/playback/__init__.py diff --git a/librespot/player/state/DeviceStateHandler.py b/librespot/player/state/DeviceStateHandler.py new file mode 100644 index 0000000..ec9aedc --- /dev/null +++ b/librespot/player/state/DeviceStateHandler.py @@ -0,0 +1,97 @@ +from __future__ import annotations +from librespot.common import Utils +from librespot.core import Session +from librespot.player import PlayerConfiguration +from librespot.proto import Connect, Player +import base64 +import concurrent.futures +import enum +import logging +import time +import typing +import urllib.parse + + +class DeviceStateHandler: + _LOGGER: logging = logging.getLogger(__name__) + _session: Session = None + _deviceInfo: Connect.DeviceInfo = None + _listeners: list[DeviceStateHandler.Listener] = list() + _putState: Connect.PutStateRequest = None + _putStateWorker: concurrent.futures.ThreadPoolExecutor = concurrent.futures.ThreadPoolExecutor() + _connectionId: str = None + + def __init__(self, session: Session, player, conf: PlayerConfiguration): + self._session = session + self._deviceInfo = None + self._putState = Connect.PutStateRequest() + + def _update_connection_id(self, newer: str) -> None: + newer = urllib.parse.unquote(newer, "UTF-8") + + if self._connectionId is None or \ + self._connectionId != newer: + self._connectionId = newer + self._LOGGER.debug("Updated Spotify-Connection-Id: {}".format(self._connectionId)) + self._notify_ready() + + def _notify_ready(self) -> None: + for listener in self._listeners: + listener.ready() + + def update_state(self, reason: Connect.PutStateReason, player_time: int, state: Player.PlayerState): + if self._connectionId is None: + raise TypeError() + + if player_time == -1: + pass + else: + pass + + self._putState.put_state_reason = reason + self._putState.client_side_timestamp = int(time.time() * 1000) + self._putState.device.device_info = self._deviceInfo + self._putState.device.player_state = state + + self._putStateWorker.submit(self._put_connect_state, self._putState) + + def _put_connect_state(self, req: Connect.PutStateRequest): + self._session.api().put_connect_state(self._connectionId, req) + self._LOGGER.info("Put state. ts: {}, connId: {}, reason: {}".format( + req.client_side_timestamp, Utils.truncate_middle(self._connectionId, 10), req.put_state_reason + )) + + class Endpoint(enum.Enum): + Play: str = "play" + Pause: str = "pause" + Resume: str = "resume" + SeekTo: str = "seek_to" + SkipNext: str = "skip_next" + SkipPrev: str = "skip_prev" + + class Listener: + def ready(self) -> None: + pass + + def command(self, endpoint: DeviceStateHandler.Endpoint, data: DeviceStateHandler.CommandBody) -> None: + pass + + def volume_changed(self) -> None: + pass + + def not_active(self) -> None: + pass + + class CommandBody: + _obj: typing.Any = None + _data: bytes = None + _value: str = None + + def __init__(self, obj: typing.Any): + self._obj = obj + + if obj.get("data") is not None: + self._data = base64.b64decode(obj.get("data")) + + if obj.get("value") is not None: + self._value = obj.get("value") diff --git a/librespot/player/state/__init__.py b/librespot/player/state/__init__.py new file mode 100644 index 0000000..7f33797 --- /dev/null +++ b/librespot/player/state/__init__.py @@ -0,0 +1 @@ +from librespot.player.state.DeviceStateHandler import DeviceStateHandler diff --git a/src/librespot/proto/Authentication.py b/librespot/proto/Authentication.py similarity index 100% rename from src/librespot/proto/Authentication.py rename to librespot/proto/Authentication.py diff --git a/src/librespot/proto/Connect.py b/librespot/proto/Connect.py similarity index 99% rename from src/librespot/proto/Connect.py rename to librespot/proto/Connect.py index acb8d43..cd8800b 100644 --- a/src/librespot/proto/Connect.py +++ b/librespot/proto/Connect.py @@ -11,7 +11,7 @@ from google.protobuf import symbol_database as _symbol_database _sym_db = _symbol_database.Default() -import librespot.proto.player_pb2 as player__pb2 +import librespot.proto.Player as player__pb2 DESCRIPTOR = _descriptor.FileDescriptor( name='connect.proto', diff --git a/src/librespot/proto/ExplicitContentPubsub.py b/librespot/proto/ExplicitContentPubsub.py similarity index 100% rename from src/librespot/proto/ExplicitContentPubsub.py rename to librespot/proto/ExplicitContentPubsub.py diff --git a/src/librespot/proto/Keyexchange.py b/librespot/proto/Keyexchange.py similarity index 100% rename from src/librespot/proto/Keyexchange.py rename to librespot/proto/Keyexchange.py diff --git a/src/librespot/proto/Mercury.py b/librespot/proto/Mercury.py similarity index 100% rename from src/librespot/proto/Mercury.py rename to librespot/proto/Mercury.py diff --git a/src/librespot/proto/Metadata.py b/librespot/proto/Metadata.py similarity index 100% rename from src/librespot/proto/Metadata.py rename to librespot/proto/Metadata.py diff --git a/src/librespot/proto/player_pb2.py b/librespot/proto/Player.py similarity index 100% rename from src/librespot/proto/player_pb2.py rename to librespot/proto/Player.py diff --git a/src/librespot/proto/Pubsub.py b/librespot/proto/Pubsub.py similarity index 100% rename from src/librespot/proto/Pubsub.py rename to librespot/proto/Pubsub.py diff --git a/src/librespot/proto/StorageResolve.py b/librespot/proto/StorageResolve.py similarity index 100% rename from src/librespot/proto/StorageResolve.py rename to librespot/proto/StorageResolve.py diff --git a/src/librespot/proto/spotify/__init__.py b/librespot/proto/__init__.py similarity index 100% rename from src/librespot/proto/spotify/__init__.py rename to librespot/proto/__init__.py diff --git a/src/librespot/proto/canvaz_meta_pb2.py b/librespot/proto/canvaz_meta_pb2.py similarity index 100% rename from src/librespot/proto/canvaz_meta_pb2.py rename to librespot/proto/canvaz_meta_pb2.py diff --git a/src/librespot/proto/canvaz_pb2.py b/librespot/proto/canvaz_pb2.py similarity index 100% rename from src/librespot/proto/canvaz_pb2.py rename to librespot/proto/canvaz_pb2.py diff --git a/src/librespot/proto/context_page_pb2.py b/librespot/proto/context_page_pb2.py similarity index 100% rename from src/librespot/proto/context_page_pb2.py rename to librespot/proto/context_page_pb2.py diff --git a/src/librespot/proto/context_pb2.py b/librespot/proto/context_pb2.py similarity index 100% rename from src/librespot/proto/context_pb2.py rename to librespot/proto/context_pb2.py diff --git a/src/librespot/proto/context_player_options_pb2.py b/librespot/proto/context_player_options_pb2.py similarity index 100% rename from src/librespot/proto/context_player_options_pb2.py rename to librespot/proto/context_player_options_pb2.py diff --git a/src/librespot/proto/context_track_pb2.py b/librespot/proto/context_track_pb2.py similarity index 100% rename from src/librespot/proto/context_track_pb2.py rename to librespot/proto/context_track_pb2.py diff --git a/src/librespot/proto/play_origin_pb2.py b/librespot/proto/play_origin_pb2.py similarity index 100% rename from src/librespot/proto/play_origin_pb2.py rename to librespot/proto/play_origin_pb2.py diff --git a/src/librespot/proto/playback_pb2.py b/librespot/proto/playback_pb2.py similarity index 100% rename from src/librespot/proto/playback_pb2.py rename to librespot/proto/playback_pb2.py diff --git a/src/librespot/proto/playlist4_external_pb2.py b/librespot/proto/playlist4_external_pb2.py similarity index 100% rename from src/librespot/proto/playlist4_external_pb2.py rename to librespot/proto/playlist4_external_pb2.py diff --git a/src/librespot/proto/playlist_annotate3_pb2.py b/librespot/proto/playlist_annotate3_pb2.py similarity index 100% rename from src/librespot/proto/playlist_annotate3_pb2.py rename to librespot/proto/playlist_annotate3_pb2.py diff --git a/src/librespot/proto/queue_pb2.py b/librespot/proto/queue_pb2.py similarity index 100% rename from src/librespot/proto/queue_pb2.py rename to librespot/proto/queue_pb2.py diff --git a/src/librespot/proto/restrictions_pb2.py b/librespot/proto/restrictions_pb2.py similarity index 100% rename from src/librespot/proto/restrictions_pb2.py rename to librespot/proto/restrictions_pb2.py diff --git a/src/librespot/proto/session_pb2.py b/librespot/proto/session_pb2.py similarity index 100% rename from src/librespot/proto/session_pb2.py rename to librespot/proto/session_pb2.py diff --git a/src/librespot/proto/spotify/login5/__init__.py b/librespot/proto/spotify/__init__.py similarity index 100% rename from src/librespot/proto/spotify/login5/__init__.py rename to librespot/proto/spotify/__init__.py diff --git a/src/librespot/proto/spotify/login5/v3/__init__.py b/librespot/proto/spotify/login5/__init__.py similarity index 100% rename from src/librespot/proto/spotify/login5/v3/__init__.py rename to librespot/proto/spotify/login5/__init__.py diff --git a/src/librespot/proto/spotify/login5/v3/challenges/__init__.py b/librespot/proto/spotify/login5/v3/__init__.py similarity index 100% rename from src/librespot/proto/spotify/login5/v3/challenges/__init__.py rename to librespot/proto/spotify/login5/v3/__init__.py diff --git a/src/librespot/proto/spotify/login5/v3/credentials/__init__.py b/librespot/proto/spotify/login5/v3/challenges/__init__.py similarity index 100% rename from src/librespot/proto/spotify/login5/v3/credentials/__init__.py rename to librespot/proto/spotify/login5/v3/challenges/__init__.py diff --git a/src/librespot/proto/spotify/login5/v3/challenges/code_pb2.py b/librespot/proto/spotify/login5/v3/challenges/code_pb2.py similarity index 100% rename from src/librespot/proto/spotify/login5/v3/challenges/code_pb2.py rename to librespot/proto/spotify/login5/v3/challenges/code_pb2.py diff --git a/src/librespot/proto/spotify/login5/v3/challenges/hashcash_pb2.py b/librespot/proto/spotify/login5/v3/challenges/hashcash_pb2.py similarity index 100% rename from src/librespot/proto/spotify/login5/v3/challenges/hashcash_pb2.py rename to librespot/proto/spotify/login5/v3/challenges/hashcash_pb2.py diff --git a/src/librespot/proto/spotify/login5/v3/client_info_pb2.py b/librespot/proto/spotify/login5/v3/client_info_pb2.py similarity index 100% rename from src/librespot/proto/spotify/login5/v3/client_info_pb2.py rename to librespot/proto/spotify/login5/v3/client_info_pb2.py diff --git a/src/librespot/proto/spotify/login5/v3/identifiers/__init__.py b/librespot/proto/spotify/login5/v3/credentials/__init__.py similarity index 100% rename from src/librespot/proto/spotify/login5/v3/identifiers/__init__.py rename to librespot/proto/spotify/login5/v3/credentials/__init__.py diff --git a/src/librespot/proto/spotify/login5/v3/credentials/credentials_pb2.py b/librespot/proto/spotify/login5/v3/credentials/credentials_pb2.py similarity index 100% rename from src/librespot/proto/spotify/login5/v3/credentials/credentials_pb2.py rename to librespot/proto/spotify/login5/v3/credentials/credentials_pb2.py diff --git a/librespot/proto/spotify/login5/v3/identifiers/__init__.py b/librespot/proto/spotify/login5/v3/identifiers/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/librespot/proto/spotify/login5/v3/identifiers/identifiers_pb2.py b/librespot/proto/spotify/login5/v3/identifiers/identifiers_pb2.py similarity index 100% rename from src/librespot/proto/spotify/login5/v3/identifiers/identifiers_pb2.py rename to librespot/proto/spotify/login5/v3/identifiers/identifiers_pb2.py diff --git a/src/librespot/proto/spotify/login5/v3/login5_pb2.py b/librespot/proto/spotify/login5/v3/login5_pb2.py similarity index 100% rename from src/librespot/proto/spotify/login5/v3/login5_pb2.py rename to librespot/proto/spotify/login5/v3/login5_pb2.py diff --git a/src/librespot/proto/spotify/login5/v3/user_info_pb2.py b/librespot/proto/spotify/login5/v3/user_info_pb2.py similarity index 100% rename from src/librespot/proto/spotify/login5/v3/user_info_pb2.py rename to librespot/proto/spotify/login5/v3/user_info_pb2.py diff --git a/src/librespot/proto/transfer_state_pb2.py b/librespot/proto/transfer_state_pb2.py similarity index 100% rename from src/librespot/proto/transfer_state_pb2.py rename to librespot/proto/transfer_state_pb2.py diff --git a/src/librespot/standard/AutoCloseable.py b/librespot/standard/AutoCloseable.py similarity index 100% rename from src/librespot/standard/AutoCloseable.py rename to librespot/standard/AutoCloseable.py diff --git a/src/librespot/standard/ByteArrayOutputStream.py b/librespot/standard/ByteArrayOutputStream.py similarity index 100% rename from src/librespot/standard/ByteArrayOutputStream.py rename to librespot/standard/ByteArrayOutputStream.py diff --git a/src/librespot/standard/BytesInputStream.py b/librespot/standard/BytesInputStream.py similarity index 100% rename from src/librespot/standard/BytesInputStream.py rename to librespot/standard/BytesInputStream.py diff --git a/src/librespot/standard/BytesOutputStream.py b/librespot/standard/BytesOutputStream.py similarity index 100% rename from src/librespot/standard/BytesOutputStream.py rename to librespot/standard/BytesOutputStream.py diff --git a/src/librespot/standard/Closeable.py b/librespot/standard/Closeable.py similarity index 100% rename from src/librespot/standard/Closeable.py rename to librespot/standard/Closeable.py diff --git a/src/librespot/standard/DataInput.py b/librespot/standard/DataInput.py similarity index 100% rename from src/librespot/standard/DataInput.py rename to librespot/standard/DataInput.py diff --git a/src/librespot/standard/DataInputStream.py b/librespot/standard/DataInputStream.py similarity index 100% rename from src/librespot/standard/DataInputStream.py rename to librespot/standard/DataInputStream.py diff --git a/src/librespot/standard/DataOutput.py b/librespot/standard/DataOutput.py similarity index 100% rename from src/librespot/standard/DataOutput.py rename to librespot/standard/DataOutput.py diff --git a/src/librespot/standard/FilterInputStream.py b/librespot/standard/FilterInputStream.py similarity index 100% rename from src/librespot/standard/FilterInputStream.py rename to librespot/standard/FilterInputStream.py diff --git a/src/librespot/standard/Flushable.py b/librespot/standard/Flushable.py similarity index 100% rename from src/librespot/standard/Flushable.py rename to librespot/standard/Flushable.py diff --git a/src/librespot/standard/InputStream.py b/librespot/standard/InputStream.py similarity index 100% rename from src/librespot/standard/InputStream.py rename to librespot/standard/InputStream.py diff --git a/src/librespot/standard/OutputStream.py b/librespot/standard/OutputStream.py similarity index 100% rename from src/librespot/standard/OutputStream.py rename to librespot/standard/OutputStream.py diff --git a/src/librespot/standard/Proxy.py b/librespot/standard/Proxy.py similarity index 100% rename from src/librespot/standard/Proxy.py rename to librespot/standard/Proxy.py diff --git a/src/librespot/standard/Runnable.py b/librespot/standard/Runnable.py similarity index 100% rename from src/librespot/standard/Runnable.py rename to librespot/standard/Runnable.py diff --git a/src/librespot/standard/__init__.py b/librespot/standard/__init__.py similarity index 100% rename from src/librespot/standard/__init__.py rename to librespot/standard/__init__.py diff --git a/setup.py b/setup.py index c3d1160..79318b2 100644 --- a/setup.py +++ b/setup.py @@ -9,8 +9,7 @@ setuptools.setup( author="kokarare1212", url="https://github.com/kokarare1212/librespot-python", license="Apache-2.0", - packages=setuptools.find_packages("src"), - package_dir={"": "src"}, + packages=setuptools.find_packages("."), install_requires=["defusedxml", "protobuf", "pycryptodome", "requests"], classifiers=[ "Development Status :: 1 - Planning", diff --git a/src/librespot/player/Player.py b/src/librespot/player/Player.py deleted file mode 100644 index 7e63cfd..0000000 --- a/src/librespot/player/Player.py +++ /dev/null @@ -1,21 +0,0 @@ -from librespot.core.Session import Session -from librespot.player import PlayerConfiguration, StateWrapper -import sched -import time - - -class Player: - VOLUME_MAX: int = 65536 - _scheduler: sched.scheduler = sched.scheduler(time.time) - _session: Session = None - _conf: PlayerConfiguration - state: StateWrapper - - # _playerSession: - - def __init__(self, conf: PlayerConfiguration, session: Session): - self._conf = conf - self._session = session - - def init_state(self): - self.state = StateWrapper(self._session, self, self._conf) diff --git a/src/librespot/player/StateWrapper.py b/src/librespot/player/StateWrapper.py deleted file mode 100644 index 18e7588..0000000 --- a/src/librespot/player/StateWrapper.py +++ /dev/null @@ -1,13 +0,0 @@ -from __future__ import annotations -from librespot.core import Session -from librespot.player import Player, PlayerConfiguration - - -class StateWrapper: - session: Session - player: Player - - def __init__(self, session: Session, player: Player, - conf: PlayerConfiguration): - self.session = session - self.player = player