Merge pull request #43 from pawanpaudel93/main
Fixed the _pb2 suffix need for protobuf compiled files and also fixed issue with proxy configuration in requests Session
This commit is contained in:
commit
b96b369c3c
|
@ -1,4 +1,4 @@
|
||||||
from librespot.proto.Keyexchange import *
|
from librespot.proto.Keyexchange_pb2 import *
|
||||||
import platform
|
import platform
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ from zeroconf import Zeroconf
|
||||||
from librespot.common import Utils
|
from librespot.common import Utils
|
||||||
from librespot.core import Session
|
from librespot.core import Session
|
||||||
from librespot.crypto import DiffieHellman
|
from librespot.crypto import DiffieHellman
|
||||||
from librespot.proto import Connect
|
from librespot.proto import Connect_pb2 as Connect
|
||||||
from librespot.standard import Closeable
|
from librespot.standard import Closeable
|
||||||
from librespot.standard import Runnable
|
from librespot.standard import Runnable
|
||||||
|
|
||||||
|
|
|
@ -52,8 +52,8 @@ class AudioKeyManager(PacketsReceiver):
|
||||||
return self.get_audio_key(gid, file_id, False)
|
return self.get_audio_key(gid, file_id, False)
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
"Failed fetching audio key! gid: {}, fileId: {}".format(
|
"Failed fetching audio key! gid: {}, fileId: {}".format(
|
||||||
Utils.Utils.bytes_to_hex(gid),
|
Utils.bytes_to_hex(gid),
|
||||||
Utils.Utils.bytes_to_hex(file_id)))
|
Utils.bytes_to_hex(file_id)))
|
||||||
|
|
||||||
return key
|
return key
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ from __future__ import annotations
|
||||||
import typing
|
import typing
|
||||||
|
|
||||||
if typing.TYPE_CHECKING:
|
if typing.TYPE_CHECKING:
|
||||||
from librespot.audio import AbsChunkedInputStream
|
from librespot.audio.AbsChunkedInputStream import AbsChunkedInputStream
|
||||||
from librespot.audio.format import SuperAudioFormat
|
from librespot.audio.format import SuperAudioFormat
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,8 @@ from librespot.common.Utils import Utils
|
||||||
from librespot.core import Session
|
from librespot.core import Session
|
||||||
from librespot.metadata import PlayableId
|
from librespot.metadata import PlayableId
|
||||||
from librespot.metadata import TrackId
|
from librespot.metadata import TrackId
|
||||||
from librespot.proto import Metadata
|
from librespot.proto import Metadata_pb2 as Metadata
|
||||||
from librespot.proto import StorageResolve
|
from librespot.proto import StorageResolve_pb2 as StorageResolve
|
||||||
|
|
||||||
|
|
||||||
class PlayableContentFeeder:
|
class PlayableContentFeeder:
|
||||||
|
@ -41,7 +41,7 @@ class PlayableContentFeeder:
|
||||||
playable_id: PlayableId,
|
playable_id: PlayableId,
|
||||||
audio_quality_picker: AudioQualityPicker,
|
audio_quality_picker: AudioQualityPicker,
|
||||||
preload: bool,
|
preload: bool,
|
||||||
halt_listener: HaltListener,
|
halt_listener: HaltListener.HaltListener,
|
||||||
):
|
):
|
||||||
if type(playable_id) is TrackId:
|
if type(playable_id) is TrackId:
|
||||||
return self.load_track(playable_id, audio_quality_picker, preload,
|
return self.load_track(playable_id, audio_quality_picker, preload,
|
||||||
|
@ -74,7 +74,7 @@ class PlayableContentFeeder:
|
||||||
track_id_or_track: typing.Union[TrackId, Metadata.Track],
|
track_id_or_track: typing.Union[TrackId, Metadata.Track],
|
||||||
audio_quality_picker: AudioQualityPicker,
|
audio_quality_picker: AudioQualityPicker,
|
||||||
preload: bool,
|
preload: bool,
|
||||||
halt_listener: HaltListener,
|
halt_listener: HaltListener.HaltListener,
|
||||||
):
|
):
|
||||||
if type(track_id_or_track) is TrackId:
|
if type(track_id_or_track) is TrackId:
|
||||||
original = self.session.api().get_metadata_4_track(
|
original = self.session.api().get_metadata_4_track(
|
||||||
|
@ -98,7 +98,7 @@ class PlayableContentFeeder:
|
||||||
track: Metadata.Track,
|
track: Metadata.Track,
|
||||||
episode: Metadata.Episode,
|
episode: Metadata.Episode,
|
||||||
preload: bool,
|
preload: bool,
|
||||||
halt_lister: HaltListener,
|
halt_lister: HaltListener.HaltListener,
|
||||||
):
|
):
|
||||||
if track is None and episode is None:
|
if track is None and episode is None:
|
||||||
raise RuntimeError()
|
raise RuntimeError()
|
||||||
|
@ -124,15 +124,15 @@ class PlayableContentFeeder:
|
||||||
class LoadedStream:
|
class LoadedStream:
|
||||||
episode: Metadata.Episode
|
episode: Metadata.Episode
|
||||||
track: Metadata.Track
|
track: Metadata.Track
|
||||||
input_stream: GeneralAudioStream
|
input_stream: GeneralAudioStream.GeneralAudioStream
|
||||||
normalization_data: NormalizationData
|
normalization_data: NormalizationData.NormalizationData
|
||||||
metrics: PlayableContentFeeder.Metrics
|
metrics: PlayableContentFeeder.Metrics
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
track_or_episode: typing.Union[Metadata.Track, Metadata.Episode],
|
track_or_episode: typing.Union[Metadata.Track, Metadata.Episode],
|
||||||
input_stream: GeneralAudioStream,
|
input_stream: GeneralAudioStream.GeneralAudioStream,
|
||||||
normalization_data: NormalizationData,
|
normalization_data: NormalizationData.NormalizationData,
|
||||||
metrics: PlayableContentFeeder.Metrics,
|
metrics: PlayableContentFeeder.Metrics,
|
||||||
):
|
):
|
||||||
if type(track_or_episode) is Metadata.Track:
|
if type(track_or_episode) is Metadata.Track:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from librespot.common.Utils import Utils
|
from librespot.common.Utils import Utils
|
||||||
from librespot.proto import Metadata
|
from librespot.proto import Metadata_pb2 as Metadata
|
||||||
|
|
||||||
|
|
||||||
class StreamId:
|
class StreamId:
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
from librespot.audio.AbsChunkedInputStream import AbsChunkedInputStream
|
from librespot.audio import AbsChunkedInputStream
|
||||||
from librespot.audio.AudioKeyManager import AudioKeyManager
|
from librespot.audio import AudioKeyManager
|
||||||
from librespot.audio.GeneralAudioStream import GeneralAudioStream
|
from librespot.audio import GeneralAudioStream
|
||||||
from librespot.audio.GeneralWritableStream import GeneralWritableStream
|
from librespot.audio import GeneralWritableStream
|
||||||
from librespot.audio.HaltListener import HaltListener
|
from librespot.audio import HaltListener
|
||||||
from librespot.audio.NormalizationData import NormalizationData
|
from librespot.audio import NormalizationData
|
||||||
from librespot.audio.PlayableContentFeeder import PlayableContentFeeder
|
from librespot.audio import PlayableContentFeeder
|
||||||
from librespot.audio.StreamId import StreamId
|
from librespot.audio import StreamId
|
||||||
|
|
|
@ -10,8 +10,8 @@ from librespot.audio import NormalizationData
|
||||||
from librespot.audio import PlayableContentFeeder
|
from librespot.audio import PlayableContentFeeder
|
||||||
from librespot.common import Utils
|
from librespot.common import Utils
|
||||||
from librespot.core import Session
|
from librespot.core import Session
|
||||||
from librespot.proto import Metadata
|
from librespot.proto import Metadata_pb2 as Metadata
|
||||||
from librespot.proto import StorageResolve
|
from librespot.proto import StorageResolve_pb2 as StorageResolve
|
||||||
|
|
||||||
|
|
||||||
class CdnFeedHelper:
|
class CdnFeedHelper:
|
||||||
|
@ -28,7 +28,7 @@ class CdnFeedHelper:
|
||||||
file: Metadata.AudioFile,
|
file: Metadata.AudioFile,
|
||||||
resp_or_url: typing.Union[StorageResolve.StorageResolveResponse, str],
|
resp_or_url: typing.Union[StorageResolve.StorageResolveResponse, str],
|
||||||
preload: bool,
|
preload: bool,
|
||||||
halt_listener: HaltListener,
|
halt_listener: HaltListener.HaltListener,
|
||||||
) -> PlayableContentFeeder.PlayableContentFeeder.LoadedStream:
|
) -> PlayableContentFeeder.PlayableContentFeeder.LoadedStream:
|
||||||
if type(resp_or_url) is str:
|
if type(resp_or_url) is str:
|
||||||
url = resp_or_url
|
url = resp_or_url
|
||||||
|
@ -55,7 +55,7 @@ class CdnFeedHelper:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def load_episode_external(
|
def load_episode_external(
|
||||||
session: Session, episode: Metadata.Episode,
|
session: Session, episode: Metadata.Episode,
|
||||||
halt_listener: HaltListener
|
halt_listener: HaltListener.HaltListener
|
||||||
) -> PlayableContentFeeder.PlayableContentFeeder.LoadedStream:
|
) -> PlayableContentFeeder.PlayableContentFeeder.LoadedStream:
|
||||||
resp = session.client().head(episode.external_url)
|
resp = session.client().head(episode.external_url)
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ class CdnFeedHelper:
|
||||||
|
|
||||||
url = resp.url
|
url = resp.url
|
||||||
CdnFeedHelper._LOGGER.debug("Fetched external url for {}: {}".format(
|
CdnFeedHelper._LOGGER.debug("Fetched external url for {}: {}".format(
|
||||||
Utils.Utils.bytes_to_hex(episode.gid), url))
|
Utils.bytes_to_hex(episode.gid), url))
|
||||||
|
|
||||||
streamer = session.cdn().stream_external_episode(
|
streamer = session.cdn().stream_external_episode(
|
||||||
episode, url, halt_listener)
|
episode, url, halt_listener)
|
||||||
|
@ -82,7 +82,7 @@ class CdnFeedHelper:
|
||||||
episode: Metadata.Episode,
|
episode: Metadata.Episode,
|
||||||
file: Metadata.AudioFile,
|
file: Metadata.AudioFile,
|
||||||
resp_or_url: typing.Union[StorageResolve.StorageResolveResponse, str],
|
resp_or_url: typing.Union[StorageResolve.StorageResolveResponse, str],
|
||||||
halt_listener: HaltListener,
|
halt_listener: HaltListener.HaltListener,
|
||||||
) -> PlayableContentFeeder.PlayableContentFeeder.LoadedStream:
|
) -> PlayableContentFeeder.PlayableContentFeeder.LoadedStream:
|
||||||
if type(resp_or_url) is str:
|
if type(resp_or_url) is str:
|
||||||
url = resp_or_url
|
url = resp_or_url
|
||||||
|
@ -94,7 +94,7 @@ class CdnFeedHelper:
|
||||||
|
|
||||||
streamer = session.cdn().stream_file(file, key, url, halt_listener)
|
streamer = session.cdn().stream_file(file, key, url, halt_listener)
|
||||||
input_stream = streamer.stream()
|
input_stream = streamer.stream()
|
||||||
normalization_data = NormalizationData.read(input_stream)
|
normalization_data = NormalizationData.NormalizationData.read(input_stream)
|
||||||
if input_stream.skip(0xA7) != 0xA7:
|
if input_stream.skip(0xA7) != 0xA7:
|
||||||
raise IOError("Couldn't skip 0xa7 bytes!")
|
raise IOError("Couldn't skip 0xa7 bytes!")
|
||||||
return PlayableContentFeeder.PlayableContentFeeder.LoadedStream(
|
return PlayableContentFeeder.PlayableContentFeeder.LoadedStream(
|
||||||
|
|
|
@ -17,14 +17,14 @@ from librespot.audio.decrypt import NoopAudioDecrypt
|
||||||
from librespot.audio.format import SuperAudioFormat
|
from librespot.audio.format import SuperAudioFormat
|
||||||
from librespot.audio.storage import ChannelManager
|
from librespot.audio.storage import ChannelManager
|
||||||
from librespot.common import Utils
|
from librespot.common import Utils
|
||||||
from librespot.proto import StorageResolve
|
from librespot.proto import StorageResolve_pb2 as StorageResolve
|
||||||
|
|
||||||
if typing.TYPE_CHECKING:
|
if typing.TYPE_CHECKING:
|
||||||
from librespot.audio.decrypt.AudioDecrypt import AudioDecrypt
|
from librespot.audio.decrypt.AudioDecrypt import AudioDecrypt
|
||||||
from librespot.audio.HaltListener import HaltListener
|
from librespot.audio.HaltListener import HaltListener
|
||||||
from librespot.cache.CacheManager import CacheManager
|
from librespot.cache.CacheManager import CacheManager
|
||||||
from librespot.core.Session import Session
|
from librespot.core.Session import Session
|
||||||
from librespot.proto import Metadata
|
from librespot.proto import Metadata_pb2 as Metadata
|
||||||
|
|
||||||
|
|
||||||
class CdnManager:
|
class CdnManager:
|
||||||
|
@ -55,7 +55,7 @@ class CdnManager:
|
||||||
halt_listener: HaltListener):
|
halt_listener: HaltListener):
|
||||||
return CdnManager.Streamer(
|
return CdnManager.Streamer(
|
||||||
self._session,
|
self._session,
|
||||||
StreamId(episode),
|
StreamId.StreamId(episode),
|
||||||
SuperAudioFormat.MP3,
|
SuperAudioFormat.MP3,
|
||||||
CdnManager.CdnUrl(self, None, external_url),
|
CdnManager.CdnUrl(self, None, external_url),
|
||||||
self._session.cache(),
|
self._session.cache(),
|
||||||
|
@ -188,7 +188,7 @@ class CdnManager:
|
||||||
GeneralWritableStream.GeneralWritableStream,
|
GeneralWritableStream.GeneralWritableStream,
|
||||||
):
|
):
|
||||||
_session: Session = None
|
_session: Session = None
|
||||||
_streamId: StreamId = None
|
_streamId: StreamId.StreamId = None
|
||||||
_executorService = concurrent.futures.ThreadPoolExecutor()
|
_executorService = concurrent.futures.ThreadPoolExecutor()
|
||||||
_audioFormat: SuperAudioFormat = None
|
_audioFormat: SuperAudioFormat = None
|
||||||
_audioDecrypt: AudioDecrypt = None
|
_audioDecrypt: AudioDecrypt = None
|
||||||
|
@ -204,7 +204,7 @@ class CdnManager:
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
session: Session,
|
session: Session,
|
||||||
stream_id: StreamId,
|
stream_id: StreamId.StreamId,
|
||||||
audio_format: SuperAudioFormat,
|
audio_format: SuperAudioFormat,
|
||||||
cdn_url,
|
cdn_url,
|
||||||
cache: CacheManager,
|
cache: CacheManager,
|
||||||
|
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||||
import enum
|
import enum
|
||||||
import typing
|
import typing
|
||||||
|
|
||||||
from librespot.proto.Metadata import AudioFile
|
from librespot.proto.Metadata_pb2 import AudioFile
|
||||||
|
|
||||||
|
|
||||||
class AudioQuality(enum.Enum):
|
class AudioQuality(enum.Enum):
|
||||||
|
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||||
import typing
|
import typing
|
||||||
|
|
||||||
if typing.TYPE_CHECKING:
|
if typing.TYPE_CHECKING:
|
||||||
from librespot.proto import Metadata
|
from librespot.proto import Metadata_pb2 as Metadata
|
||||||
|
|
||||||
|
|
||||||
class AudioQualityPicker:
|
class AudioQualityPicker:
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from librespot.proto import Metadata
|
from librespot.proto import Metadata_pb2 as Metadata
|
||||||
import enum
|
import enum
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ class ChannelManager(Closeable, PacketsReceiver.PacketsReceiver):
|
||||||
else:
|
else:
|
||||||
self._LOGGER.warning(
|
self._LOGGER.warning(
|
||||||
"Couldn't handle packet, cmd: {}, payload: {}".format(
|
"Couldn't handle packet, cmd: {}, payload: {}".format(
|
||||||
packet.cmd, Utils.Utils.bytes_to_hex(packet.payload)))
|
packet.cmd, Utils.bytes_to_hex(packet.payload)))
|
||||||
|
|
||||||
def close(self) -> None:
|
def close(self) -> None:
|
||||||
self._executorService.shutdown()
|
self._executorService.shutdown()
|
||||||
|
|
|
@ -35,10 +35,10 @@ from librespot.dealer import ApiClient
|
||||||
from librespot.dealer import DealerClient
|
from librespot.dealer import DealerClient
|
||||||
from librespot.mercury import MercuryClient
|
from librespot.mercury import MercuryClient
|
||||||
from librespot.mercury import SubListener
|
from librespot.mercury import SubListener
|
||||||
from librespot.proto import Authentication
|
from librespot.proto import Authentication_pb2 as Authentication
|
||||||
from librespot.proto import Connect
|
from librespot.proto import Connect_pb2 as Connect
|
||||||
from librespot.proto import Keyexchange
|
from librespot.proto import Keyexchange_pb2 as Keyexchange
|
||||||
from librespot.proto.ExplicitContentPubsub import UserAttributesUpdate
|
from librespot.proto.ExplicitContentPubsub_pb2 import UserAttributesUpdate
|
||||||
from librespot.standard import BytesInputStream
|
from librespot.standard import BytesInputStream
|
||||||
from librespot.standard import Closeable
|
from librespot.standard import Closeable
|
||||||
from librespot.standard import Proxy
|
from librespot.standard import Proxy
|
||||||
|
@ -321,7 +321,7 @@ class Session(Closeable, SubListener, DealerClient.MessageListener):
|
||||||
_receiver: Session.Receiver = None
|
_receiver: Session.Receiver = None
|
||||||
_apWelcome: Authentication.APWelcome = None
|
_apWelcome: Authentication.APWelcome = None
|
||||||
_mercuryClient: MercuryClient = None
|
_mercuryClient: MercuryClient = None
|
||||||
_audioKeyManager: AudioKeyManager = None
|
_audioKeyManager: AudioKeyManager.AudioKeyManager = None
|
||||||
_channelManager: ChannelManager = None
|
_channelManager: ChannelManager = None
|
||||||
_tokenProvider: TokenProvider = None
|
_tokenProvider: TokenProvider = None
|
||||||
_cdnManager: CdnManager = None
|
_cdnManager: CdnManager = None
|
||||||
|
@ -329,7 +329,7 @@ class Session(Closeable, SubListener, DealerClient.MessageListener):
|
||||||
_dealer: DealerClient = None
|
_dealer: DealerClient = None
|
||||||
_api: ApiClient = None
|
_api: ApiClient = None
|
||||||
_search: SearchManager = None
|
_search: SearchManager = None
|
||||||
_contentFeeder: PlayableContentFeeder = None
|
_contentFeeder: PlayableContentFeeder.PlayableContentFeeder = None
|
||||||
_eventService: EventService = None
|
_eventService: EventService = None
|
||||||
_countryCode: str = None
|
_countryCode: str = None
|
||||||
_closed: bool = False
|
_closed: bool = False
|
||||||
|
@ -348,16 +348,13 @@ class Session(Closeable, SubListener, DealerClient.MessageListener):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _create_client(conf: Session.Configuration) -> requests.Session:
|
def _create_client(conf: Session.Configuration) -> requests.Session:
|
||||||
client = requests.Session()
|
client = requests.Session()
|
||||||
if conf.proxyAuth and conf.proxyType is not Proxy.Type.DIRECT:
|
if conf.proxyAddress and conf.proxyPort and conf.proxyType is not Proxy.Type.DIRECT:
|
||||||
if conf.proxyAuth:
|
proxy_setting = [
|
||||||
proxy_setting = [
|
conf.proxyUsername,
|
||||||
conf.proxyUsername,
|
conf.proxyPassword,
|
||||||
conf.proxyPassword,
|
conf.proxyAddress,
|
||||||
conf.proxyAddress,
|
conf.proxyPort,
|
||||||
conf.proxyPort,
|
]
|
||||||
]
|
|
||||||
else:
|
|
||||||
proxy_setting = [conf.proxyAddress, conf.proxyPort]
|
|
||||||
client.proxies = {
|
client.proxies = {
|
||||||
"http": "{}:{}@{}:{}".format(*proxy_setting),
|
"http": "{}:{}@{}:{}".format(*proxy_setting),
|
||||||
"https": "{}:{}@{}:{}".format(*proxy_setting),
|
"https": "{}:{}@{}:{}".format(*proxy_setting),
|
||||||
|
@ -686,7 +683,7 @@ class Session(Closeable, SubListener, DealerClient.MessageListener):
|
||||||
raise RuntimeError("Session isn't authenticated!")
|
raise RuntimeError("Session isn't authenticated!")
|
||||||
return self._mercuryClient
|
return self._mercuryClient
|
||||||
|
|
||||||
def audio_key(self) -> AudioKeyManager:
|
def audio_key(self) -> AudioKeyManager.AudioKeyManager:
|
||||||
self._wait_auth_lock()
|
self._wait_auth_lock()
|
||||||
if self._audioKeyManager is None:
|
if self._audioKeyManager is None:
|
||||||
raise RuntimeError("Session isn't authenticated!")
|
raise RuntimeError("Session isn't authenticated!")
|
||||||
|
@ -728,7 +725,7 @@ class Session(Closeable, SubListener, DealerClient.MessageListener):
|
||||||
raise RuntimeError("Session isn't authenticated!")
|
raise RuntimeError("Session isn't authenticated!")
|
||||||
return self._api
|
return self._api
|
||||||
|
|
||||||
def content_feeder(self) -> PlayableContentFeeder:
|
def content_feeder(self) -> PlayableContentFeeder.PlayableContentFeeder:
|
||||||
if self._contentFeeder is None:
|
if self._contentFeeder is None:
|
||||||
raise RuntimeError("Session isn't authenticated!")
|
raise RuntimeError("Session isn't authenticated!")
|
||||||
return self._contentFeeder
|
return self._contentFeeder
|
||||||
|
|
|
@ -9,8 +9,8 @@ from librespot.metadata import ArtistId
|
||||||
from librespot.metadata import EpisodeId
|
from librespot.metadata import EpisodeId
|
||||||
from librespot.metadata import ShowId
|
from librespot.metadata import ShowId
|
||||||
from librespot.metadata import TrackId
|
from librespot.metadata import TrackId
|
||||||
from librespot.proto import Connect
|
from librespot.proto import Connect_pb2 as Connect
|
||||||
from librespot.proto import Metadata
|
from librespot.proto import Metadata_pb2 as Metadata
|
||||||
from librespot.standard import Closeable
|
from librespot.standard import Closeable
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,8 @@ from librespot.crypto import Packet
|
||||||
from librespot.mercury import JsonMercuryRequest
|
from librespot.mercury import JsonMercuryRequest
|
||||||
from librespot.mercury import RawMercuryRequest
|
from librespot.mercury import RawMercuryRequest
|
||||||
from librespot.mercury import SubListener
|
from librespot.mercury import SubListener
|
||||||
from librespot.proto import Mercury
|
from librespot.proto import Mercury_pb2 as Mercury
|
||||||
from librespot.proto import Pubsub
|
from librespot.proto import Pubsub_pb2 as Pubsub
|
||||||
from librespot.standard import BytesInputStream
|
from librespot.standard import BytesInputStream
|
||||||
from librespot.standard import BytesOutputStream
|
from librespot.standard import BytesOutputStream
|
||||||
from librespot.standard import Closeable
|
from librespot.standard import Closeable
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import typing
|
import typing
|
||||||
|
|
||||||
from librespot.proto import Mercury
|
from librespot.proto import Mercury_pb2 as Mercury
|
||||||
|
|
||||||
|
|
||||||
class RawMercuryRequest:
|
class RawMercuryRequest:
|
||||||
|
|
|
@ -4,7 +4,7 @@ import re
|
||||||
|
|
||||||
from librespot.common import Base62
|
from librespot.common import Base62
|
||||||
from librespot.common import Utils
|
from librespot.common import Utils
|
||||||
from librespot.proto.ContextTrack import ContextTrack
|
from librespot.proto.ContextTrack_pb2 import ContextTrack
|
||||||
|
|
||||||
|
|
||||||
class SpotifyId:
|
class SpotifyId:
|
||||||
|
@ -166,14 +166,14 @@ class EpisodeId(SpotifyId, PlayableId):
|
||||||
if matcher is not None:
|
if matcher is not None:
|
||||||
episode_id = matcher.group(1)
|
episode_id = matcher.group(1)
|
||||||
return EpisodeId(
|
return EpisodeId(
|
||||||
Utils.Utils.bytes_to_hex(
|
Utils.bytes_to_hex(
|
||||||
PlayableId.BASE62.decode(episode_id, 16)))
|
PlayableId.BASE62.decode(episode_id, 16)))
|
||||||
TypeError("Not a Spotify episode ID: {}".format(uri))
|
TypeError("Not a Spotify episode ID: {}".format(uri))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def from_base62(base62: str) -> EpisodeId:
|
def from_base62(base62: str) -> EpisodeId:
|
||||||
return EpisodeId(
|
return EpisodeId(
|
||||||
Utils.Utils.bytes_to_hex(PlayableId.BASE62.decode(base62, 16)))
|
Utils.bytes_to_hex(PlayableId.BASE62.decode(base62, 16)))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def from_hex(hex_str: str) -> EpisodeId:
|
def from_hex(hex_str: str) -> EpisodeId:
|
||||||
|
@ -184,13 +184,13 @@ class EpisodeId(SpotifyId, PlayableId):
|
||||||
|
|
||||||
def to_spotify_uri(self) -> str:
|
def to_spotify_uri(self) -> str:
|
||||||
return "Spotify:episode:{}".format(
|
return "Spotify:episode:{}".format(
|
||||||
PlayableId.BASE62.encode(Utils.Utils.hex_to_bytes(self._hexId)))
|
PlayableId.BASE62.encode(Utils.hex_to_bytes(self._hexId)))
|
||||||
|
|
||||||
def hex_id(self) -> str:
|
def hex_id(self) -> str:
|
||||||
return self._hexId
|
return self._hexId
|
||||||
|
|
||||||
def get_gid(self) -> bytes:
|
def get_gid(self) -> bytes:
|
||||||
return Utils.Utils.hex_to_bytes(self._hexId)
|
return Utils.hex_to_bytes(self._hexId)
|
||||||
|
|
||||||
|
|
||||||
class ShowId(SpotifyId):
|
class ShowId(SpotifyId):
|
||||||
|
|
|
@ -7,11 +7,11 @@ from librespot.dealer import DealerClient
|
||||||
from librespot.player import Player
|
from librespot.player import Player
|
||||||
from librespot.player import PlayerConfiguration
|
from librespot.player import PlayerConfiguration
|
||||||
from librespot.player.state import DeviceStateHandler
|
from librespot.player.state import DeviceStateHandler
|
||||||
from librespot.proto import Connect
|
from librespot.proto import Connect_pb2 as Connect
|
||||||
from librespot.proto.Player import ContextPlayerOptions
|
from librespot.proto.Player_pb2 import ContextPlayerOptions
|
||||||
from librespot.proto.Player import PlayerState
|
from librespot.proto.Player_pb2 import PlayerState
|
||||||
from librespot.proto.Player import Restrictions
|
from librespot.proto.Player_pb2 import Restrictions
|
||||||
from librespot.proto.Player import Suppressions
|
from librespot.proto.Player_pb2 import Suppressions
|
||||||
|
|
||||||
|
|
||||||
class StateWrapper(DeviceStateHandler.Listener, DealerClient.MessageListener):
|
class StateWrapper(DeviceStateHandler.Listener, DealerClient.MessageListener):
|
||||||
|
|
|
@ -6,7 +6,7 @@ import typing
|
||||||
from librespot.audio.decoders.AudioQuality import AudioQuality
|
from librespot.audio.decoders.AudioQuality import AudioQuality
|
||||||
from librespot.audio.format.AudioQualityPicker import AudioQualityPicker
|
from librespot.audio.format.AudioQualityPicker import AudioQualityPicker
|
||||||
from librespot.audio.format.SuperAudioFormat import SuperAudioFormat
|
from librespot.audio.format.SuperAudioFormat import SuperAudioFormat
|
||||||
from librespot.proto import Metadata
|
from librespot.proto import Metadata_pb2 as Metadata
|
||||||
|
|
||||||
|
|
||||||
class VorbisOnlyAudioQuality(AudioQualityPicker):
|
class VorbisOnlyAudioQuality(AudioQualityPicker):
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
from librespot.player.codecs.VorbisOnlyAudioQuality import \
|
from librespot.player.codecs.VorbisOnlyAudioQuality import VorbisOnlyAudioQuality
|
||||||
VorbisOnlyAudioQuality
|
|
||||||
|
|
|
@ -11,8 +11,8 @@ import urllib.parse
|
||||||
from librespot.common import Utils
|
from librespot.common import Utils
|
||||||
from librespot.core import Session
|
from librespot.core import Session
|
||||||
from librespot.player import PlayerConfiguration
|
from librespot.player import PlayerConfiguration
|
||||||
from librespot.proto import Connect
|
from librespot.proto import Connect_pb2 as Connect
|
||||||
from librespot.proto import Player
|
from librespot.proto import Player_pb2 as Player
|
||||||
|
|
||||||
|
|
||||||
class DeviceStateHandler:
|
class DeviceStateHandler:
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||||
# source: canvaz.proto
|
# source: canvaz.proto
|
||||||
"""Generated protocol buffer code."""
|
"""Generated protocol buffer code."""
|
||||||
import CanvazMeta as canvaz__meta__pb2
|
import CanvazMeta_pb2 as canvaz__meta__pb2
|
||||||
from google.protobuf import descriptor as _descriptor
|
from google.protobuf import descriptor as _descriptor
|
||||||
from google.protobuf import message as _message
|
from google.protobuf import message as _message
|
||||||
from google.protobuf import reflection as _reflection
|
from google.protobuf import reflection as _reflection
|
|
@ -11,7 +11,7 @@ from google.protobuf import symbol_database as _symbol_database
|
||||||
|
|
||||||
_sym_db = _symbol_database.Default()
|
_sym_db = _symbol_database.Default()
|
||||||
|
|
||||||
import librespot.proto.Player as player__pb2
|
import librespot.proto.Player_pb2 as player__pb2
|
||||||
|
|
||||||
DESCRIPTOR = _descriptor.FileDescriptor(
|
DESCRIPTOR = _descriptor.FileDescriptor(
|
||||||
name='connect.proto',
|
name='connect.proto',
|
|
@ -2,7 +2,7 @@
|
||||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||||
# source: context_page.proto
|
# source: context_page.proto
|
||||||
"""Generated protocol buffer code."""
|
"""Generated protocol buffer code."""
|
||||||
import ContextTrack as context__track__pb2
|
import ContextTrack_pb2 as context__track__pb2
|
||||||
from google.protobuf import descriptor as _descriptor
|
from google.protobuf import descriptor as _descriptor
|
||||||
from google.protobuf import message as _message
|
from google.protobuf import message as _message
|
||||||
from google.protobuf import reflection as _reflection
|
from google.protobuf import reflection as _reflection
|
|
@ -2,8 +2,8 @@
|
||||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||||
# source: context.proto
|
# source: context.proto
|
||||||
"""Generated protocol buffer code."""
|
"""Generated protocol buffer code."""
|
||||||
import ContextPage as context__page__pb2
|
import ContextPage_pb2 as context__page__pb2
|
||||||
import Restrictions as restrictions__pb2
|
import Restrictions_pb2 as restrictions__pb2
|
||||||
from google.protobuf import descriptor as _descriptor
|
from google.protobuf import descriptor as _descriptor
|
||||||
from google.protobuf import message as _message
|
from google.protobuf import message as _message
|
||||||
from google.protobuf import reflection as _reflection
|
from google.protobuf import reflection as _reflection
|
|
@ -2,7 +2,7 @@
|
||||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||||
# source: playback.proto
|
# source: playback.proto
|
||||||
"""Generated protocol buffer code."""
|
"""Generated protocol buffer code."""
|
||||||
import ContextTrack as context__track__pb2
|
import ContextTrack_pb2 as context__track__pb2
|
||||||
from google.protobuf import descriptor as _descriptor
|
from google.protobuf import descriptor as _descriptor
|
||||||
from google.protobuf import message as _message
|
from google.protobuf import message as _message
|
||||||
from google.protobuf import reflection as _reflection
|
from google.protobuf import reflection as _reflection
|
|
@ -2,7 +2,7 @@
|
||||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||||
# source: queue.proto
|
# source: queue.proto
|
||||||
"""Generated protocol buffer code."""
|
"""Generated protocol buffer code."""
|
||||||
import ContextTrack as context__track__pb2
|
import ContextTrack_pb2 as context__track__pb2
|
||||||
from google.protobuf import descriptor as _descriptor
|
from google.protobuf import descriptor as _descriptor
|
||||||
from google.protobuf import message as _message
|
from google.protobuf import message as _message
|
||||||
from google.protobuf import reflection as _reflection
|
from google.protobuf import reflection as _reflection
|
|
@ -2,9 +2,9 @@
|
||||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||||
# source: session.proto
|
# source: session.proto
|
||||||
"""Generated protocol buffer code."""
|
"""Generated protocol buffer code."""
|
||||||
import Context as context__pb2
|
import Context_pb2 as context__pb2
|
||||||
import ContextPlayerOptions as context__player__options__pb2
|
import ContextPlayerOptions_pb2 as context__player__options__pb2
|
||||||
import PlayOrigin as play__origin__pb2
|
import PlayOrigin_pb2 as play__origin__pb2
|
||||||
from google.protobuf import descriptor as _descriptor
|
from google.protobuf import descriptor as _descriptor
|
||||||
from google.protobuf import message as _message
|
from google.protobuf import message as _message
|
||||||
from google.protobuf import reflection as _reflection
|
from google.protobuf import reflection as _reflection
|
|
@ -2,10 +2,10 @@
|
||||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||||
# source: transfer_state.proto
|
# source: transfer_state.proto
|
||||||
"""Generated protocol buffer code."""
|
"""Generated protocol buffer code."""
|
||||||
import ContextPlayerOptions as context__player__options__pb2
|
import ContextPlayerOptions_pb2 as context__player__options__pb2
|
||||||
import Playback as playback__pb2
|
import Playback_pb2 as playback__pb2
|
||||||
import Queue as queue__pb2
|
import Queue_pb2 as queue__pb2
|
||||||
import Session as session__pb2
|
import Session_pb2 as session__pb2
|
||||||
from google.protobuf import descriptor as _descriptor
|
from google.protobuf import descriptor as _descriptor
|
||||||
from google.protobuf import message as _message
|
from google.protobuf import message as _message
|
||||||
from google.protobuf import reflection as _reflection
|
from google.protobuf import reflection as _reflection
|
Loading…
Reference in New Issue