karthink / elfeed-tube

Youtube integration for Elfeed, the feed reader for Emacs
The Unlicense
241 stars 11 forks source link

Is video saved locally #5

Closed emacsbliss closed 7 months ago

emacsbliss commented 2 years ago

Didn't find anywhere in the readme mention this, just wondering is video saved locally? Since playback initially is not smooth, wonder would it be better after sometime if video will be cached locally...

karthink commented 2 years ago

There isn't a download option in elfeed-tube yet, although I'm considering adding one.

It won't help with choppy playback though, unless you're willing to wait until the video is fully downloaded. If mpv playback is not smooth I would consider tweaking the variables cache, cache-secs, cache-pause-wait, cache-pause-initial and demuxer-max-bytes in your mpv.conf instead.

emacsbliss commented 2 years ago

thanks for the explanation, makes sense! I'll give it a try.. It would still be nice to have download option so I can leave it to download first and come back later once it's completed.

PlasmaShift commented 2 years ago

A download option would be nice. Having a download option you would want a configurable location(s) to download and search from. ex "~/youtube/channel/playlist/video.mkv". Something on the UI to indicate if the file is downloaded in the Elfeed post entry and maybe the Elfeed search UI, maybe the size as well. As well as some commands to download and delete, hopefully operating non the search UI and post UI.

karthink commented 2 years ago

A download option would be nice. Having a download option you would want a...

I'm considering a limited version of this, with the following considerations:

Something on the UI to indicate if the file is downloaded in the Elfeed post entry and maybe the Elfeed search UI,

As well as some commands to download and delete, hopefully operating non the search UI and post UI.

I'm not sure if I'll be able to get to it though. (PRs welcome!)

karthink commented 7 months ago

I've been using this command to download videos -- note that despite the name, it doesn't require elfeed-tube or elfeed-tube-mpv, only Emacs 28.1+ and yt-dlp installed on the system.

(defun my/elfeed-tube-download (entries)
    (interactive
     (list
      (cond
       ((eq major-mode 'elfeed-search-mode)
        (when (y-or-n-p "Download entry at point or selected entries?")
          (ensure-list (elfeed-search-selected))))
       ((eq major-mode 'elfeed-show-mode)
        (when (y-or-n-p "Download entry at point or selected entries?")
          (ensure-list elfeed-show-entry)))
       (t (user-error "elfeed-tube-download only works in Elfeed.")))))
    (when entries
      (if-let* (((seq-every-p #'elfeed-tube--youtube-p entries))
                (default-directory "~/Videos/yt/"))
          (seq-doseq (entry entries)
            (let* ((title (elfeed-entry-title entry))
                   (link  (elfeed-entry-link entry))
                   (proc (start-process
                          (format "yt-dlp download: %s" title)
                          (get-buffer-create (format "*elfeed-tube-yt-dlp*: %s" title))
                          "yt-dlp" "-w" "-c" "-o" "%(title)s.%(ext)s" "-f"
                          "bestvideo[height<=?720]+bestaudio/best" "--add-metadata" link)))
              (set-process-sentinel
               proc
               (lambda (process s)
                 (unless (process-live-p process)
                   (if (eq (process-exit-status process) 0)
                       (progn
                         (message "Finished download: %s" title)
                         (kill-buffer (process-buffer process)))
                     (message "Download: [%s] failed (%d) with error: %s"
                              title (process-exit-status process) s)))))
              (message "Started download: %s" title)))
        (message "Not youtube url(s), cancelling download."))))

You might want to change is the default destination (~/Videos/yt/ above).

vikasrawal commented 5 months ago

Would be nice if the function posted by @karthink was modified to 1) not require user interaction after it is called (unnecessary), 2) skip downloading if the video is already there, and 3) Mark the entry as read.