From 17b4bb9ea2263b9676e5cfa045a4e6ce319cbfd3 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sun, 11 Feb 2024 09:15:02 +0200 Subject: Update CONTRIBUTING tasks --- CONTRIBUTING.org | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CONTRIBUTING.org b/CONTRIBUTING.org index 6454f5d..109d52d 100644 --- a/CONTRIBUTING.org +++ b/CONTRIBUTING.org @@ -29,3 +29,9 @@ $ git format-patch HEAD^1 ** DONE Add sorting for tabulated list views/date/title/duration CLOSED: [2024-02-10 Sat 11:38] + With the help of Boruch Baum + +** Improve interactivity ++ Sort columns interactively + +** Improve torsocks support ++ Use =socks= to route all traffic from =url= to tor, this should be an opt-in feature -- cgit v1.2.3 From 1e9bea8f79e9ab93f07766e876cdb4a7f7ea5a8d Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Mon, 19 Feb 2024 15:24:46 +0200 Subject: package: Update header --- yeetube.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yeetube.el b/yeetube.el index ff6c16d..118abdb 100644 --- a/yeetube.el +++ b/yeetube.el @@ -1,4 +1,4 @@ -;;; yeetube.el --- YouTube Front End -*- lexical-binding: t; -*- +;;; yeetube.el --- YouTube Front End | Interface for yt-dlp | mpv control | -*- lexical-binding: t; -*- ;; Copyright (C) 2023 Thanos Apollo -- cgit v1.2.3 From 2ccf1b68376840d640f6620e102ab09632d3e7bb Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Mon, 19 Feb 2024 15:25:07 +0200 Subject: yeetube: Enable socks support - Add yeetube-with-tor-socks - Add yeetube-enable-tor option --- yeetube.el | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/yeetube.el b/yeetube.el index 118abdb..2deb503 100644 --- a/yeetube.el +++ b/yeetube.el @@ -41,6 +41,7 @@ (require 'url) (require 'tabulated-list) (require 'cl-lib) +(require 'socks) (require 'yeetube-mpv) (defgroup yeetube nil @@ -97,6 +98,11 @@ Valid options include: :type 'boolean :group 'yeetube) +(defcustom yeetube-enable-tor nil + "Enable routing through tor" + :type 'boolean + :group 'yeetube) + (defgroup yeetube-faces nil "Faces used by yeetube." :group 'yeetube @@ -296,19 +302,26 @@ This is used to download thumbnails from `yeetube-content', within "Get filter code for sorting search results." (cdr (assoc filter yeetube-filter-code-alist))) +(defmacro yeetube-with-tor-socks (&rest body) + `(let ((url-gateway-method 'socks) + (socks-noproxy '("localhost")) + (socks-server '("Default server" "127.0.0.1" 9050 5))) + ,@body)) + ;;;###autoload (defun yeetube-search (query) "Search for QUERY." (interactive "sYeetube Search: ") - (let ((url-request-extra-headers yeetube-request-headers)) + (let* ((url-request-extra-headers yeetube-request-headers) + (search-url (concat "https://youtube.com/search?q=" + (replace-regexp-in-string " " "+" query) + ;; Filter parameter to remove live videos. + "&sp=" + (yeetube-get-filter-code yeetube-filter)))) (with-current-buffer - (url-retrieve-synchronously - (concat "https://youtube.com/search?q=" - (replace-regexp-in-string " " "+" query) - ;; Filter parameter to remove live videos. - "&sp=" - (yeetube-get-filter-code yeetube-filter)) - 'silent 'inhibit-cookies 30) + (if yeetube-enable-tor + (yeetube-with-tor-socks (url-retrieve-synchronously search-url 'silent 'inhibit-cookies 30)) + (url-retrieve-synchronously search-url 'silent 'inhibit-cookies 30)) (decode-coding-region (point-min) (point-max) 'utf-8) (goto-char (point-min)) (toggle-enable-multibyte-characters) @@ -421,7 +434,8 @@ Optional values: (unless yeetube-ytdlp (error "Executable for yt-dlp not found. Please install yt-dlp")) (call-process-shell-command - (concat "yt-dlp " (shell-quote-argument url) + (concat (when yeetube-enable-tor "torsocks ") + "yt-dlp " (shell-quote-argument url) (when name " -o "(shell-quote-argument name)) (when audio-format -- cgit v1.2.3 From 4adc4ce7f93298d4a2c7d9eef41ec5518087e271 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sun, 25 Feb 2024 04:26:53 +0200 Subject: Add yeetube-thumbnail-height --- yeetube.el | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/yeetube.el b/yeetube.el index 2deb503..5353c70 100644 --- a/yeetube.el +++ b/yeetube.el @@ -109,6 +109,11 @@ Valid options include: :tag "Yeetube Faces" :prefix 'yeetube-face) +(defcustom yeetube-thumbnail-height 80 + "Height of the thumbnail." + :type 'number + :group 'yeetube) + (defface yeetube-face-header-query '((t :inherit font-lock-function-name-face)) "Face used for the video published date." -- cgit v1.2.3 From 21bd4bafa218e4f74c07fac52da7b943ee6920b3 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sun, 25 Feb 2024 04:27:05 +0200 Subject: Add yeetube-thumbnail-width --- yeetube.el | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/yeetube.el b/yeetube.el index 5353c70..53701e5 100644 --- a/yeetube.el +++ b/yeetube.el @@ -114,6 +114,11 @@ Valid options include: :type 'number :group 'yeetube) +(defcustom yeetube-thumbnail-width 80 + "Width of the thumbnail." + :type 'number + :group 'yeetube) + (defface yeetube-face-header-query '((t :inherit font-lock-function-name-face)) "Face used for the video published date." -- cgit v1.2.3 From 6c17c33b76c2db5d14bee5a03c5bf47ce4cf8250 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sun, 25 Feb 2024 04:27:16 +0200 Subject: Add yeetube-display-thumbnails --- yeetube.el | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/yeetube.el b/yeetube.el index 53701e5..434be23 100644 --- a/yeetube.el +++ b/yeetube.el @@ -119,6 +119,11 @@ Valid options include: :type 'number :group 'yeetube) +(defcustom yeetube-display-thumbnails t + "asdf" + :type 'boolean + :group 'yeetube) + (defface yeetube-face-header-query '((t :inherit font-lock-function-name-face)) "Face used for the video published date." -- cgit v1.2.3 From 6b2ad1fffe759494075793ccb53c17ca2dc2cb33 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sun, 25 Feb 2024 04:31:56 +0200 Subject: Refactor yeetube-get-thumbnails --- yeetube.el | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/yeetube.el b/yeetube.el index 434be23..b17acee 100644 --- a/yeetube.el +++ b/yeetube.el @@ -294,10 +294,16 @@ This is used to download thumbnails from `yeetube-content', within (unless wget-exec (error "Please install `wget', to download thumbnails")) (cl-loop for item in content - do (let ((title (plist-get item :title)) - (thumbnail (plist-get item :thumbnail))) + do (let ((thumbnail (plist-get item :thumbnail))) (call-process-shell-command - (concat "wget " (shell-quote-argument thumbnail) " -O" (shell-quote-argument title)) + (format "%s %s %s %s" wget-exec + (shell-quote-argument thumbnail) + "-O" + (concat (replace-regexp-in-string + "\\(.*\\)\\(\\(.\\{10\\}\\)\\)$" + "\\2" + thumbnail) + ".jpg")) nil 0))))) (defvar yeetube-filter-code-alist -- cgit v1.2.3 From f1d8cb5e5590497d5dc8fc80414fbc5a19a41b86 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sun, 25 Feb 2024 04:32:22 +0200 Subject: yeetube-search: download thumbnails & use pop-to-buffer --- yeetube.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yeetube.el b/yeetube.el index b17acee..2e33e63 100644 --- a/yeetube.el +++ b/yeetube.el @@ -346,11 +346,11 @@ This is used to download thumbnails from `yeetube-content', within (decode-coding-region (point-min) (point-max) 'utf-8) (goto-char (point-min)) (toggle-enable-multibyte-characters) - (yeetube-get-content))) - ;; (yeetube-get-thumbnails yeetube-content) ;; download thumbnails + (yeetube-get-content)) + (yeetube-get-thumbnails yeetube-content)) ;; download thumbnails ;; unfortunately we can't use images them with tabulated list (with-current-buffer - (switch-to-buffer (get-buffer-create (concat "*yeetube*"))) + (pop-to-buffer-same-window "*yeetube*") (yeetube-mode))) ;;;###autoload -- cgit v1.2.3 From 9d91bc23ce9599ca89921c0f2b11be039da49887 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sun, 25 Feb 2024 04:32:47 +0200 Subject: yeetube-content: Specify image path --- yeetube.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/yeetube.el b/yeetube.el index 2e33e63..2ea8262 100644 --- a/yeetube.el +++ b/yeetube.el @@ -414,7 +414,13 @@ SUBSTRING-END is the end of the string to return, interger." :duration video-duration :channel channel :thumbnail thumbnail - :date (replace-regexp-in-string "Streamed " "" date)) + :date (replace-regexp-in-string "Streamed " "" date) + :image (format "[[%s.jpg]]" (expand-file-name + (replace-regexp-in-string + "\\(.*\\)\\(\\(.\\{10\\}\\)\\)$" + "\\2" + thumbnail) + temporary-file-directory))) yeetube-content)))))) (add-variable-watcher 'yeetube-saved-videos #'yeetube-update-saved-videos-list) -- cgit v1.2.3 From d563a5645febaa122a749ebbf48c3a8e25ab7121 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sun, 25 Feb 2024 04:33:07 +0200 Subject: Add yeetube-iimage-mode-buffer --- yeetube.el | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/yeetube.el b/yeetube.el index 2ea8262..fa111a4 100644 --- a/yeetube.el +++ b/yeetube.el @@ -567,7 +567,35 @@ column." (units-b (length (member (nth 1 split-b) intervals)))) (if (= units-a units-b) (< (string-to-number (nth 0 split-a)) (string-to-number (nth 0 split-b))) - (> units-a units-b)))) + (> units-a units-b)))) + +(defun yeetube-iimage-mode-buffer (arg) + "Display images if ARG is non-nil, undisplay them otherwise. + +Modified version of `iimage-mode-buffer' to specify height & width and +image-path." + (let ((image-path (list (expand-file-name temporary-file-directory))) + file) + (with-silent-modifications + (save-excursion + (cl-loop for pair in iimage-mode-image-regex-alist do + (goto-char (point-min)) + (while (re-search-forward (car pair) nil t) + (when (and (setq file (match-string (cdr pair))) + (setq file (locate-file file image-path))) + (if arg + (add-text-properties + (match-beginning 0) (match-end 0) + `(display + ,(create-image file nil nil + :max-width yeetube-thumbnail-width + :max-height yeetube-thumbnail-height) + keymap ,image-map + modification-hooks + (iimage-modification-hook))) + (remove-list-of-text-properties + (match-beginning 0) (match-end 0) + '(display modification-hooks)))))))))) (define-derived-mode yeetube-mode tabulated-list-mode "Yeetube" "Yeetube mode." -- cgit v1.2.3 From 913a4a8f178596995f17d48b1b43594ec0968079 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sun, 25 Feb 2024 04:33:24 +0200 Subject: [Feature] yeetube-mode: Display thumbnails --- yeetube.el | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/yeetube.el b/yeetube.el index fa111a4..45d4035 100644 --- a/yeetube.el +++ b/yeetube.el @@ -605,7 +605,8 @@ image-path." ("Views" 11 yeetube--sort-views) ("Duration" 9 yeetube--sort-duration) ("Date" 13 yeetube--sort-date) - ("Channel" 8 t)] + ("Channel" 10 t) + ("Thumbnail" 0 t)] tabulated-list-entries (cl-map 'list (lambda (content) @@ -615,13 +616,15 @@ image-path." :view-count 'yeetube-face-view-count :duration 'yeetube-face-duration :date 'yeetube-face-date - :channel 'yeetube-face-channel))) + :channel 'yeetube-face-channel + :image 'yeetube-face-thumbnail))) (reverse yeetube-content)) tabulated-list-sort-key (cons yeetube-default-sort-column yeetube-default-sort-ascending)) (display-line-numbers-mode 0) (tabulated-list-init-header) - (tabulated-list-print)) + (tabulated-list-print) + (yeetube-iimage-mode-buffer yeetube-display-thumbnails)) (provide 'yeetube) ;;; yeetube.el ends here -- cgit v1.2.3 From 7ffab51fe194aa5962884cf2d935454736bd4cda Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sun, 25 Feb 2024 04:49:01 +0200 Subject: Version bump: 2.1.3 --- yeetube.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/yeetube.el b/yeetube.el index 45d4035..9d8112b 100644 --- a/yeetube.el +++ b/yeetube.el @@ -5,7 +5,7 @@ ;; Author: Thanos Apollo ;; Keywords: extensions youtube videos ;; URL: https://thanosapollo.org/projects/yeetube/ -;; Version: 2.1.2 +;; Version: 2.1.3 ;; Package-Requires: ((emacs "27.2") (compat "29.1.4.2")) @@ -42,6 +42,8 @@ (require 'tabulated-list) (require 'cl-lib) (require 'socks) +(require 'iimage) + (require 'yeetube-mpv) (defgroup yeetube nil -- cgit v1.2.3 From ba3f0987d4af95c53925a4746a6379df66ec3e54 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sun, 25 Feb 2024 04:58:16 +0200 Subject: yeetube-get-content: If not yeetube-display-thumbnails return "nil" --- yeetube.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/yeetube.el b/yeetube.el index 9d8112b..baa3572 100644 --- a/yeetube.el +++ b/yeetube.el @@ -417,12 +417,14 @@ SUBSTRING-END is the end of the string to return, interger." :channel channel :thumbnail thumbnail :date (replace-regexp-in-string "Streamed " "" date) - :image (format "[[%s.jpg]]" (expand-file-name + :image (if yeetube-display-thumbnails + (format "[[%s.jpg]]" (expand-file-name (replace-regexp-in-string "\\(.*\\)\\(\\(.\\{10\\}\\)\\)$" "\\2" thumbnail) - temporary-file-directory))) + temporary-file-directory)) + "nil")) yeetube-content)))))) (add-variable-watcher 'yeetube-saved-videos #'yeetube-update-saved-videos-list) -- cgit v1.2.3 From 3d75f432e184494f29efaca3e09e5ee4ad4c6152 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sun, 25 Feb 2024 11:54:04 +0200 Subject: yeetube-mode: update style & docstring --- yeetube.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yeetube.el b/yeetube.el index baa3572..2391f28 100644 --- a/yeetube.el +++ b/yeetube.el @@ -576,7 +576,7 @@ column." (defun yeetube-iimage-mode-buffer (arg) "Display images if ARG is non-nil, undisplay them otherwise. -Modified version of `iimage-mode-buffer' to specify height & width and +Modified version of `iimage-mode-buffer' to specify height, width and image-path." (let ((image-path (list (expand-file-name temporary-file-directory))) file) @@ -609,7 +609,7 @@ image-path." ("Views" 11 yeetube--sort-views) ("Duration" 9 yeetube--sort-duration) ("Date" 13 yeetube--sort-date) - ("Channel" 10 t) + ("Channel" 12 t) ("Thumbnail" 0 t)] tabulated-list-entries (cl-map 'list @@ -621,7 +621,7 @@ image-path." :duration 'yeetube-face-duration :date 'yeetube-face-date :channel 'yeetube-face-channel - :image 'yeetube-face-thumbnail))) + :image nil))) (reverse yeetube-content)) tabulated-list-sort-key (cons yeetube-default-sort-column yeetube-default-sort-ascending)) -- cgit v1.2.3 From 30fec227afc484a92444441b70668c3a2fbbec6c Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sun, 25 Feb 2024 11:54:22 +0200 Subject: yeetube-get-thumbnails: Download only when yeetube-display-thumbnail --- yeetube.el | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/yeetube.el b/yeetube.el index 2391f28..bdd772b 100644 --- a/yeetube.el +++ b/yeetube.el @@ -291,22 +291,23 @@ WHERE indicates where in the buffer the update should happen." This is used to download thumbnails from `yeetube-content', within `yeetube-search'. We can't as of now use images with tabulated-list." (interactive) - (let ((wget-exec (executable-find "wget")) - (default-directory temporary-file-directory)) - (unless wget-exec - (error "Please install `wget', to download thumbnails")) - (cl-loop for item in content - do (let ((thumbnail (plist-get item :thumbnail))) - (call-process-shell-command - (format "%s %s %s %s" wget-exec - (shell-quote-argument thumbnail) - "-O" - (concat (replace-regexp-in-string - "\\(.*\\)\\(\\(.\\{10\\}\\)\\)$" - "\\2" - thumbnail) - ".jpg")) - nil 0))))) + (when yeetube-display-thumbnails + (let ((wget-exec (executable-find "wget")) + (default-directory temporary-file-directory)) + (unless wget-exec + (error "Please install `wget', to download thumbnails")) + (cl-loop for item in content + do (let ((thumbnail (plist-get item :thumbnail))) + (call-process-shell-command + (format "%s %s %s %s" wget-exec + (shell-quote-argument thumbnail) + "-O" + (concat (replace-regexp-in-string + "\\(.*\\)\\(\\(.\\{10\\}\\)\\)$" + "\\2" + thumbnail) + ".jpg")) + nil 0)))))) (defvar yeetube-filter-code-alist '(("Relevance" . "EgIQAQ%253D%253D") -- cgit v1.2.3