ytdl is an Emacs-based interface for youtube-dl, written in
emacs-lisp.
youtube-dl is a command-line program to download videos from
YouTube.com and a few more sites. More information
here.
Command-line tools can be challenging to use (many arguments, need to use the "--help" command or the man page before actually using the tool, etc.). Those challenges (or leaning curves) can prevent many potential users from using the tool.
The idea of ytdl is to provide an intuitive and flexible Emacs
interface for youtube-dl. ytdl leads to considerable gains in
efficiency and comfort, especially when used with exwm.
Add the following line to your init.el:
(require 'ytdl)Six interactive functions are available:
ytdl-download-eshell,ytdl-downloadandytdl-download-openthat can be used to download a media file from an url.ytdl-download-playlistto download a playlist.ytdl-open-last-downloaded-fileto open the last file downloaded withytdlin the configured media player.ytdl-show-listto show the dowload list.
Note that ytdl-download, ytdl-download-open and
ytdl-download-playlist add the file in the ytdl download list that
can be visualized with ytdl-show-list. ytdl-download-eshell does
not.
ytdl pre-fills the mini-buffer with the URL at point if thing at
point is an URL or the first entry in the kill ring. Users have to
confim by pressing Enter.
When calling ytdl-show-list, ytdl dowload list is shown in a new
buffer. This list contains information about files already downloaded
and files currently being downloaded.
Several actions can be carried out within the download list buffer:
?: Show the help menu with all the commands.g: Refresh the listo: Open the file in media playerO: Open all marked files in media playerk: Remove item(s) at point from the list (the file will not be affected)K: Remove item(s) at point from the list and delete the associated file from the disky: Copy path to file into clipboardm: mMrk item(s) at pointM: Mark all itemsu: Unmark item(s) at pointU: Unmark all items^: Mark items matching a regexp (to be entered in the mini-buffer)e: Show eventual error(s)r: Relaunch item at pointR: Relaunch all items with error(s)d: remove mark item(s)D: Remove mark item(s) and associated filesc: Clear downloaded items from listC: Clear list
Skeeto's interface was a source of inspiration for the development of
the download list of ytdl. His original source code can be found
here.
By default, there are three download types:
-
Downloads
ytdl-download-foldercan be customized to change the destination folder. By default it is set to"~/Downloads". No extra arguments are given by default, seeytdl-download-extra-args. -
Videos
ytdl-video-foldercan be customized to change the destination folder. By default it is set tonil. No extra arguments are given by default, seeytdl-video-extra-args. -
Music
ytdl-music-foldercan be customized to change the destination folder. By default it is set to"nil. By default, the extra arguments used for this download type are:'("-x" "--audio-format" "mp3"), meaning that audio will be extracted from the media file and eventually converted into mp3.
To add a new download type, use
ytdl-add-field-in-download-type-list. This function takes four
arguments:
field-name: the name displayed in the mini-buffer;keyboard-shortcut: keyboard shortcut to select this download type in the mini-buffer;path-to-folder: absolute path to destination folder;extra-args: eventual extra arguments to ytdl for this download type.
To add a new download type called "podcasts", add this to the configuration file:
(ytdl-add-field-in-download-type-list "podcasts"
"p"
(expand-file-name "~/podcasts")
nil)- By default,
ytdldoes not query the default filename fom the web server.
This behavior can be changed by changing ytdl-always-query-default-filename to:
- 'never (default behavior)
- 'yes-confirm: query default filenme from teh web server and ask confirmation
- 'yes: query default filenme from teh web server and use it without confirmation.
(setq ytdl-always-query-default-filename nil)-
Set the media player (used by
ytdl-download-open) by changing the variableytdl-media-player. Default value ismpv. -
Change the beginning of
ytdlmini-buffer messages by changingytdl-message-start. Default value is[ytdl]. -
Hide the
ytdlinformation in the global mode line by settingytdl-mode-linetonil. -
By default,
ytdlqueries the download type usingread-char-choice. If the list of download types is longer than a certain value (ytdl-max-mini-buffer-download-type-entries), then the download type is queried thtoughcompleting-read(enabling users to usehelm). To always usecompleting-read, setytdl-max-mini-buffer-download-type-entriesto 0. -
Change
ytdldownload list buffer name withytdl-dl-buffer-name. Default value is*ytdl-list*. -
Change the item title column width with
ytdl-title-column-width. Default value is 35.
Here is an example of configuration you can add to your init.el:
(require 'ytdl)
(setq ytdl-music-folder (expand-file-name "~/music")
ytdl-video-folder (expand-file-name "~/videos")
ytdl-always-query-default-filename 'never)
(ytdl-add-field-in-download-type-list "podcasts"
"p"
(expand-file-name "~/podcasts")
nil)FEATURE:
- Add ytdl-download-finished-hook defcustom. (by Damien Cassou)
BUG:
- Show
ytdl-listwhen launching a new download. (by Arnaud Hoffmann) - Remove
emulationsfrom keyword list. (by Arnaud Hoffmann)
FEATURE:
- Add
ytdl-commanddefcustom. (by Pierre Neidhardt)
INTERNAL:
- Replace ytdl-message-start by
ytdl--concat. (by Pierre Neidhardt)
STYLE:
- Use
errorinstead of(concat ... "ERROR:" ...). (by Pierre Neidhardt) - Fix syntax and docstring typos. (by Pierre Neidhardt)

