Store plan item clean status.

This commit is contained in:
Matthew Stratford 2021-05-02 02:27:41 +01:00
parent eefc89cd42
commit 2fb1d38e6e

View file

@ -29,6 +29,7 @@ class PlanItem:
_managedid: Optional[int] _managedid: Optional[int]
_markers: List[Marker] = [] _markers: List[Marker] = []
_play_count: int _play_count: int
_clean: bool
@property @property
def weight(self) -> int: def weight(self) -> int:
@ -99,6 +100,10 @@ class PlanItem:
def type(self) -> Optional[str]: def type(self) -> Optional[str]:
return "aux" if self.managedid else "central" return "aux" if self.managedid else "central"
@property
def clean(self) -> bool:
return self._clean
@property @property
def intro(self) -> float: def intro(self) -> float:
markers = list(filter(lambda m: m.position == "start" and m.section is None, self._markers)) markers = list(filter(lambda m: m.position == "start" and m.section is None, self._markers))
@ -145,7 +150,8 @@ class PlanItem:
"outro": self.outro, "outro": self.outro,
"markers": self.markers, "markers": self.markers,
"played": self.play_count > 0, "played": self.play_count > 0,
"play_count": self.play_count "play_count": self.play_count,
"clean": self.clean
} }
def __init__(self, new_item: Dict[str, Any]): def __init__(self, new_item: Dict[str, Any]):
@ -167,6 +173,7 @@ class PlanItem:
[Marker(marker) for marker in new_item["markers"]] if "markers" in new_item else [] [Marker(marker) for marker in new_item["markers"]] if "markers" in new_item else []
) )
self._play_count = new_item["play_count"] if "play_count" in new_item else 0 self._play_count = new_item["play_count"] if "play_count" in new_item else 0
self._clean = new_item["clean"] if "clean" in new_item else True
# TODO: Edit this to handle markers when MyRadio supports them # TODO: Edit this to handle markers when MyRadio supports them
if "intro" in new_item and (isinstance(new_item["intro"], int) or isinstance(new_item["intro"], float)) and new_item["intro"] > 0: if "intro" in new_item and (isinstance(new_item["intro"], int) or isinstance(new_item["intro"], float)) and new_item["intro"] > 0: