diff --git a/ytnoti/base.py b/ytnoti/base.py index 2f235d3..bf2b9f1 100644 --- a/ytnoti/base.py +++ b/ytnoti/base.py @@ -365,6 +365,13 @@ async def _subscribe(self, channel_ids: str | Iterable[str]) -> None: if isinstance(channel_ids, str): channel_ids = [channel_ids] + async with AsyncClient() as client: + for channel_id in channel_ids: + response = await client.head(f"https://www.youtube.com/channel/{channel_id}") + + if response.status_code != HTTPStatus.OK.value: + raise ValueError(f"Invalid channel ID: {channel_id}") + if not self.is_ready: self._subscribed_ids.update(channel_ids) return @@ -388,13 +395,6 @@ async def _register(self, :raises HTTPError: If failed to subscribe or unsubscribe due to an HTTP error. """ - async with AsyncClient() as client: - for channel_id in channel_ids: - response = await client.head(f"https://www.youtube.com/channel/{channel_id}") - - if response.status_code != HTTPStatus.OK.value: - raise ValueError(f"Invalid channel ID: {channel_id}") - for channel_id in channel_ids: async with AsyncClient() as client: self.__logger.debug("Sending %s request for channel: %s", mode, channel_id)