From 4cd3bfeae40709b952120827372e4731e7351c77 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Tue, 1 Aug 2023 14:44:52 +0300 Subject: fix: Docstrings and Path Update docstrings For (yeetube-load-saved-videos) add if statement to check if yeetube file exists --- README.md | 5 +++++ yeetube.el | 23 +++++++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 14d522d..f53e63d 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,11 @@ git clone https://git.sr.ht/~thanosapollo/yeetube.el (load-file "~/path/to/yeetube.el") ``` +- Make sure you have installed `mpv` and `yt-dlp` as well +*Debian/Ubuntu* +``` shell +sudo apt install yt-dlp mpv +``` ## Contributing diff --git a/yeetube.el b/yeetube.el index f8be81d..a062879 100644 --- a/yeetube.el +++ b/yeetube.el @@ -150,12 +150,14 @@ It's recommended you keep it as the default value." (defun yeetube-load-saved-videos () "Load saved videos." (interactive) - (let ((file-path (concat user-emacs-directory "yeetube-saved"))) - (with-temp-buffer - (insert-file-contents file-path) - (goto-char (point-min)) - (let ((contents (read (current-buffer)))) - (setq yeetube-saved-videos contents))))) + (let ((file-path (concat user-emacs-directory "yeetube"))) + (if (file-exists-p file-path) + (with-temp-buffer + (insert-file-contents file-path) + (goto-char (point-min)) + (let ((contents (read (current-buffer)))) + (setq yeetube-saved-videos contents))) + (write-region "nil" nil file-path)))) (defun yeetube-save-video () "Save url at point." @@ -473,8 +475,13 @@ OPERATION & WHERE are required to work with ='add-variable-watcher." (goto-char (mark)))) (defun yeetube-update-saved-videos-list (_symbol new-value _where _environment) - "Updated saved videos." - (with-temp-buffer (find-file (concat user-emacs-directory "yeetube-saved")) + "Updated saved videos. + +SYMBOL-NAME is the name of the symbol to update. +NEW-VALUE is the new value for the symbol. +OPERATION is the operation to perform (e.g., insert or replace). +WHERE indicates where in the buffer the update should happen." + (with-temp-buffer (find-file (concat user-emacs-directory "yeetube")) (erase-buffer) (setq yeetube-saved-videos new-value) (insert (pp-to-string yeetube-saved-videos)) -- cgit v1.2.3