Xah Talk Show 2024-07-07 Ep560, Emacs Lisp Coding, Get Youtube Video Thumbnail
- write emacs lisp command to grab a Youtube video thumbnail
(defun grab-youtube-thumbnail ()
"grab Youtube Thumbnail and save it in current dir.
Created: 2024-07-07
Version: 2024-07-07"
(interactive)
(let (xp1 xp2 xboundary xurl xid xThumbnailUrl xcmd)
(setq xboundary (bounds-of-thing-at-point 'url))
(setq xp1 (car xboundary))
(setq xp2 (cdr xboundary))
(setq xurl (buffer-substring-no-properties xp1 xp2))
(setq xid (xah-html--get-youtube-id xurl))
(setq xThumbnailUrl
(concat "https://img.youtube.com/vi/"
xid
"/maxresdefault.jpg"))
(setq xcmd (format "curl -O %s" xThumbnailUrl))
(shell-command xcmd)
(message "image thumbnail saved in maxresdefault.jpg")
))