From 24b5b3ba148f7051fd49a29aa048fa45afcb52bc Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sat, 13 Jul 2024 00:41:12 +0200 Subject: [PATCH] [youtube] Added `youtube.is_subscribed` action. --- platypush/plugins/youtube/__init__.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/platypush/plugins/youtube/__init__.py b/platypush/plugins/youtube/__init__.py index 6dcee9b9c0..6d72f200cd 100644 --- a/platypush/plugins/youtube/__init__.py +++ b/platypush/plugins/youtube/__init__.py @@ -360,6 +360,19 @@ class YoutubePlugin(Plugin): json={'playlistId': id}, ) + @action + def is_subscribed(self, channel_id: str) -> bool: + """ + Check if the user is subscribed to a channel. + + :param channel_id: YouTube channel ID. + :return: True if the user is subscribed to the channel, False otherwise. + """ + return self._request( + 'subscribed', + params={'channelId': channel_id}, + ).get('subscribed', False) + @action def subscribe(self, channel_id: str): """