From b3b07c26344fa9eea00ef9a801e196fd571d8727 Mon Sep 17 00:00:00 2001 From: Nate Harris Date: Wed, 4 Nov 2020 11:51:20 -0500 Subject: [PATCH 1/8] Create security_check.yml --- .github/workflows/security_check.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .github/workflows/security_check.yml diff --git a/.github/workflows/security_check.yml b/.github/workflows/security_check.yml new file mode 100644 index 0000000..6e00e06 --- /dev/null +++ b/.github/workflows/security_check.yml @@ -0,0 +1,2 @@ +- name: PyCharm Python Security Scanner + uses: tonybaloney/pycharm-security@1.20.1 From 80efe99e7c61c965cb4e16dda94141b4c98c37eb Mon Sep 17 00:00:00 2001 From: Nate Harris Date: Wed, 4 Nov 2020 11:55:17 -0500 Subject: [PATCH 2/8] Update security_check.yml --- .github/workflows/security_check.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/security_check.yml b/.github/workflows/security_check.yml index 6e00e06..884f603 100644 --- a/.github/workflows/security_check.yml +++ b/.github/workflows/security_check.yml @@ -1,2 +1,10 @@ -- name: PyCharm Python Security Scanner - uses: tonybaloney/pycharm-security@1.20.1 +on: [push] + +jobs: + security_checks: + runs-on: ubuntu-latest + name: Execute the pycharm-security action + steps: + - uses: actions/checkout@v1 + - name: Run PyCharm Security + uses: tonybaloney/pycharm-security@master From 30736658f894ee546459ee59dc42f24dd925f289 Mon Sep 17 00:00:00 2001 From: Nate Harris Date: Wed, 4 Nov 2020 11:55:38 -0500 Subject: [PATCH 3/8] Create styling.yml --- .github/workflows/styling.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/workflows/styling.yml diff --git a/.github/workflows/styling.yml b/.github/workflows/styling.yml new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/.github/workflows/styling.yml @@ -0,0 +1 @@ + From a55a9e435ec3f8155756abeaf7c27d3d93c0af1a Mon Sep 17 00:00:00 2001 From: Nate Harris Date: Wed, 4 Nov 2020 12:04:17 -0500 Subject: [PATCH 4/8] Update styling.yml --- .github/workflows/styling.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/styling.yml b/.github/workflows/styling.yml index 8b13789..551a863 100644 --- a/.github/workflows/styling.yml +++ b/.github/workflows/styling.yml @@ -1 +1,14 @@ +on: [push] +jobs: + style_check: + runs-on: ubuntu-latest + name: Style check + steps: + - uses: actions/checkout@v2 + - name: wemake-python-styleguide + uses: wemake-services/wemake-python-styleguide + with: + reporter: 'github-pr-review' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 5caf4bf3516bd9d925e884711fbc408b6ae08612 Mon Sep 17 00:00:00 2001 From: Nate Harris Date: Wed, 4 Nov 2020 12:05:23 -0500 Subject: [PATCH 5/8] Update styling.yml --- .github/workflows/styling.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/styling.yml b/.github/workflows/styling.yml index 551a863..d15f40c 100644 --- a/.github/workflows/styling.yml +++ b/.github/workflows/styling.yml @@ -11,4 +11,4 @@ jobs: with: reporter: 'github-pr-review' env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} From 7cb9701fa4ba9ae45f67197150d39bdd774b8690 Mon Sep 17 00:00:00 2001 From: Nate Harris Date: Wed, 4 Nov 2020 12:14:17 -0500 Subject: [PATCH 6/8] Update styling.yml --- .github/workflows/styling.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/styling.yml b/.github/workflows/styling.yml index d15f40c..9452101 100644 --- a/.github/workflows/styling.yml +++ b/.github/workflows/styling.yml @@ -7,7 +7,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: wemake-python-styleguide - uses: wemake-services/wemake-python-styleguide + uses: wemake-services/wemake-python-styleguide@master with: reporter: 'github-pr-review' env: From 3dbffd6ac2c70fffea4155e9e20721eaea85f52b Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 24 Nov 2020 19:53:07 -0700 Subject: [PATCH 7/8] Fix parsing issue when transcoding and watermark JSON missing. --- dizqueTV/channels.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dizqueTV/channels.py b/dizqueTV/channels.py index ec25f30..519e824 100644 --- a/dizqueTV/channels.py +++ b/dizqueTV/channels.py @@ -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'), From 569f444066cbf06d6f6ff37e71050759693f04b1 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 24 Nov 2020 19:53:23 -0700 Subject: [PATCH 8/8] Able to find a channel by name now --- README.md | 2 +- dizqueTV/dizquetv.py | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 118f498..3928d3f 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/dizqueTV/dizquetv.py b/dizqueTV/dizquetv.py index 04c5aed..6a8ef36 100644 --- a/dizqueTV/dizquetv.py +++ b/dizqueTV/dizquetv.py @@ -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: