#173 Implement PlaylistId

This commit is contained in:
kokarare1212
2023-01-03 10:16:51 +09:00
parent 29ff02882b
commit e65f7fc691
2 changed files with 37 additions and 2 deletions

View File

@@ -11,8 +11,8 @@ from librespot.audio.storage import ChannelManager
from librespot.cache import CacheManager
from librespot.crypto import CipherPair, DiffieHellman, Packet
from librespot.mercury import MercuryClient, MercuryRequests, RawMercuryRequest
from librespot.metadata import AlbumId, ArtistId, EpisodeId, ShowId, TrackId
from librespot.proto import Authentication_pb2 as Authentication, ClientToken_pb2 as ClientToken, Connect_pb2 as Connect, Connectivity_pb2 as Connectivity, Keyexchange_pb2 as Keyexchange, Metadata_pb2 as Metadata
from librespot.metadata import AlbumId, ArtistId, EpisodeId, ShowId, TrackId, PlaylistId
from librespot.proto import Authentication_pb2 as Authentication, ClientToken_pb2 as ClientToken, Connect_pb2 as Connect, Connectivity_pb2 as Connectivity, Keyexchange_pb2 as Keyexchange, Metadata_pb2 as Metadata, Playlist4External_pb2 as Playlist4External
from librespot.proto.ExplicitContentPubsub_pb2 import UserAttributesUpdate
from librespot.structure import Closeable, MessageListener, RequestListener, SubListener
import base64
@@ -154,6 +154,18 @@ class ApiClient(Closeable):
proto.ParseFromString(body)
return proto
def get_playlist(self, _id: PlaylistId) -> Playlist4External.SelectedListContent:
response = self.send("GET",
"/playlist/v2/playlist/{}".format(_id.id()), None,
None)
ApiClient.StatusCodeException.check_status(response)
body = response.content
if body is None:
raise IOError()
proto = Playlist4External.SelectedListContent()
proto.ParseFromString(body)
return proto
def set_client_token(self, client_token):
self.__client_token_str = client_token