fiftyone.utils.youtube#
Utilities for working with YouTube <https://youtube.com>.
Functions:
| 
 | Downloads a list of YouTube videos. | 
- fiftyone.utils.youtube.download_youtube_videos(urls, download_dir=None, video_paths=None, clip_segments=None, ext='.mp4', only_progressive=True, resolution='highest', max_videos=None, num_workers=None, skip_failures=True, quiet=False)#
- Downloads a list of YouTube videos. - The - urlsargument accepts a list of YouTube “watch” URLs:- urls = [ "https://www.youtube.com/watch?v=-0URMJE8_PB", ..., ] - Use either the - download_diror- video_pathsargument to specify where to download each video.- You can use the optional - clip_segmentsargument to specify a specific segment, in seconds, of each video to download:- clip_segments = [ (10, 25), (11.1, 20.2), None, # entire video (None, 8.0), # through beginning of video (8.0, None), # through end of video ... ] - You can also use the optional - extand- resolutionarguments to specify a desired video codec and resolution to download, if possible.- YouTube videos are regularly taken down. Therefore, this method provides an optional - max_videosargument that you can use in conjunction with- skip_failures=Trueand a large list of possibly non-existent videos in- urlsin cases where you need a certain number of videos to be successfully downloaded but are willing to tolerate failures.- Parameters:
- urls – a list of YouTube URLs to download 
- download_dir (None) – a directory in which to store the downloaded videos 
- video_paths (None) – a list of paths to which to download the videos. When downloading entire videos, a stream matching the video format implied by each file’s extension is downloaded, if available, or else the extension of the video path is changed to match the available stream’s format 
- clip_segments (None) – a list of - (first, last)tuples defining a specific segment of each video to download
- ext (".mp4") – a video format to download for each video, if possible. Only applicable when a - download_diris used. This format will be respected if such a stream exists, otherwise the format of the best available stream is used. Set this value to- Noneif you want to download the stream with the best match for- resolutionand- progressiveregardless of format
- only_progressive (True) – whether to only download progressive streams, if possible. Progressive streams contain both audio and video tracks and are typically only available at <= 720p resolution 
- resolution ("highest") – - a desired stream resolution to download. This filter is applied after respecting the desired video format and - only_progressiverestriction, if applicable. The supported values are:- "highest"(default): download the highest resolution stream
- "lowest": download the lowest resolution stream
- A target resolution like - "1080p". In this case, the stream whose resolution is closest to this target value is downloaded
 
- max_videos (None) – the maximum number of videos to successfully download. By default, all videos are downloaded 
- num_workers (None) – a suggested number of threads/processes to use when downloading videos 
- skip_failures (True) – whether to gracefully continue without raising an error if a video cannot be downloaded 
- quiet (False) – whether to suppress logging, except for a progress bar 
 
- Returns:
- a tuple of - downloaded: a dict mapping integer indexes into - urlsto paths of successfully downloaded videos
- errors: a dict mapping integer indexes into - urlsto error messages for videos that were attempted to be downloaded, but failed