An implementation of youtube-dl for the Godot engine that works on Linux, OSX and Windows
Features
- Automatic youtube-dl and ffmpeg setup.
- Downloading single videos from YouTube.
- Converting videos to audio.
- Downloading playlists of videos from YouTube. (yet to be implemented)
- Searching YouTube videos. (yet to be implemented)
Installation
- Clone the repository and place the youtube-dl folder in your project folder.
How to use
Setup:
Create a new YouTube-DL object like this:
var youtube_dl = YouTubeDl.new()
Usually you will want to connect it's signals immediately like this:
youtube_dl.connect("ready", self, "ready_to_dl")
youtube_dl.connect("download_complete", self, "yt_download_complete")
- The
ready
signal is emitted when the YouTubeDL object has finished the initial setup and is ready to download YouTube videos. - The
download_complete
signal is emitted when the YouTubeDL object has finished downloading a video/audio.
Usage:
To download a YouTube video use the download
function:
youtube_dl.download(url, destination_path, filename, convert_to_audio, video_format, audio_format)
string
url: The YouTube video urlstring
destination_path: The folder where you want the video to be downloadedstring
filename: Specify the filename without extension, can be leaved blankbool
convert_to_audio: If true the video will be converted to the specified audio formatint
video_format: Used to specify the video format to download, use built-in constants likeYouTubeDl.VIDEO_WEBM
.int
audio_format: Used to specify the audio format for conversion, use built-in constants likeYouTubeDl.AUDIO_VORBIS
.
Examples:
Downloading a video:
youtube_dl.download("https://youtu.be/ogMNV33AhCY", "/home/noe/downloads/", "videoclip", false, YouTubeDl.VIDEO_WEBM)
Downloading a video as audio:
youtube_dl.download("https://youtu.be/ogMNV33AhCY", "/home/noe/downloads/", "audioclip", true, YouTubeDl.VIDEO_WEBM, YouTubeDl.AUDIO_VORBIS)
Supported formats audio/video formats:
Video:
- webm -
VIDEO_WEBM
(only for non 60fps videos) - mp4 -
VIDEO_MP4
Audio:
- mp3 -
AUDIO_MP3
- flac -
AUDIO_FLAC
- aac -
AUDIO_AAC
- vorbis (ogg) -
AUDIO_VORBIS
- opus (ogg) -
AUDIO_OPUS
- m4a -
AUDIO_M4A
- wav -
AUDIO_WAV
Future:
This project needs improvements and you are more than welcome to contribute to it by submitting Issues and Pull Requets.