artemis-model 0.1.115__tar.gz → 0.1.117__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. {artemis_model-0.1.115 → artemis_model-0.1.117}/PKG-INFO +1 -1
  2. {artemis_model-0.1.115 → artemis_model-0.1.117}/artemis_model/banned_tracks.py +4 -1
  3. {artemis_model-0.1.115 → artemis_model-0.1.117}/artemis_model/redis/__init__.py +4 -1
  4. {artemis_model-0.1.115 → artemis_model-0.1.117}/artemis_model/redis/bucket.py +7 -19
  5. {artemis_model-0.1.115 → artemis_model-0.1.117}/artemis_model/redis/play_history.py +3 -8
  6. {artemis_model-0.1.115 → artemis_model-0.1.117}/artemis_model/redis/zone_state.py +55 -9
  7. {artemis_model-0.1.115 → artemis_model-0.1.117}/artemis_model/zone_activity.py +2 -0
  8. {artemis_model-0.1.115 → artemis_model-0.1.117}/pyproject.toml +1 -1
  9. {artemis_model-0.1.115 → artemis_model-0.1.117}/README.md +0 -0
  10. {artemis_model-0.1.115 → artemis_model-0.1.117}/artemis_model/__init__.py +0 -0
  11. {artemis_model-0.1.115 → artemis_model-0.1.117}/artemis_model/album.py +0 -0
  12. {artemis_model-0.1.115 → artemis_model-0.1.117}/artemis_model/artist.py +0 -0
  13. {artemis_model-0.1.115 → artemis_model-0.1.117}/artemis_model/auth.py +0 -0
  14. {artemis_model-0.1.115 → artemis_model-0.1.117}/artemis_model/base.py +0 -0
  15. {artemis_model-0.1.115 → artemis_model-0.1.117}/artemis_model/category.py +0 -0
  16. {artemis_model-0.1.115 → artemis_model-0.1.117}/artemis_model/dj_set.py +0 -0
  17. {artemis_model-0.1.115 → artemis_model-0.1.117}/artemis_model/genre.py +0 -0
  18. {artemis_model-0.1.115 → artemis_model-0.1.117}/artemis_model/location.py +0 -0
  19. {artemis_model-0.1.115 → artemis_model-0.1.117}/artemis_model/message.py +0 -0
  20. {artemis_model-0.1.115 → artemis_model-0.1.117}/artemis_model/organization.py +0 -0
  21. {artemis_model-0.1.115 → artemis_model-0.1.117}/artemis_model/otp.py +0 -0
  22. {artemis_model-0.1.115 → artemis_model-0.1.117}/artemis_model/permission.py +0 -0
  23. {artemis_model-0.1.115 → artemis_model-0.1.117}/artemis_model/playlist.py +0 -0
  24. {artemis_model-0.1.115 → artemis_model-0.1.117}/artemis_model/redis/device.py +0 -0
  25. {artemis_model-0.1.115 → artemis_model-0.1.117}/artemis_model/redis/keys.py +0 -0
  26. {artemis_model-0.1.115 → artemis_model-0.1.117}/artemis_model/schedule.py +0 -0
  27. {artemis_model-0.1.115 → artemis_model-0.1.117}/artemis_model/setting.py +0 -0
  28. {artemis_model-0.1.115 → artemis_model-0.1.117}/artemis_model/sqs/__init__.py +0 -0
  29. {artemis_model-0.1.115 → artemis_model-0.1.117}/artemis_model/sqs/messages.py +0 -0
  30. {artemis_model-0.1.115 → artemis_model-0.1.117}/artemis_model/track.py +0 -0
  31. {artemis_model-0.1.115 → artemis_model-0.1.117}/artemis_model/user.py +0 -0
  32. {artemis_model-0.1.115 → artemis_model-0.1.117}/artemis_model/zone.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: artemis-model
3
- Version: 0.1.115
3
+ Version: 0.1.117
4
4
  Summary:
5
5
  Author: Jukeboxy
6
6
  Requires-Python: >=3.10.6,<4.0.0
@@ -6,16 +6,19 @@ from artemis_model.base import AuditMixin, TimeStampMixin, CustomSyncBase, Custo
6
6
 
7
7
 
8
8
  class BannedTracksMixin(TimeStampMixin, AuditMixin):
9
- """Banned Tracks per Zone Model"""
9
+ """Banned Tracks per Zone Model"""
10
+
10
11
  zone_id: Mapped[int] = mapped_column(Integer, primary_key=True)
11
12
  track_id: Mapped[UUID] = mapped_column(UUID(as_uuid=True), primary_key=True)
12
13
 
13
14
 
14
15
  class BannedTracksSync(CustomSyncBase, BannedTracksMixin):
15
16
  """Banned Tracks per Zone Model"""
17
+
16
18
  pass
17
19
 
18
20
 
19
21
  class BannedTracks(CustomBase, BannedTracksMixin):
20
22
  """Banned Tracks per Zone Model"""
23
+
21
24
  pass
@@ -1,6 +1,6 @@
1
1
  """Redis models."""
2
2
 
3
- from .zone_state import ZoneState, NowPlaying, SessionId, BucketId
3
+ from .zone_state import ZoneState, NowPlaying, SessionId, BucketId, PushedPlaylist, PushedPlaylistMetadata, PushedPlaylistDetails
4
4
  from .device import ActiveDevice
5
5
  from .bucket import RedisTrackBucketItem
6
6
  from .play_history import RedisTrackPlayHistoryItem
@@ -19,6 +19,9 @@ __all__ = [
19
19
  "SessionId",
20
20
  "BucketId",
21
21
  "ActiveDevice",
22
+ "PushedPlaylist",
23
+ "PushedPlaylistMetadata",
24
+ "PushedPlaylistDetails",
22
25
  "KEY_ZONE_PLAY_HISTORY_TEMPLATE",
23
26
  "KEY_ZONE_PUSH_PLAYLIST_BUCKET_TEMPLATE",
24
27
  "KEY_ZONE_SCHEDULE_BUCKET_TEMPLATE",
@@ -1,25 +1,16 @@
1
1
  """Redis track buckets"""
2
- import json
2
+
3
3
  from pydantic import BaseModel, Field, ConfigDict
4
4
  from typing import Annotated
5
5
  from datetime import datetime, timezone
6
6
  import uuid
7
7
 
8
8
 
9
- TrackId = Annotated[
10
- uuid.UUID,
11
- Field(description="Track ID (UUID)")
12
- ]
9
+ TrackId = Annotated[uuid.UUID, Field(description="Track ID (UUID)")]
13
10
 
14
- PlaylistId = Annotated[
15
- int,
16
- Field(description="Playlist ID (integer)")
17
- ]
11
+ PlaylistId = Annotated[int, Field(description="Playlist ID (integer)")]
18
12
 
19
- Timestamp = Annotated[
20
- int,
21
- Field(description="Unix timestamp")
22
- ]
13
+ Timestamp = Annotated[int, Field(description="Unix timestamp")]
23
14
 
24
15
 
25
16
  class RedisTrackBucketItem(BaseModel):
@@ -34,10 +25,7 @@ class RedisTrackBucketItem(BaseModel):
34
25
  playlist_id: PlaylistId
35
26
  ts: Timestamp = Field(default_factory=lambda: int(datetime.now(timezone.utc).timestamp()))
36
27
 
37
- model_config = ConfigDict(
38
- json_encoders={uuid.UUID: str},
39
- populate_by_name=True
40
- )
28
+ model_config = ConfigDict(json_encoders={uuid.UUID: str}, populate_by_name=True)
41
29
 
42
30
  def as_redis_entry(self) -> dict[str, int]:
43
31
  """
@@ -46,8 +34,7 @@ class RedisTrackBucketItem(BaseModel):
46
34
  """
47
35
  key = self.model_dump_json(include={"track_id", "playlist_id"})
48
36
  return {key: self.ts}
49
-
50
-
37
+
51
38
  @classmethod
52
39
  def from_redis_entry(cls, entry: dict[str, int]) -> "RedisTrackBucketItem":
53
40
  """
@@ -58,5 +45,6 @@ class RedisTrackBucketItem(BaseModel):
58
45
 
59
46
  class RedisTrackBucketItemValue(BaseModel):
60
47
  """JSON string format for Redis keys: '{"track_id": "...", "playlist_id": ...}'"""
48
+
61
49
  track_id: TrackId
62
50
  playlist_id: PlaylistId
@@ -5,15 +5,9 @@ from typing import Annotated
5
5
  from datetime import datetime, timezone
6
6
 
7
7
 
8
- TrackId = Annotated[
9
- str,
10
- Field(description="Track ID (UUID or string)")
11
- ]
8
+ TrackId = Annotated[str, Field(description="Track ID (UUID or string)")]
12
9
 
13
- Timestamp = Annotated[
14
- int,
15
- Field(description="Unix timestamp")
16
- ]
10
+ Timestamp = Annotated[int, Field(description="Unix timestamp")]
17
11
 
18
12
 
19
13
  class RedisTrackPlayHistoryItem(BaseModel):
@@ -21,6 +15,7 @@ class RedisTrackPlayHistoryItem(BaseModel):
21
15
  Represents the value stored in Redis sorted set:
22
16
  A string like "track_id#timestamp"
23
17
  """
18
+
24
19
  track_id: TrackId
25
20
  ts: Timestamp = Field(default_factory=lambda: int(datetime.now(timezone.utc).timestamp()))
26
21
 
@@ -27,6 +27,50 @@ BucketId = Annotated[
27
27
  ]
28
28
 
29
29
 
30
+ class PushedPlaylist(BaseModel):
31
+ """Pushed playlist schema."""
32
+
33
+ id: int = Field(
34
+ description="The id of the pushed playlist. It's generated as a timestamp value of the current time."
35
+ )
36
+ name: str = Field(
37
+ description="The name of the pushed playlist",
38
+ )
39
+
40
+
41
+ class PushedPlaylistMetadata(BaseModel):
42
+ """Pushed playlist metadata schema."""
43
+
44
+ expire_at: int = Field(
45
+ description="The expire time of the pushed playlist. It's calculated in set_bucket_track as the timestamp value of the timeslot."
46
+ )
47
+ playlists: list[PushedPlaylist] = Field(
48
+ description="The playlists of the pushed playlist",
49
+ )
50
+
51
+
52
+ class PushedPlaylistDetails(BaseModel):
53
+ """Player details schema."""
54
+
55
+ redis_details: dict[SessionId, BucketId] | None = Field(
56
+ default_factory=dict,
57
+ description="""Pushed playlists does exist in Redis with a timestamp.
58
+ Example: zone_{zone_id}_pp_bucket_{ts}
59
+ Every pushplaylist action has a session id. Here we map these session ids to the bucket id.
60
+ """,
61
+ )
62
+ metadata: PushedPlaylistMetadata | None = Field(
63
+ default=None,
64
+ description="The metadata of the pushed playlist",
65
+ )
66
+
67
+ @field_validator("redis_details", mode="before")
68
+ @classmethod
69
+ def default_empty_dict_if_none(cls, v):
70
+ """Override none value to empty dict."""
71
+ return v or {}
72
+
73
+
30
74
  class ZoneState(BaseModel):
31
75
  """Zone state schema."""
32
76
 
@@ -42,16 +86,18 @@ class ZoneState(BaseModel):
42
86
  default=None,
43
87
  description="The currently playing track",
44
88
  )
