any
This commit is contained in:
parent
9e37e3be95
commit
1f046e4ba9
2 changed files with 52 additions and 25 deletions
|
@ -14,28 +14,8 @@
|
|||
# playlist / entries
|
||||
# …
|
||||
|
||||
# videos
|
||||
# id
|
||||
# channel
|
||||
# channel_id
|
||||
# title
|
||||
# channel_follower_count
|
||||
# description
|
||||
# tags
|
||||
# thumbnails
|
||||
# uploader_id
|
||||
# uploader
|
||||
# entries
|
||||
|
||||
# videos / entries
|
||||
# id
|
||||
# title
|
||||
# description truncated
|
||||
# duration
|
||||
# thumbnails
|
||||
# view_count
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Any
|
||||
from rwx import Object
|
||||
from rwx.log import stream as log
|
||||
from yt_dlp import YoutubeDL
|
||||
|
@ -57,15 +37,13 @@ class Tab(Object, ABC):
|
|||
self.url = self.get_url()
|
||||
log.info(self.url)
|
||||
|
||||
def extract(self) -> dict:
|
||||
def extract(self) -> dict[str, Any]:
|
||||
"""Return extracted dict.
|
||||
|
||||
:rtype: dict
|
||||
"""
|
||||
yt_dl = Tab.yt_dl(self.get_options())
|
||||
return yt_dl.extract_info(
|
||||
self.url, download=False
|
||||
)
|
||||
return yt_dl.extract_info(self.url, download=False)
|
||||
|
||||
def get_options(self) -> dict:
|
||||
"""Return options for the action.
|
||||
|
@ -135,9 +113,34 @@ class Video(Tab):
|
|||
return f"{Tab.URL_ROOT}/watch?v={self.object_id}"
|
||||
|
||||
|
||||
# channel
|
||||
# title
|
||||
# channel_follower_count
|
||||
# description
|
||||
# tags
|
||||
# thumbnails
|
||||
# uploader_id
|
||||
# uploader
|
||||
# videos / entries
|
||||
# title
|
||||
# description truncated
|
||||
# duration
|
||||
# thumbnails
|
||||
# view_count
|
||||
class Videos(Tab):
|
||||
def __init__(self, channel_id: str) -> None:
|
||||
super().__init__(channel_id)
|
||||
info = self.extract()
|
||||
self.title = info["title"]
|
||||
self.ids = [v["id"] for v in info["entries"]]
|
||||
self.videos = {}
|
||||
|
||||
def get_url(self) -> str:
|
||||
return f"{Tab.URL_ROOT}/channel/{self.object_id}/videos"
|
||||
|
||||
def load(self) -> None:
|
||||
done = 0
|
||||
for video_id in self.ids:
|
||||
self.videos[video_id] = Video(video_id)
|
||||
done += 1
|
||||
log.info(done)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue