Channels
This commit is contained in:
parent
4346f0d3e5
commit
167f7327c7
2 changed files with 121 additions and 7 deletions
92
piped_api/models/channels.py
Normal file
92
piped_api/models/channels.py
Normal file
|
@ -0,0 +1,92 @@
|
|||
import typing as t
|
||||
|
||||
from . import BasePipedModel
|
||||
from .videos import Video
|
||||
|
||||
|
||||
|
||||
class Channel(BasePipedModel):
|
||||
"""
|
||||
Represents a YouTube channel
|
||||
"""
|
||||
|
||||
@property
|
||||
def id(self) -> str:
|
||||
"""
|
||||
The channel's ID
|
||||
"""
|
||||
|
||||
return self.data['id']
|
||||
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
"""
|
||||
The channel's name
|
||||
"""
|
||||
|
||||
return self.data['name']
|
||||
|
||||
|
||||
@property
|
||||
def avatar_url(self) -> str:
|
||||
"""
|
||||
The channel's avatar URL
|
||||
"""
|
||||
|
||||
return self.data['avatarUrl']
|
||||
|
||||
|
||||
@property
|
||||
def banner_url(self) -> str:
|
||||
"""
|
||||
The channel's banner URL
|
||||
"""
|
||||
|
||||
return self.data['bannerUrl']
|
||||
|
||||
|
||||
@property
|
||||
def description(self) -> str:
|
||||
"""
|
||||
The channel's description
|
||||
"""
|
||||
|
||||
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:
|
||||
"""
|
||||
The number of subscribers the channel has
|
||||
"""
|
||||
|
||||
return self.data['subscriberCount']
|
||||
|
||||
|
||||
@property
|
||||
def verified(self) -> bool:
|
||||
"""
|
||||
Whether or not the channel is verified by YouTube (has a badge)
|
||||
"""
|
||||
|
||||
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']]
|
Loading…
Add table
Add a link
Reference in a new issue