Skip to content

Commit

Permalink
Merge pull request #67 from nwithan8/develop
Browse files Browse the repository at this point in the history
Prep v1.2.2 hf 1
  • Loading branch information
nwithan8 authored Nov 25, 2020
2 parents a9a5975 + 569f444 commit 194e829
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Enable verbose logging by passing ``verbose=True`` into the ``API`` object decla
#### Channels
- Get all channels: ``channels = dtv.channels`` -> list of ``Channel`` objects
- Get all channel numbers: ``channel_numbers = dtv.channel_numbers`` -> list of ints
- Get a specific channel: ``channel = dtv.get_channel(channel_number: int)`` -> ``Channel`` object
- Get a specific channel: ``channel = dtv.get_channel(channel_number: int, channel_name: str)`` -> ``Channel`` object
- Get brief info on a specific channel: ``channel_info = dtv.get_channel_info(channel_number: int)`` -> ``{"name": str, "number": int, "icon": str}``
- Add a channel: ``new_channel = dtv.add_channel(programs: [Program, PlexAPI Video, ...], plex_server: PlexAPI Server [Optional], handle_errors: bool, **kwargs)`` -> ``Channel`` object
- Update a channel: ``updated = dtv.update_channel(channel_number: int, **kwargs)`` or ``Channel.update(**kwargs)`` -> True/False
Expand Down
4 changes: 2 additions & 2 deletions dizqueTV/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,10 @@ def __init__(self,
for filler_data in data.get('fallback')]
self.watermark = Watermark(data=data.get('watermark'),
dizque_instance=dizque_instance,
channel_instance=self)
channel_instance=self) if data.get('watermark') else None
self.transcoding = ChannelFFMPEGSettings(data=data.get('transcoding'),
dizque_instance=dizque_instance,
channel_instance=self)
channel_instance=self) if data.get('transcoding') else None
self.schedule = None
if data.get('scheduleBackup'):
self.schedule = Schedule(data=data.get('scheduleBackup'),
Expand Down
18 changes: 13 additions & 5 deletions dizqueTV/dizquetv.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,17 +335,25 @@ def channels(self) -> List[Channel]:
json_data = self._get_json(endpoint='/channels', timeout=5) # large JSON may take longer, so bigger timeout
return [Channel(data=channel, dizque_instance=self) for channel in json_data]

def get_channel(self, channel_number: int) -> Union[Channel, None]:
def get_channel(self, channel_number: int = None, channel_name: str = None) -> Union[Channel, None]:
"""
Get a specific dizqueTV channel
Get a specific dizqueTV channel by number or name
:param channel_number: Number of channel
:param channel_name: Name of channel
:return: Channel object or None
:rtype: Channel | None
"""
channel_data = self._get_json(endpoint=f'/channel/{channel_number}')
if channel_data:
return Channel(data=channel_data, dizque_instance=self)
if not channel_number and not channel_name:
raise MissingParametersError("Must include either 'channel_number' or 'channel_name'")
if channel_number:
channel_data = self._get_json(endpoint=f'/channel/{channel_number}')
if channel_data:
return Channel(data=channel_data, dizque_instance=self)
if channel_name:
for channel in self.channels:
if channel.name == channel_name:
return channel
return None

def get_channel_info(self, channel_number: int) -> json:
Expand Down

0 comments on commit 194e829

Please # to comment.