wip
This commit is contained in:
parent
979aaf1299
commit
f73667a5d3
1 changed files with 35 additions and 30 deletions
|
@ -44,35 +44,26 @@ class Channel(Object):
|
|||
self.uploader_id = d["uploader_id"]
|
||||
self.uploader = d["uploader"]
|
||||
# videos
|
||||
self.videos_ids = [video["id"] for video in reversed(d["entries"])]
|
||||
# TODO filter members-only
|
||||
self.videos_ids = [
|
||||
entry["id"]
|
||||
for entry in reversed(d["entries"])
|
||||
if entry["availability"] != "subscriber_only"
|
||||
]
|
||||
# playlists
|
||||
d = extract_playlists(channel_id)
|
||||
self.playlists_ids = [playlist["id"] for playlist in reversed(d["entries"])]
|
||||
|
||||
def add_video(self, d: dict) -> dict:
|
||||
"""Add video extra info."""
|
||||
self.video_index += 1
|
||||
log.info(f"{self.video_index} ∕ {len(self.videos_ids)}")
|
||||
self.videos.append(Video(d))
|
||||
return d
|
||||
|
||||
def load_videos(self) -> None:
|
||||
"""Load videos extra info."""
|
||||
self.videos = []
|
||||
# a
|
||||
#for index, video_id in enumerate(self.videos_ids):
|
||||
# log.info(f"{index} ∕ {len(self.videos_ids)}")
|
||||
# self.videos.append(Video(video_id))
|
||||
# b
|
||||
videos_urls = [url_video(video_id) for video_id in self.videos_ids]
|
||||
y = ytdl(
|
||||
{
|
||||
"process_info_hooks": [self.add_video],
|
||||
"skip_download": True,
|
||||
},
|
||||
)
|
||||
y.download(videos_urls)
|
||||
for index, video_id in enumerate(self.videos_ids):
|
||||
log.info(f"{index} ∕ {len(self.videos_ids)}")
|
||||
self.videos.append(Video(video_id))
|
||||
|
||||
|
||||
# TODO Format
|
||||
# TODO Playlist/basic,extra
|
||||
# TODO Thumbnail
|
||||
|
||||
|
||||
class Video(Object):
|
||||
|
@ -85,17 +76,31 @@ class Video(Object):
|
|||
:type d: dict
|
||||
"""
|
||||
self.at = datetime.now().strftime("%Y%m%d%H%M%S")
|
||||
# title
|
||||
# description truncated
|
||||
# duration
|
||||
# thumbnails
|
||||
# view_count
|
||||
# info
|
||||
self.uid = d["id"]
|
||||
self.fulltitle = d["fulltitle"]
|
||||
self.duration = d["duration"]
|
||||
self.title = d["title"]
|
||||
self.description_cut = d["description"]
|
||||
self.duration = int(d["duration"])
|
||||
# TODO thumbnail from thumbnails
|
||||
|
||||
def load_extra(self):
|
||||
d = extract_video(self.uid)
|
||||
# TODO formats
|
||||
# TODO thumbnail from thumbnails
|
||||
# TODO compare existing thumbnail
|
||||
self.description = d["description"]
|
||||
# TODO channel_id
|
||||
self.duration = int(d["duration"])
|
||||
self.views = int(d["view_count"])
|
||||
self.categories = d["categories"]
|
||||
self.tags = d["tags"]
|
||||
self.description = d["description"]
|
||||
# TODO automatic_captions
|
||||
# TODO subtitles
|
||||
self.chapters = d["chapters"]
|
||||
self.likes = d["like_count"]
|
||||
# TODO from epoch
|
||||
self.timestamp = d["timestamp"]
|
||||
self.fulltitle = d["fulltitle"]
|
||||
|
||||
|
||||
# ╭──────────╮
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue