-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Buildout YouTubeResource functionality #333
Comments
Various youtube automation efforts:
|
The It is time to revisit the functionality in Requirements
Design
ClassesYouTubeResource
YouTubeBase
YouTubeVideo(YouTubeBase)
Example usage to download yt_vid = YouTubeVideo(url=video_url)
vid_metadata = yt_vid.get_ricecooker_node()
vid_node = VideoNode(**vid_metadata)
vid_node.add_file(YouTubeVideoFile(url=vid_metadata['id'], lang=?))
lang_codes = yt_vid.get_subtitle_languages()
for lang_code in lang_codes:
vid_node.add_file(YouTubeSubtitleFile(youtube_id=vid_metadata['id'], lang=lang_code)) YouTubePlaylist(YouTubeBase)
Example usage to download yt_pl = YouTubePlaylist(url=playlist_url)
pl_metadata = yt_pl.get_ricecooker_node(options={"extract_flat":True})
video_urls = pl_metadata.pop('children')
topic_node = TopicNode(**pl_metadata)
for video_url in video_urls:
yt_vid = YouTubeVideo(url=video_url)
vid_metadata = yt_vid.get_ricecooker_node()
vid_node = VideoNode(**vid_metadata)
vid_node.add_file(YouTubeVideoFile(url=vid_metadata['id'], lang=?))
topic_node.add_child(vid_node) YouTubeChannel(YouTubeBase)
Example usage, to download the videos from all the playlists of the youtube user KhanAcademyKiswahili, run: channel_node = Channel(name="KA Swahili", source_id, ...)
yt_ch = YouTubeChannel(id="KhanAcademyKiswahili")
playlist_urls = yt_ch.get_playlists_flat() # == get_info(options={"extract_flat":True})['entries']
for playlist_url in playlist_urls:
yt_pl = YouTubePlaylist(url=playlist_url)
pl_metadata = yt_pl.get_ricecooker_node(options={"extract_flat":True})
video_urls = pl_metadata.pop('children')
topic_node = TopicNode(**pl_metadata)
for video_url in video_urls:
yt_vid = YouTubeVideo(url=video_url)
vid_metadata = yt_vid.get_ricecooker_node()
vid_node = VideoNode(**vid_metadata)
vid_node.add_file(YouTubeVideoFile(url=vid_metadata['id'], lang=?))
topic_node.add_child(vid_node)
channel_node.add_child(topic_node) @WenyuZhang1992 ^ note the usage examples above refer to code that doesn't exist yet — this is just my proposal for classes and methods that would handle all the user cases and would be easy to use in chef code. This is a kind of readme-driven-programming ;) |
@kollivier Please check this extra functionality added by Alejandro around the
YouTubeResource
class and see if there aren't any parts we might want to incorporate into pressurecooker:https://github.com/elaeon/sushi-chef-science-ahmed-al-hoot-ar/blob/master/sushichef.py#L162-L279
^ all seems very useful and reusable
The text was updated successfully, but these errors were encountered: