Youtube Subscription Implementation (WIP)
This commit is contained in:
parent
816285efbc
commit
b80e4f7745
6 changed files with 333 additions and 133 deletions
|
|
@ -33,16 +33,6 @@ class PageInfo(_Api):
|
|||
return PageInfo(totalResults=info['totalResults'], resultsPerPage=info['resultsPerPage'])
|
||||
|
||||
|
||||
@dataclass
|
||||
class SearchResultId(_Api):
|
||||
kind: str
|
||||
videoId: str
|
||||
|
||||
@staticmethod
|
||||
def from_dict(info: dict) -> SearchResultId:
|
||||
return SearchResultId(kind=info['kind'], videoId=info['videoId'])
|
||||
|
||||
|
||||
@dataclass
|
||||
class ThumbnailInfo(_Api):
|
||||
url: str
|
||||
|
|
@ -72,7 +62,7 @@ class Thumbnails(_Api):
|
|||
class Result(Generic[T_api]):
|
||||
kind: str
|
||||
etag: str
|
||||
nextPageToken: str
|
||||
nextPageToken: str | None
|
||||
pageInfo: PageInfo
|
||||
items: list[T_api]
|
||||
|
||||
|
|
@ -82,7 +72,7 @@ class Result(Generic[T_api]):
|
|||
return cls(
|
||||
kind=info['kind'],
|
||||
etag=info['etag'],
|
||||
nextPageToken=info['nextPageToken'],
|
||||
nextPageToken=info.get('nextPageToken'),
|
||||
pageInfo=PageInfo.from_dict(info['pageInfo']),
|
||||
items=[item_type.from_dict(i) for i in info['items']])
|
||||
|
||||
|
|
@ -90,20 +80,40 @@ class Result(Generic[T_api]):
|
|||
# Channel Objects
|
||||
|
||||
|
||||
@dataclass
|
||||
class ChannelSnippet(_Api):
|
||||
title: str
|
||||
description: str
|
||||
customUrl: str
|
||||
publishedAt: datetime
|
||||
thumbnails: Thumbnails
|
||||
country: str
|
||||
|
||||
@staticmethod
|
||||
def from_dict(info: dict) -> ChannelSnippet:
|
||||
return ChannelSnippet(
|
||||
title=info['title'],
|
||||
description=info['description'],
|
||||
customUrl=info['customUrl'],
|
||||
publishedAt=datetime.fromisoformat(info['publishedAt']),
|
||||
thumbnails=Thumbnails.from_dict(info['thumbnails']),
|
||||
country=info['country'])
|
||||
|
||||
|
||||
@dataclass
|
||||
class ChannelResultItem(_Api):
|
||||
kind: str
|
||||
etag: str
|
||||
id: SearchResultId
|
||||
snippet: SearchResultSnippet
|
||||
id: str
|
||||
snippet: ChannelSnippet
|
||||
|
||||
@staticmethod
|
||||
def from_dict(info: dict) -> SearchResultItem:
|
||||
return SearchResultItem(
|
||||
def from_dict(info: dict) -> ChannelResultItem:
|
||||
return ChannelResultItem(
|
||||
kind=info['kind'],
|
||||
etag=info['etag'],
|
||||
id=SearchResultId.from_dict(info['id']),
|
||||
snippet=SearchResultSnippet.from_dict(info['snippet']))
|
||||
id=info['id'],
|
||||
snippet=ChannelSnippet.from_dict(info['snippet']))
|
||||
|
||||
|
||||
class ChannelResult(Result[ChannelResultItem]):
|
||||
|
|
@ -114,7 +124,17 @@ class ChannelResult(Result[ChannelResultItem]):
|
|||
|
||||
|
||||
@dataclass
|
||||
class SearchResultSnippet(_Api):
|
||||
class SearchResultId(_Api):
|
||||
kind: str
|
||||
videoId: str
|
||||
|
||||
@staticmethod
|
||||
def from_dict(info: dict) -> SearchResultId:
|
||||
return SearchResultId(kind=info['kind'], videoId=info['videoId'])
|
||||
|
||||
|
||||
@dataclass
|
||||
class SearchSnippet(_Api):
|
||||
publishedAt: datetime
|
||||
channelId: str
|
||||
title: str
|
||||
|
|
@ -125,8 +145,8 @@ class SearchResultSnippet(_Api):
|
|||
publishTime: datetime
|
||||
|
||||
@staticmethod
|
||||
def from_dict(info: dict) -> SearchResultSnippet:
|
||||
return SearchResultSnippet(
|
||||
def from_dict(info: dict) -> SearchSnippet:
|
||||
return SearchSnippet(
|
||||
publishedAt=datetime.fromisoformat(info['publishedAt']),
|
||||
channelId=info['channelId'],
|
||||
title=info['title'],
|
||||
|
|
@ -142,7 +162,7 @@ class SearchResultItem(_Api):
|
|||
kind: str
|
||||
etag: str
|
||||
id: SearchResultId
|
||||
snippet: SearchResultSnippet
|
||||
snippet: SearchSnippet
|
||||
|
||||
@staticmethod
|
||||
def from_dict(info: dict) -> SearchResultItem:
|
||||
|
|
@ -150,7 +170,7 @@ class SearchResultItem(_Api):
|
|||
kind=info['kind'],
|
||||
etag=info['etag'],
|
||||
id=SearchResultId.from_dict(info['id']),
|
||||
snippet=SearchResultSnippet.from_dict(info['snippet']))
|
||||
snippet=SearchSnippet.from_dict(info['snippet']))
|
||||
|
||||
|
||||
class SearchResult(Result[SearchResultItem]):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue