Skip to content

Instantly share code, notes, and snippets.

@lelinhtinh
Last active January 12, 2025 16:41
Show Gist options
  • Save lelinhtinh/c192ab956d4c100a85d618a787c30b46 to your computer and use it in GitHub Desktop.
Save lelinhtinh/c192ab956d4c100a85d618a787c30b46 to your computer and use it in GitHub Desktop.
Tải nhạc từ Youtube dùng Youtube-DL

Tải nhạc từ Youtube

Cài đặt

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
sudo apt install ffmpeg

Sử dụng

Dòng lệnh

youtube-dl --extract-audio -o '~/Music/%(title)s.%(ext)s' <Video-URL>

GUI

Video Downloader


Tích hợp vào trình duyệt

Cài đặt tiện ích Open With

Cấu hình Open With

Để sử dụng được Open With, bạn cần cài đặt thêm một helper program:

curl -L https://github.com/darktrojan/openwith/raw/master/webextension/native/open_with_linux.py -o ~/.open_with_linux.py
chmod u+x .open_with_linux.py
./.open_with_linux.py install

Nhấp vào Test Installation để kiểm tra.

Nút Look for browsers sẽ hiển thị danh sách trình duyệt trên máy tính bạn.

Palemoon sử dụng Open With bản cũ (v6.8.6), không cần cài đặt helper program.

Để thêm tính năng tải từ Youtube thông qua Youtube DL, nhấp vào Add browser:

  • Name: Youtube Audio

  • Command:

    x-terminal-emulator -e "youtube-dl --extract-audio -o '~/Music/%(title)s.%(ext)s' %s"
    

    Nếu muốn định dạng mp3:

    x-terminal-emulator -e "youtube-dl --extract-audio --audio-format mp3 -o '~/Music/%(title)s.%(ext)s' %s"
    

    Mp3 chất lượng cao hơn, tốn dung lượng hơn:

    x-terminal-emulator -e "youtube-dl --extract-audio -o '~/Music/%(title)s.%(ext)s' %s --exec 'ffmpeg -i {} -codec:a libmp3lame -qscale:a 0 {}.mp3 && rm {}'"
    

Cấu hình có chút khác trên Palemoon, tách riêng Command (terminal)Arguments (phần từ -e về sau).

Thành quả

Tải nhạc từ Youtube

Youtube DL hoạt động với cả playlist nên hãy cẩn thận khi nhấp tải nhé.

@lelinhtinh
Copy link
Author

youtube-dl --cookies cookies.txt -o "~/Videos/%(title)s.%(ext)s" %s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment