Skip to content

Commit

Permalink
Merge pull request #104 from nwithan8/develop
Browse files Browse the repository at this point in the history
Prep for patch release
  • Loading branch information
nwithan8 authored Sep 22, 2022
2 parents b8e1513 + 7f27fa6 commit 3ccdabb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
14 changes: 7 additions & 7 deletions dizqueTV/dizquetv.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ def _fill_in_default_channel_settings(
:return: Dictionary of settings with defaults filled in
:rtype: dict
"""
if not settings_dict.get("programs"): # empty or doesn't exist
if not settings_dict.get("programs", []): # empty or doesn't exist
if handle_errors:
settings_dict["programs"] = [{"duration": 600000, "isOffline": True}]
else:
Expand Down Expand Up @@ -724,7 +724,7 @@ def _fill_in_default_channel_settings(
] = f"{self.url}/images/generic-offline-screen.png"
# override duration regardless of user input
settings_dict["duration"] = sum(
program["duration"] for program in settings_dict["programs"]
program["duration"] for program in settings_dict.get("programs", [])
)
settings_dict["watermark"] = fill_in_watermark_settings(**settings_dict)
return helpers._combine_settings_add_new(
Expand Down Expand Up @@ -852,9 +852,9 @@ def _make_schedule(
if res:
schedule_json = res.json()
return channel.update(
programs=schedule_json["programs"],
startTime=schedule_json["startTime"],
scheduleBackup=data["schedule"],
programs=schedule_json.get("programs", []),
startTime=schedule_json.get("startTime", ""),
scheduleBackup=data.get("schedule", {}),
)
return False

Expand Down Expand Up @@ -1600,8 +1600,8 @@ def create_custom_show_with_programs(
return CustomShow(data=custom_show_data, dizque_instance=self)

def parse_custom_shows_and_non_custom_shows(
self, items: list, non_custom_show_type, **kwargs
):
self, items: List, non_custom_show_type, **kwargs
) -> List[Union[Program, CustomShow]]:
custom_show_programs = []
current_custom_show_id = None
parsing_custom_show = False
Expand Down
6 changes: 4 additions & 2 deletions dizqueTV/models/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def delete(self) -> bool:
class Channel(BaseAPIObject):
def __init__(self, data: dict, dizque_instance, plex_server: PServer = None):
super().__init__(data, dizque_instance)
self._program_data = data.get("programs")
self._program_data = data.get("programs", [])
self._fillerCollections_data = data.get("fillerCollections")
self.fillerRepeatCooldown = data.get("fillerRepeatCooldown")
self.startTime = data.get("startTime")
Expand Down Expand Up @@ -592,8 +592,10 @@ def add_program(
ignore_keys=["_id", "id"],
):
channel_data = self._data
if not channel_data["duration"]:
if not channel_data.get("duration"):
channel_data["duration"] = 0
if not channel_data.get("programs", []):
channel_data["programs"] = []
channel_data["programs"].append(kwargs)
channel_data["duration"] += kwargs.get("duration", 0)
return self.update(**channel_data)
Expand Down
10 changes: 4 additions & 6 deletions dizqueTV/models/guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,10 @@ def get_lineup(self, from_date: datetime, to_date: datetime) -> List[GuideProgra
json_data = self._dizque_instance._get_json(
endpoint=f"/guide/channels/{self.number}", params=params
)
if json_data.get("programs"):
return [
return [
GuideProgram(data=program_data)
for program_data in json_data["programs"]
for program_data in json_data.get("programs", [])
]
return []


class Guide(BaseAPIObject):
Expand All @@ -75,10 +73,10 @@ def _create_channels_and_programs(self) -> List[GuideChannel]:
channels = []
for channel_number, data in self._data.items():
programs = [
GuideProgram(data=program_data) for program_data in data["programs"]
GuideProgram(data=program_data) for program_data in data.get("programs", [])
]
channel = GuideChannel(
data=data["channel"],
data=data.get("channel", {}),
programs=programs,
dizque_instance=self._dizque_instance,
)
Expand Down

0 comments on commit 3ccdabb

Please sign in to comment.