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_id = d["uploader_id"]
|
||||||
self.uploader = d["uploader"]
|
self.uploader = d["uploader"]
|
||||||
# videos
|
# videos
|
||||||
self.videos_ids = [video["id"] for video in reversed(d["entries"])]
|
self.videos_ids = [
|
||||||
# TODO filter members-only
|
entry["id"]
|
||||||
|
for entry in reversed(d["entries"])
|
||||||
|
if entry["availability"] != "subscriber_only"
|
||||||
|
]
|
||||||
# playlists
|
# playlists
|
||||||
d = extract_playlists(channel_id)
|
d = extract_playlists(channel_id)
|
||||||
self.playlists_ids = [playlist["id"] for playlist in reversed(d["entries"])]
|
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:
|
def load_videos(self) -> None:
|
||||||
"""Load videos extra info."""
|
"""Load videos extra info."""
|
||||||
self.videos = []
|
self.videos = []
|
||||||
# a
|
for index, video_id in enumerate(self.videos_ids):
|
||||||
#for index, video_id in enumerate(self.videos_ids):
|
log.info(f"{index} ∕ {len(self.videos_ids)}")
|
||||||
# log.info(f"{index} ∕ {len(self.videos_ids)}")
|
self.videos.append(Video(video_id))
|
||||||
# self.videos.append(Video(video_id))
|
|
||||||
# b
|
|
||||||
videos_urls = [url_video(video_id) for video_id in self.videos_ids]
|
# TODO Format
|
||||||
y = ytdl(
|
# TODO Playlist/basic,extra
|
||||||
{
|
# TODO Thumbnail
|
||||||
"process_info_hooks": [self.add_video],
|
|
||||||
"skip_download": True,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
y.download(videos_urls)
|
|
||||||
|
|
||||||
|
|
||||||
class Video(Object):
|
class Video(Object):
|
||||||
|
@ -85,17 +76,31 @@ class Video(Object):
|
||||||
:type d: dict
|
:type d: dict
|
||||||
"""
|
"""
|
||||||
self.at = datetime.now().strftime("%Y%m%d%H%M%S")
|
self.at = datetime.now().strftime("%Y%m%d%H%M%S")
|
||||||
# title
|
# info
|
||||||
# description truncated
|
|
||||||
# duration
|
|
||||||
# thumbnails
|
|
||||||
# view_count
|
|
||||||
self.uid = d["id"]
|
self.uid = d["id"]
|
||||||
self.fulltitle = d["fulltitle"]
|
self.title = d["title"]
|
||||||
self.duration = d["duration"]
|
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.categories = d["categories"]
|
||||||
self.tags = d["tags"]
|
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