diff --git a/pyvolt/__init__.py b/pyvolt/__init__.py index 1c2ad45..b940ea3 100644 --- a/pyvolt/__init__.py +++ b/pyvolt/__init__.py @@ -22,6 +22,7 @@ from .enums import * from .errors import * from .events import * +from .flags import * from .http import * from .invite import * from .message import * diff --git a/pyvolt/embed.py b/pyvolt/embed.py index 8000217..bf93f2b 100644 --- a/pyvolt/embed.py +++ b/pyvolt/embed.py @@ -43,7 +43,8 @@ class _BaseEmbed(abc.ABC): def _stateful(self, state: State) -> Embed: ... -class EmbedSpecial(abc.ABC): +@define(slots=True) +class EmbedSpecial: """Information about special remote content.""" @@ -123,6 +124,17 @@ class BandcampEmbedSpecial(EmbedSpecial): """The Bandcamp content ID.""" +@define(slots=True) +class AppleMusicEmbedSpecial(EmbedSpecial): + """Represents information about Apple Music track.""" + + album_id: str = field(repr=True, kw_only=True, eq=True) + """The Apple Music album ID.""" + + track_id: str | None = field(repr=True, kw_only=True, eq=True) + """The Apple Music track ID.""" + + @define(slots=True) class StreamableEmbedSpecial(EmbedSpecial): """Represents information about Streamable video.""" @@ -278,6 +290,7 @@ def _stateful(self, state: State) -> Embed: 'SoundcloudEmbedSpecial', '_SOUNDCLOUD_EMBED_SPECIAL', 'BandcampEmbedSpecial', + 'AppleMusicEmbedSpecial', 'StreamableEmbedSpecial', 'ImageEmbed', 'VideoEmbed', diff --git a/pyvolt/parser.py b/pyvolt/parser.py index 72e8805..00f87b9 100644 --- a/pyvolt/parser.py +++ b/pyvolt/parser.py @@ -71,6 +71,7 @@ SoundcloudEmbedSpecial, _SOUNDCLOUD_EMBED_SPECIAL, BandcampEmbedSpecial, + AppleMusicEmbedSpecial, StreamableEmbedSpecial, ImageSize, ImageEmbed, @@ -249,6 +250,7 @@ def __init__(self, state: State) -> None: 'Spotify': self.parse_spotify_embed_special, 'Soundcloud': self.parse_soundcloud_embed_special, 'Bandcamp': self.parse_bandcamp_embed_special, + 'AppleMusic': self.parse_apple_music_embed_special, 'Streamable': self.parse_streamable_embed_special, } self._emoji_parsers = { @@ -281,7 +283,13 @@ def __init__(self, state: State) -> None: # basic start - def parse_asset_metadata(self, d: raw.Metadata) -> AssetMetadata: + def parse_apple_music_embed_special(self, d: raw.AppleMusicSpecial, /) -> AppleMusicEmbedSpecial: + return AppleMusicEmbedSpecial( + album_id=d['album_id'], + track_id=d.get('track_id'), + ) + + def parse_asset_metadata(self, d: raw.Metadata, /) -> AssetMetadata: return AssetMetadata( type=AssetMetadataType(d['type']), width=d.get('width'), diff --git a/pyvolt/raw/embeds.py b/pyvolt/raw/embeds.py index 7683514..3706680 100644 --- a/pyvolt/raw/embeds.py +++ b/pyvolt/raw/embeds.py @@ -67,6 +67,12 @@ class BandcampSpecial(typing.TypedDict): id: str +class AppleMusicSpecial(typing.TypedDict): + type: typing.Literal['AppleMusic'] + album_id: str + track_id: typing.NotRequired[str] + + class StreamableSpecial(typing.TypedDict): type: typing.Literal['Streamable'] id: str @@ -80,6 +86,7 @@ class StreamableSpecial(typing.TypedDict): | TwitchSpecial | SpotifySpecial | BandcampSpecial + | AppleMusicSpecial | StreamableSpecial ) @@ -143,6 +150,7 @@ class NoneEmbed(typing.TypedDict): 'SpotifySpecial', 'SoundcloudSpecial', 'BandcampSpecial', + 'AppleMusicSpecial', 'StreamableSpecial', 'Special', 'WebsiteMetadata',