2020-11-01 02:35:14 +00:00
|
|
|
"""
|
|
|
|
BAPSicle Server
|
|
|
|
Next-gen audio playout server for University Radio York playout,
|
|
|
|
based on WebStudio interface.
|
|
|
|
|
|
|
|
Show Plan Items
|
|
|
|
|
|
|
|
Authors:
|
|
|
|
Michael Grace
|
|
|
|
|
|
|
|
Date:
|
|
|
|
November 2020
|
|
|
|
"""
|
|
|
|
|
2020-12-19 14:57:37 +00:00
|
|
|
from typing import Any, Dict, Optional
|
2020-11-04 00:09:42 +00:00
|
|
|
import os
|
2020-11-01 02:35:14 +00:00
|
|
|
|
2020-11-05 23:53:27 +00:00
|
|
|
class PlanItem:
|
|
|
|
_timeslotItemId: int = 0
|
2020-11-15 19:34:13 +00:00
|
|
|
_channel_weight: int = 0
|
2020-11-01 02:35:14 +00:00
|
|
|
_filename: str = ""
|
|
|
|
_title: str = ""
|
|
|
|
_artist: str = ""
|
2020-12-19 14:57:37 +00:00
|
|
|
_trackId: Optional[int] = None
|
|
|
|
_managedId: Optional[int] = None
|
2020-11-01 02:35:14 +00:00
|
|
|
|
|
|
|
@property
|
2020-11-15 19:34:13 +00:00
|
|
|
def channel_weight(self) -> int:
|
|
|
|
return self._channel_weight
|
2020-12-19 15:57:41 +00:00
|
|
|
|
2020-11-05 23:53:27 +00:00
|
|
|
def timeslotItemId(self) -> int:
|
|
|
|
return self._timeslotItemId
|
2020-11-01 02:35:14 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def filename(self) -> str:
|
|
|
|
return self._filename
|
|
|
|
|
2020-12-08 19:41:11 +00:00
|
|
|
@filename.setter
|
|
|
|
def filename(self, value: str):
|
|
|
|
self._filename = value
|
|
|
|
|
2020-11-01 02:35:14 +00:00
|
|
|
@property
|
|
|
|
def name(self) -> str:
|
|
|
|
return "{0} - {1}".format(self._title, self._artist) if self._artist else self._title
|
|
|
|
|
2020-11-05 23:53:27 +00:00
|
|
|
@property
|
2020-12-19 14:57:37 +00:00
|
|
|
def trackId(self) -> Optional[int]:
|
2020-11-05 23:53:27 +00:00
|
|
|
return self._trackId
|
|
|
|
|
2020-11-16 22:49:33 +00:00
|
|
|
@property
|
2020-12-19 14:57:37 +00:00
|
|
|
def managedId(self) -> Optional[int]:
|
2020-11-16 22:49:33 +00:00
|
|
|
return self._managedId
|
|
|
|
|
2020-11-03 00:32:43 +00:00
|
|
|
@property
|
2020-12-19 14:57:37 +00:00
|
|
|
def __dict__(self):
|
2020-11-01 02:35:14 +00:00
|
|
|
return {
|
2020-11-15 19:34:13 +00:00
|
|
|
"channel_weight": self.channel_weight,
|
2020-11-05 23:53:27 +00:00
|
|
|
"timeslotItemId": self.timeslotItemId,
|
|
|
|
"trackId": self._trackId,
|
|
|
|
"managedId": self._managedId,
|
2020-11-03 00:32:43 +00:00
|
|
|
"title": self._title,
|
|
|
|
"artist": self._artist,
|
2020-11-01 02:35:14 +00:00
|
|
|
"name": self.name,
|
|
|
|
"filename": self.filename
|
2020-11-03 00:32:43 +00:00
|
|
|
}
|
|
|
|
|
2020-12-19 14:57:37 +00:00
|
|
|
def __init__(self, new_item: Dict[str, Any]):
|
2020-11-05 23:53:27 +00:00
|
|
|
self._timeslotItemId = new_item["timeslotItemId"]
|
|
|
|
self._trackId = new_item["trackId"] if "trackId" in new_item else None
|
|
|
|
self._managedId = new_item["managedId"] if "managedId" in new_item else None
|
|
|
|
self._filename = new_item["filename"] # This could be a temp dir for API-downloaded items, or a mapped drive.
|
2020-11-15 19:34:13 +00:00
|
|
|
self._channel_weight = new_item["channel_weight"]
|
2020-11-03 00:32:43 +00:00
|
|
|
self._title = new_item["title"]
|
|
|
|
self._artist = new_item["artist"]
|
2020-11-04 00:09:42 +00:00
|
|
|
|
|
|
|
# Fix any OS specific / or \'s
|
2020-11-16 22:49:33 +00:00
|
|
|
if self.filename:
|
|
|
|
if os.path.sep == "/":
|
|
|
|
self._filename = self.filename.replace("\\", '/')
|
|
|
|
else:
|
|
|
|
self._filename = self.filename.replace("/", '\\')
|