From 5295a1f4bf6c19d86e0e46c2b79def99e5718530 Mon Sep 17 00:00:00 2001 From: Ben Halling Date: Wed, 12 Feb 2025 13:58:02 +0000 Subject: [PATCH] Adds the origin field to the Shot helpers in FlixPy --- flixpy/flix/lib/models.py | 1 + flixpy/flix/lib/types.py | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/flixpy/flix/lib/models.py b/flixpy/flix/lib/models.py index 9d9032a..f9f50c0 100644 --- a/flixpy/flix/lib/models.py +++ b/flixpy/flix/lib/models.py @@ -264,6 +264,7 @@ class Shot(TypedDict, total=False): transitive: bool related_panel_revisions: list[ShotPanelRevision] metadata: list[MetadataField] + origin: str class SequenceRevisionShot(TypedDict, total=False): diff --git a/flixpy/flix/lib/types.py b/flixpy/flix/lib/types.py index 6f7dafb..70dd725 100644 --- a/flixpy/flix/lib/types.py +++ b/flixpy/flix/lib/types.py @@ -940,13 +940,18 @@ def new_panel( ) def new_shot( - self, panels: list[ShotPanelRevision] | None = None, *, transitive: bool = True + self, + panels: list[ShotPanelRevision] | None = None, + *, + transitive: bool = True, + origin: str = "Manual Import", ) -> Shot: """Construct a new shot. Args: panels: The panel revisions to include in the shot, if any. transitive: Whether the shot should be transitive (implicit). + origin: Origin of the shot, with a maximum of 25 characters. Returns: The new shot. @@ -954,6 +959,7 @@ def new_shot( return Shot( panel_revisions=panels or [], transitive=transitive, + origin=origin, _client=self.client, ) @@ -2335,6 +2341,7 @@ def __init__( shot_id: int | None = None, show_id: int | None = None, sequence_id: int | None = None, + origin: str = "Manual Import", _client: client.Client | None, ) -> None: super().__init__(_client) @@ -2348,6 +2355,7 @@ def __init__( self.shot_id: int | None = shot_id self.show_id: int | None = show_id self.sequence_id: int | None = sequence_id + self.origin = origin @classmethod def from_dict( @@ -2374,6 +2382,7 @@ def from_dict( into.shot_id = data.get("id") into.show_id = data.get("show_id") into.sequence_id = data.get("sequence_id") + into.origin = data.get("origin", "") into.metadata = Metadata.from_dict(data.get("metadata"), parent=into, _client=_client) return into @@ -2389,6 +2398,8 @@ def to_dict(self) -> models.Shot: shot["show_id"] = self.show_id if self.sequence_id: shot["sequence_id"] = self.sequence_id + if self.origin: + shot["origin"] = self.origin return shot def path_prefix(self) -> str: