From ff29ac9d862daffc6eb1ac3e7cebc4a9fb541b57 Mon Sep 17 00:00:00 2001 From: Boruch Baum Date: Sun, 4 Feb 2024 17:15:22 -0500 Subject: feat: reduce duration column width --- yeetube.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yeetube.el b/yeetube.el index 35ad3b7..375108b 100644 --- a/yeetube.el +++ b/yeetube.el @@ -485,7 +485,7 @@ FIELDS-FACE-PAIRS is a list of fields and faces." (define-derived-mode yeetube-mode tabulated-list-mode "Yeetube" "Yeetube mode." :keymap yeetube-mode-map - (setf tabulated-list-format [("Title" 60 t) ("Views" 12 t) ("Duration" 12 t) ("Channel" 12 t)] + (setf tabulated-list-format [("Title" 60 t) ("Views" 12 t) ("Duration" 9 t) ("Channel" 12 t)] tabulated-list-entries (cl-map 'list (lambda (content) -- cgit v1.2.3 From 87143791c21235b1bd674ef17f8affd77c3fbaa5 Mon Sep 17 00:00:00 2001 From: Boruch Baum Date: Sun, 4 Feb 2024 18:49:22 -0500 Subject: feat(defcustom): yeetube-default-sort-{column,ascending} --- yeetube.el | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/yeetube.el b/yeetube.el index 375108b..3bc992d 100644 --- a/yeetube.el +++ b/yeetube.el @@ -83,6 +83,18 @@ Valid options include: (const "Date") (const "Views") (const "Rating")) + +(defcustom yeetube-default-sort-column "Title" + "Which column to sort the search results table." + :type '(radio (const "Title") + (const "Views") + (const "Duration") + (const "Channel")) + :group 'yeetube) + +(defcustom yeetube-default-sort-ascending nil + "Whether to sort the search results in ascending order." + :type 'boolean :group 'yeetube) (defgroup yeetube-faces nil @@ -496,7 +508,8 @@ FIELDS-FACE-PAIRS is a list of fields and faces." :duration 'yeetube-face-duration :channel 'yeetube-face-channel))) (reverse yeetube-content)) - tabulated-list-sort-key nil) + 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)) -- cgit v1.2.3 From 0b8718ccef5017c1fbf6051bee2fabd6712afbe0 Mon Sep 17 00:00:00 2001 From: Boruch Baum Date: Sun, 4 Feb 2024 18:59:32 -0500 Subject: fix: sorting of numeric columns "Duration", "Views" --- yeetube.el | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/yeetube.el b/yeetube.el index 3bc992d..e29dc54 100644 --- a/yeetube.el +++ b/yeetube.el @@ -372,6 +372,7 @@ SUBSTRING-END is the end of the string to return, interger." :videoid videoid :view-count (yeetube-view-count-format view-count) :duration video-duration + :published-time published-time :channel channel :thumbnail thumbnail) yeetube-content)))))) @@ -494,10 +495,28 @@ FIELDS-FACE-PAIRS is a list of fields and faces." "C-q" #'yeetube-mpv-change-video-quality "q" #'quit-window) +(defun yeetube--sort-views (a b) + "PREDICATE for function 'sort'. +Used by variable 'tabulated-list-format' to sort the \"Views\" +column." + (< (string-to-number (replace-regexp-in-string "," "" (aref (cadr a) 1))) + (string-to-number (replace-regexp-in-string "," "" (aref (cadr b) 1))))) + +(defun yeetube--sort-duration (a b) + "PREDICATE for function 'sort'. +Used by variable 'tabulated-list-format' to sort the \"Duration\" +column." + (< (string-to-number (replace-regexp-in-string ":" "" (aref (cadr a) 2))) + (string-to-number (replace-regexp-in-string ":" "" (aref (cadr b) 2))))) + (define-derived-mode yeetube-mode tabulated-list-mode "Yeetube" "Yeetube mode." :keymap yeetube-mode-map - (setf tabulated-list-format [("Title" 60 t) ("Views" 12 t) ("Duration" 9 t) ("Channel" 12 t)] + (setf tabulated-list-format + [("Title" 60 t) + ("Views" 12 yeetube--sort-views) + ("Duration" 9 yeetube--sort-duration) + ("Channel" 12 t)] tabulated-list-entries (cl-map 'list (lambda (content) -- cgit v1.2.3 From a69884edea6bec1cd413f08f16b1a7a1b95d739e Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sat, 10 Feb 2024 11:15:41 +0200 Subject: yeetube-default-sort-column: Set default to nil --- yeetube.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yeetube.el b/yeetube.el index e29dc54..d420d28 100644 --- a/yeetube.el +++ b/yeetube.el @@ -82,9 +82,9 @@ Valid options include: :type '(radio (const "Relevance") (const "Date") (const "Views") - (const "Rating")) + (const "Rating"))) -(defcustom yeetube-default-sort-column "Title" +(defcustom yeetube-default-sort-column nil "Which column to sort the search results table." :type '(radio (const "Title") (const "Views") -- cgit v1.2.3 From 4203cea79df87139030bce9dcbb9d607c1796b3f Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sat, 10 Feb 2024 11:15:55 +0200 Subject: Add yeetube-face-date --- yeetube.el | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/yeetube.el b/yeetube.el index d420d28..502d820 100644 --- a/yeetube.el +++ b/yeetube.el @@ -128,6 +128,11 @@ Valid options include: "Face used for video channel name." :group 'yeetube-faces) +(defface yeetube-face-date + '((t :inherit font-lock-doc-face)) + "Face used for published date." + :group 'yeetube-faces) + (defvar yeetube-invidious-instances '("vid.puffyan.us" "invidious.flokinet.to" -- cgit v1.2.3 From 5c711f345c0e1b113537fe15ebc78f7ba8b6749a Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sat, 10 Feb 2024 11:16:07 +0200 Subject: yeetube-search: Search for published date --- yeetube.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/yeetube.el b/yeetube.el index 502d820..67e9e69 100644 --- a/yeetube.el +++ b/yeetube.el @@ -372,14 +372,15 @@ SUBSTRING-END is the end of the string to return, interger." (view-count (yeetube-scrape-item :item "viewcounttext" :item-end " " :substring-end 0)) (video-duration (yeetube-scrape-item :item "lengthtext" :item-end "}," :substring-end 3)) (channel (yeetube-scrape-item :item "longbylinetext" :item-end "," :substring-end 2)) - (thumbnail (yeetube-scrape-item :item "thumbnail" :item-start "url" :item-end ",\"" :substring-end 5))) + (thumbnail (yeetube-scrape-item :item "thumbnail" :item-start "url" :item-end ",\"" :substring-end 5)) + (date (yeetube-scrape-item :item "publishedtimetext" :item-end ",\"" :substring-end 4))) (push (list :title title :videoid videoid :view-count (yeetube-view-count-format view-count) :duration video-duration - :published-time published-time :channel channel - :thumbnail thumbnail) + :thumbnail thumbnail + :date (replace-regexp-in-string "Streamed " "" date)) yeetube-content)))))) (add-variable-watcher 'yeetube-saved-videos #'yeetube-update-saved-videos-list) -- cgit v1.2.3 From 925cdbe626639f54b9aa4c35f749a86160d66726 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sat, 10 Feb 2024 11:29:51 +0200 Subject: Add yeetueb--sort-date This function is from Boruch-Baum fork: --- yeetube.el | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/yeetube.el b/yeetube.el index 67e9e69..02f27d1 100644 --- a/yeetube.el +++ b/yeetube.el @@ -515,6 +515,19 @@ column." (< (string-to-number (replace-regexp-in-string ":" "" (aref (cadr a) 2))) (string-to-number (replace-regexp-in-string ":" "" (aref (cadr b) 2))))) +(defun yeetube--sort-date (a b) + "PREDICATE for function 'sort'. +Used by variable 'tabulated-list-format' to sort the \"Date\" +column." + (let* ((intervals '("second" "minute" "hour" "day" "week" "month" "year")) + (split-a (split-string (replace-regexp-in-string "s" "" (aref (cadr a) 3)))) + (split-b (split-string (replace-regexp-in-string "s" "" (aref (cadr b) 3)))) + (units-a (length (member (nth 1 split-a) intervals))) + (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)))) + (define-derived-mode yeetube-mode tabulated-list-mode "Yeetube" "Yeetube mode." :keymap yeetube-mode-map -- cgit v1.2.3 From d50fa9de5e25d1b3c3be5ec8808f3f937d0f5f29 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sat, 10 Feb 2024 11:30:32 +0200 Subject: yeetube-mode: Add Date --- yeetube.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/yeetube.el b/yeetube.el index 02f27d1..74894cd 100644 --- a/yeetube.el +++ b/yeetube.el @@ -533,9 +533,10 @@ column." :keymap yeetube-mode-map (setf tabulated-list-format [("Title" 60 t) - ("Views" 12 yeetube--sort-views) + ("Views" 11 yeetube--sort-views) ("Duration" 9 yeetube--sort-duration) - ("Channel" 12 t)] + ("Date" 13 yeetube--sort-date) + ("Channel" 8 t)] tabulated-list-entries (cl-map 'list (lambda (content) @@ -544,6 +545,7 @@ column." :title 'yeetube-face-title :view-count 'yeetube-face-view-count :duration 'yeetube-face-duration + :date 'yeetube-face-date :channel 'yeetube-face-channel))) (reverse yeetube-content)) tabulated-list-sort-key (cons yeetube-default-sort-column -- cgit v1.2.3