 (use-package maxframe :ensure t)
 (add-hook 'window-setup-hook 'maximize-frame t)
 
+(defun ar/youtube-async-download (url)
+  (message "Downloading: %s" url)
+  (async-start
+   `(lambda ()
+      (process-lines "youtube-dl" "--no-progress" "-o" "~/Downloads/%(title)s.%(ext)s" ,url))
+
+   `(lambda (lines)
+      ;; TODO: Add some error handling.
+      (message "Downloaded: %s" ,url)
+      (string-match "/.*mp4" (nth 3 lines))
+      (let ((file-path (match-string-no-properties 0 (nth 3 lines))))
+        (shell-command (format "open -a VLC \"%s\"" file-path) ))
+      (message "Opening: %s" ,url))))
+
 (use-package elfeed :ensure t
   :config
+  (defun ar/elfeed-yt-download ()
+    (interactive)
+    (let ((link (elfeed-entry-link elfeed-show-entry)))
+      (when link
+        (ar/youtube-async-download link))))
   (validate-setq elfeed-feeds
                  '(("https://matt.hackinghistory.ca/feed/" blog emacs MattPrice)
+                   ("https://ytrss.co/feed/UCxkMDXQ5qzYOgXPRnOBrp1w")
                    ("http://www.brool.com/index.xml" blog emacs Brool)
                    ("https://elephly.net/feed.xml" blog emacs Elephly)
                    ("https://hasanyavuz.ozderya.net/?feed=rss2" blog emacs HasanYavuz)

(require 'use-package)

(use-package validate :ensure t)

(use-package async :ensure t :demand
  :config

                    (action . (lambda (url)
                                (browse-url url)))))))

(defun ar/youtube-download ()
  "Download youtube video from url in clipboard."
  (interactive)
  (ar/youtube-async-download (current-kill 0)))

(defun ar/view-clipboard-buffer ()
  "View clipboard buffer."
