1818 "YouTubeChannel" ,
1919]
2020
21+ from youtubeaio .types import PartMissingError
22+
2123T = TypeVar ("T" )
2224
2325
@@ -68,7 +70,14 @@ class YouTubeVideo(BaseModel):
6870 """Model representing a video."""
6971
7072 video_id : str = Field (..., alias = "id" )
71- snippet : YouTubeVideoSnippet | None = None
73+ nullable_snippet : YouTubeVideoSnippet | None = Field (None , alias = "snippet" )
74+
75+ @property
76+ def snippet (self ) -> YouTubeVideoSnippet :
77+ """Return snippet."""
78+ if self .nullable_snippet is None :
79+ raise PartMissingError
80+ return self .nullable_snippet
7281
7382
7483class YouTubeChannelThumbnails (BaseModel ):
@@ -125,18 +134,42 @@ class YouTubeChannel(BaseModel):
125134 """Model representing a YouTube channel."""
126135
127136 channel_id : str = Field (..., alias = "id" )
128- snippet : YouTubeChannelSnippet | None = None
129- content_details : YouTubeChannelContentDetails | None = Field (
137+ nullable_snippet : YouTubeChannelSnippet | None = Field ( None , alias = "snippet" )
138+ nullable_content_details : YouTubeChannelContentDetails | None = Field (
130139 None ,
131140 alias = "contentDetails" ,
132141 )
133- statistics : YouTubeChannelStatistics | None = None
142+ nullable_statistics : YouTubeChannelStatistics | None = Field (
143+ None ,
144+ alias = "statistics" ,
145+ )
134146
135147 @property
136148 def upload_playlist_id (self ) -> str :
137149 """Return playlist id with uploads from channel."""
138150 return str (self .channel_id ).replace ("UC" , "UU" , 1 )
139151
152+ @property
153+ def snippet (self ) -> YouTubeChannelSnippet :
154+ """Return snippet."""
155+ if self .nullable_snippet is None :
156+ raise PartMissingError
157+ return self .nullable_snippet
158+
159+ @property
160+ def content_details (self ) -> YouTubeChannelContentDetails :
161+ """Return content details."""
162+ if self .nullable_content_details is None :
163+ raise PartMissingError
164+ return self .nullable_content_details
165+
166+ @property
167+ def statistics (self ) -> YouTubeChannelStatistics :
168+ """Return statistics."""
169+ if self .nullable_statistics is None :
170+ raise PartMissingError
171+ return self .nullable_statistics
172+
140173
141174class YouTubeSubscriptionSnippet (BaseModel ):
142175 """Model representing a YouTube subscription snippet."""
@@ -156,7 +189,14 @@ class YouTubeSubscription(BaseModel):
156189 """Model representing a YouTube subscription."""
157190
158191 subscription_id : str = Field (..., alias = "id" )
159- snippet : YouTubeSubscriptionSnippet | None = None
192+ nullable_snippet : YouTubeSubscriptionSnippet | None = Field (None , alias = "snippet" )
193+
194+ @property
195+ def snippet (self ) -> YouTubeSubscriptionSnippet :
196+ """Return snippet."""
197+ if self .nullable_snippet is None :
198+ raise PartMissingError
199+ return self .nullable_snippet
160200
161201
162202class YouTubePlaylistItemSnippet (BaseModel ):
@@ -179,8 +219,22 @@ class YouTubePlaylistItem(BaseModel):
179219 """Model representing a YouTube playlist item."""
180220
181221 playlist_item_id : str = Field (..., alias = "id" )
182- snippet : YouTubePlaylistItemSnippet | None = Field (None )
183- content_details : YouTubePlaylistItemContentDetails | None = Field (
222+ nullable_snippet : YouTubePlaylistItemSnippet | None = Field (None , alias = "snippet" )
223+ nullable_content_details : YouTubePlaylistItemContentDetails | None = Field (
184224 None ,
185225 alias = "contentDetails" ,
186226 )
227+
228+ @property
229+ def snippet (self ) -> YouTubePlaylistItemSnippet :
230+ """Return snippet."""
231+ if self .nullable_snippet is None :
232+ raise PartMissingError
233+ return self .nullable_snippet
234+
235+ @property
236+ def content_details (self ) -> YouTubePlaylistItemContentDetails :
237+ """Return content details."""
238+ if self .nullable_content_details is None :
239+ raise PartMissingError
240+ return self .nullable_content_details
0 commit comments