wip
This commit is contained in:
parent
61ea62a272
commit
6a2421922b
1 changed files with 11 additions and 26 deletions
|
@ -36,20 +36,11 @@
|
||||||
# view_count
|
# view_count
|
||||||
|
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from enum import Enum
|
|
||||||
from rwx import Object
|
from rwx import Object
|
||||||
from rwx.log import stream as log
|
from rwx.log import stream as log
|
||||||
from yt_dlp import YoutubeDL
|
from yt_dlp import YoutubeDL
|
||||||
|
|
||||||
|
|
||||||
class Action(Enum):
|
|
||||||
DOWNLOAD_VIDEO = 0
|
|
||||||
EXTRACT_PLAYLIST = 1
|
|
||||||
EXTRACT_PLAYLISTS = 2
|
|
||||||
EXTRACT_VIDEO = 3
|
|
||||||
EXTRACT_VIDEOS = 4
|
|
||||||
|
|
||||||
|
|
||||||
class Tab(Object, ABC):
|
class Tab(Object, ABC):
|
||||||
"""YouTube Tab."""
|
"""YouTube Tab."""
|
||||||
|
|
||||||
|
@ -65,7 +56,9 @@ class Tab(Object, ABC):
|
||||||
log.info(self.object_id)
|
log.info(self.object_id)
|
||||||
self.url = self.get_url()
|
self.url = self.get_url()
|
||||||
log.info(self.url)
|
log.info(self.url)
|
||||||
self.info = Tab.yt_dl(self.get_options()).extract_info(self.url, download=False)
|
self.info = Tab.yt_dl(self.get_options()).extract_info(
|
||||||
|
self.url, download=False
|
||||||
|
)
|
||||||
|
|
||||||
def get_options(self) -> dict:
|
def get_options(self) -> dict:
|
||||||
"""Return options for the action.
|
"""Return options for the action.
|
||||||
|
@ -93,18 +86,18 @@ class Tab(Object, ABC):
|
||||||
|
|
||||||
class Playlist(Tab):
|
class Playlist(Tab):
|
||||||
def __init__(self, playlist_id: str) -> None:
|
def __init__(self, playlist_id: str) -> None:
|
||||||
self.playlist_id = playlist_id
|
super().__init__(playlist_id)
|
||||||
|
|
||||||
def get_url(self) -> str:
|
def get_url(self) -> str:
|
||||||
return f"{Tab.URL_ROOT}/playlist?list={self.playlist_id}"
|
return f"{Tab.URL_ROOT}/playlist?list={self.object_id}"
|
||||||
|
|
||||||
|
|
||||||
class Playlists(Tab):
|
class Playlists(Tab):
|
||||||
def __init__(self, channel_id: str) -> None:
|
def __init__(self, channel_id: str) -> None:
|
||||||
self.channel_id = channel_id
|
super().__init__(channel_id)
|
||||||
|
|
||||||
def get_url(self) -> str:
|
def get_url(self) -> str:
|
||||||
return f"{Tab.URL_ROOT}/channel/{self.channel_id}/playlists"
|
return f"{Tab.URL_ROOT}/channel/{self.object_id}/playlists"
|
||||||
|
|
||||||
|
|
||||||
# id
|
# id
|
||||||
|
@ -121,7 +114,7 @@ class Playlists(Tab):
|
||||||
# fulltitle
|
# fulltitle
|
||||||
class Video(Tab):
|
class Video(Tab):
|
||||||
def __init__(self, video_id: str) -> None:
|
def __init__(self, video_id: str) -> None:
|
||||||
self.video_id = video_id
|
super().__init__(video_id)
|
||||||
|
|
||||||
def download(self) -> None:
|
def download(self) -> None:
|
||||||
Tab.yt_dl(
|
Tab.yt_dl(
|
||||||
|
@ -134,20 +127,12 @@ class Video(Tab):
|
||||||
).download([self.url])
|
).download([self.url])
|
||||||
|
|
||||||
def get_url(self) -> str:
|
def get_url(self) -> str:
|
||||||
return f"{Tab.URL_ROOT}/watch?v={self.video_id}"
|
return f"{Tab.URL_ROOT}/watch?v={self.object_id}"
|
||||||
|
|
||||||
|
|
||||||
class Videos(Tab):
|
class Videos(Tab):
|
||||||
def __init__(self, channel_id: str) -> None:
|
def __init__(self, channel_id: str) -> None:
|
||||||
self.channel_id = channel_id
|
super().__init__(channel_id)
|
||||||
|
|
||||||
def get_url(self) -> str:
|
def get_url(self) -> str:
|
||||||
return f"{Tab.URL_ROOT}/channel/{self.channel_id}/videos"
|
return f"{Tab.URL_ROOT}/channel/{self.object_id}/videos"
|
||||||
|
|
||||||
|
|
||||||
def command(action: Action):
|
|
||||||
log.info(options)
|
|
||||||
with dl(options) as youtube:
|
|
||||||
match action:
|
|
||||||
case _:
|
|
||||||
youtube.extract_info(url, download=False)
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue