cp
This commit is contained in:
parent
a167190d6c
commit
02cf8f83e7
1 changed files with 142 additions and 0 deletions
142
rwx/sw/youtube/__init__.py
Normal file
142
rwx/sw/youtube/__init__.py
Normal file
|
@ -0,0 +1,142 @@
|
|||
import yt_dlp
|
||||
|
||||
# playlists
|
||||
# …
|
||||
# entries
|
||||
|
||||
# playlists / entries
|
||||
# title
|
||||
# id
|
||||
|
||||
# playlist
|
||||
# entries
|
||||
|
||||
# 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
|
||||
|
||||
|
||||
# video
|
||||
# id
|
||||
# title
|
||||
# formats
|
||||
# thumbnails
|
||||
# thumbnail
|
||||
# description
|
||||
#
|
||||
# duration
|
||||
# view_count
|
||||
# categories
|
||||
# tags
|
||||
# fulltitle
|
||||
|
||||
|
||||
def extract_playlist(playlist_id):
|
||||
options = {
|
||||
"quiet": False,
|
||||
"extract_flat": True,
|
||||
"force_generic_extractor": False,
|
||||
"ignoreerrors": False,
|
||||
}
|
||||
url = f"https://youtube.com/playlist?list={playlist_id}"
|
||||
print(f"""\
|
||||
{options}
|
||||
|
||||
{url}
|
||||
|
||||
""")
|
||||
with yt_dlp.YoutubeDL(options) as y:
|
||||
return y.extract_info(url, download=False)
|
||||
|
||||
|
||||
def extract_playlists(channel_id):
|
||||
options = {
|
||||
"quiet": False,
|
||||
"extract_flat": True,
|
||||
"force_generic_extractor": False,
|
||||
"ignoreerrors": False,
|
||||
"skip_download": True,
|
||||
}
|
||||
url = f"https://youtube.com/channel/{channel_id}/playlists"
|
||||
print(f"""\
|
||||
{options}
|
||||
|
||||
{url}
|
||||
|
||||
""")
|
||||
with yt_dlp.YoutubeDL(options) as y:
|
||||
return y.extract_info(url, download=False)
|
||||
|
||||
|
||||
def download_video(video_id):
|
||||
options = {
|
||||
"format": "bestvideo[ext=mp4]+bestaudio[ext=mp4]",
|
||||
"outtmpl": "%(id)s.%(ext)s",
|
||||
"writesubtitles": True,
|
||||
"writethumbnail": True,
|
||||
"ignoreerrors": False,
|
||||
}
|
||||
url = f"https://youtu.be/{video_id}"
|
||||
print(f"""\
|
||||
{options}
|
||||
|
||||
{url}
|
||||
|
||||
""")
|
||||
with yt_dlp.YoutubeDL(options) as y:
|
||||
return y.download([url])
|
||||
|
||||
|
||||
def extract_video(video_id):
|
||||
options = {
|
||||
"quiet": False,
|
||||
"ignoreerrors": False,
|
||||
}
|
||||
url = f"https://youtu.be/{video_id}"
|
||||
print(f"""\
|
||||
{options}
|
||||
|
||||
{url}
|
||||
|
||||
""")
|
||||
with yt_dlp.YoutubeDL(options) as y:
|
||||
return y.extract_info(url, download=False)
|
||||
|
||||
|
||||
def extract_videos(channel_id):
|
||||
options = {
|
||||
"quiet": False,
|
||||
"extract_flat": True,
|
||||
"force_generic_extractor": False,
|
||||
"ignoreerrors": False,
|
||||
}
|
||||
url = f"https://youtube.com/channel/{channel_id}/videos"
|
||||
print(f"""\
|
||||
{options}
|
||||
|
||||
{url}
|
||||
|
||||
""")
|
||||
with yt_dlp.YoutubeDL(options) as y:
|
||||
return y.extract_info(url, download=False)
|
Loading…
Add table
Add a link
Reference in a new issue