Some tweaks

This commit is contained in:
Kevo 2022-02-28 09:24:59 +01:00
parent d4ab82c07e
commit 8f8ffe3e7b
7 changed files with 164 additions and 87 deletions

View file

@ -5,9 +5,40 @@ from .videos import Video
class Channel(BasePipedModel):
class NextPageChannel(BasePipedModel):
"""
Represents a YouTube channel
Represents a channel obtained via the `nextpage` endpoint.
This model contains only `nextpage` and `relatedStreams`. It's a parent for `Channel`.
"""
@property
def nextpage(self) -> str:
"""
A JSON encoded string to be passed to the `'nextpage'` endpoint(s) when
obtaining paginated data.
"""
return self.data['nextpage']
@property
def uploaded_videos(self) -> t.List[Video.RelatedStream]:
"""
List of uploaded videos from the current fetched data
There are max. 30 videos per page
"""
return [Video.RelatedStream(video_data) for video_data in self.data['relatedStreams']]
class Channel(NextPageChannel):
"""
Represents a YouTube channel.
Contains properties of `NextPageChannel`.
"""
@property
@ -55,16 +86,6 @@ class Channel(BasePipedModel):
return self.data['description']
@property
def nextpage(self) -> str:
"""
A JSON encoded string to be passed to the `'nextpage'` endpoint(s) when
obtaining paginated data.
"""
return self.data['nextpage']
@property
def subscriber_count(self) -> int:
"""
@ -81,12 +102,3 @@ class Channel(BasePipedModel):
"""
return self.data['verified']
@property
def uploaded_videos(self) -> t.List[Video.RelatedStream]:
"""
List of uploaded videos from the current fetched data
"""
return [Video.RelatedStream(video_data) for video_data in self.data['relatedVideos']]

View file

@ -432,7 +432,7 @@ class Video(BasePipedModel):
List of related streams
"""
return [self.RelatedStream(video_data) for video_data in self.data['relatedVideos']]
return [self.RelatedStream(video_data) for video_data in self.data['relatedStreams']]