In genere, scarichiamo video da YouTube utilizzando il browser web. Ma ora puoi anche scaricare video da YouTube utilizzando la riga di comando.
youtube-dl è un'utilità della riga di comando sviluppata dal team di youtube-dl.org. È basato sul linguaggio di programmazione Python, a cui è richiesto anche questo script.
Questo tutorial ti aiuterà a installare youtube-dl sul tuo sistema Linux. Fornisce inoltre numerosi esempi utili per scaricare audio e video direttamente da Youtube.
Installazione di Youtube-DL
Usa il comando seguente per installare un downloader della riga di comando di YouTube secondo il tuo sistema operativo Linux.
Il modo consigliato
Per installarlo subito per tutti gli utenti UNIX (Linux, macOS, ecc.), digitare:
sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl
Se non hai curl, puoi in alternativa usare un wget recente:
sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl
Da repository
- Installazione su Ubuntu, Debian e LinuxMint
sudo apt-get install youtube-dl - CentOS/RHEL 7/6 e SL
sudo yum install youtube-dl - CentOS/RHEL 8 e Fedora
sudo dnf install youtube-dl
Scarica audio e video con Youtube-dl
Ora usa il seguente insieme di comandi di esempio per scaricare video di Youtube con diverse opzioni e formati 2 secondo le tue esigenze.
youtube-dl https://www.youtube.com/watch?v=McuF7g14hYw [youtube] McuF7g14hYw: Downloading webpage [youtube] McuF7g14hYw: Downloading video info webpage [youtube] McuF7g14hYw: Extracting video information [youtube] McuF7g14hYw: Downloading DASH manifest [youtube] McuF7g14hYw: Downloading DASH manifest [download] Destination: How to Download Java Archive using Command Line -McuF7g14hYw.mp4 [download] 100% of 3.79MiB in 00:09
youtube-dl https://www.youtube.com/watch?v=McuF7g14hYw -o Video.mp4 [youtube] McuF7g14hYw: Downloading webpage [youtube] McuF7g14hYw: Downloading video info webpage [youtube] McuF7g14hYw: Extracting video information [youtube] McuF7g14hYw: Downloading DASH manifest [youtube] McuF7g14hYw: Downloading DASH manifest [download] Destination: Video.mp4 [download] 100% of 3.79MiB in 00:07
youtube-dl --extract-audio --audio-format mp3 https://youtu.be/McuF7g14hYw -o audio.mp3 [youtube] McuF7g14hYw: Downloading webpage [youtube] McuF7g14hYw: Downloading video info webpage [youtube] McuF7g14hYw: Extracting video information [youtube] McuF7g14hYw: Downloading DASH manifest [youtube] McuF7g14hYw: Downloading DASH manifest [download] Destination: /home/sysadmin/Desktop/audio.mp3 [download] 100% of 4.16MiB in 00:11 [ffmpeg] Correcting container in "audio.mp3" [ffmpeg] Post-process file audio.mp3 exists, skipping