45
- push_playlist_details: dict[SessionId, BucketId] | None = Field(
46
- default_factory=dict,
89
+ pp_details: PushedPlaylistDetails | None = Field(
90
+ default=None,
47
91
  description="The details of the pushed playlist",
48
92
  )
49
93
 
50
- @field_validator("push_playlist_details", mode="before")
51
- @classmethod
52
- def default_empty_dict_if_none(cls, v):
53
- """Override none value to empty dict."""
54
- return v or {}
55
-
56
94
 
57
- __all__ = ["ZoneState", "NowPlaying", "SessionId", "BucketId"]
95
+ __all__ = [
96
+ "ZoneState",
97
+ "NowPlaying",
98
+ "SessionId",
99
+ "BucketId",
100
+ "PushedPlaylist",
101
+ "PushedPlaylistMetadata",
102
+ "PushedPlaylistDetails",
103
+ ]
@@ -39,9 +39,11 @@ class PlayerActivityMixin(TimeStampMixin, AuditMixin):
39
39
 
40
40
  class PlayerActivitySync(CustomSyncBase, PlayerActivityMixin):
41
41
  """Sync model for Player Activity"""
42
+
42
43
  pass
43
44
 
44
45
 
45
46
  class PlayerActivity(CustomBase, PlayerActivityMixin):
46
47
  """Base model for Player Activity"""
48
+
47
49
  pass
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "artemis-model"
3
- version = "0.1.115"
3
+ version = "0.1.117"
4
4
  description = ""
5
5
  authors = ["Jukeboxy"]
6
6
  readme = "README.md"