Youtube Subscription Implementation (WIP)

This commit is contained in:
BreadTube 2025-09-26 23:41:51 +09:00 committed by Corentin
commit b80e4f7745
6 changed files with 333 additions and 133 deletions

View file

@ -7,7 +7,7 @@ from typing import TYPE_CHECKING
import urllib.error
import urllib.request
from breadtube_bot.yt_objects import SearchResult
from .yt_objects import ChannelResult, SearchResult
if TYPE_CHECKING:
@ -57,11 +57,11 @@ class YoutubeManager:
raise RuntimeError(f'Timeout calling YT API ({url}): {error}') from error
def request_channel_info(self, channel_id: str, request_timeout: float) -> tuple[
HTTPHeaders, dict]:
HTTPHeaders, ChannelResult]:
url = ('https://www.googleapis.com/youtube/v3/channels?part=snippet'
f'&id={channel_id}&key={self._api_key}')
headers, info = self._request(url=url, request_timeout=request_timeout)
return headers, info
return headers, ChannelResult.from_dict(info)
def request_channel_videos(self, channel_id: str, max_results: int, request_timeout: float) -> tuple[
HTTPHeaders, SearchResult]: