From ae90598b6a18fec2956369754a914c643ced467d Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Fri, 9 Feb 2024 06:41:59 +0200 Subject: yeetube-filter-code-alist: Update relevance code Update to only include videos & not livestreams etc --- yeetube.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yeetube.el b/yeetube.el index 0ec9d97..5ef4071 100644 --- a/yeetube.el +++ b/yeetube.el @@ -264,7 +264,7 @@ This is used to download thumbnails from `yeetube-content', within nil 0))))) (defvar yeetube-filter-code-alist - '(("Relevance" . "CAASAhAB") + '(("Relevance" . "EgIQAQ%253D%253D") ("Date" . "CAISAhAB") ("Views" . "CAMSAhAB") ("Rating" . "CAESAhAB"))) -- cgit v1.2.3 From 803afc297a2783eb5a18c8f2b3850a682561a71a Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Fri, 9 Feb 2024 06:42:51 +0200 Subject: yeetube-search: Set language to en-US This should allow to scrape & sort results for date :) --- yeetube.el | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/yeetube.el b/yeetube.el index 5ef4071..e4e9225 100644 --- a/yeetube.el +++ b/yeetube.el @@ -5,7 +5,8 @@ ;; Author: Thanos Apollo ;; Keywords: extensions youtube videos ;; URL: https://git.thanosapollo.org/yeetube -;; Version: 2.1.1 +;; Version: 2.1.2-dev + ;; Package-Requires: ((emacs "27.2") (compat "29.1.4.2")) @@ -277,20 +278,22 @@ This is used to download thumbnails from `yeetube-content', within (defun yeetube-search (query) "Search for QUERY." (interactive "sYeetube Search: ") - (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) - (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 - ;; unfortunately we can't use images them with tabulated list + (let ((url-request-extra-headers + '(("Accept-Language" . "Accept-Language: en-US,en;q=0.9")))) + (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) + (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 + ;; unfortunately we can't use images them with tabulated list (with-current-buffer (switch-to-buffer (get-buffer-create (concat "*yeetube*"))) (yeetube-mode))) -- cgit v1.2.3 From 9d1430c90b21b4ada69af9ec29d199546205c148 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Fri, 9 Feb 2024 08:44:35 +0200 Subject: Add yeetube-request-headers Rewrite yeetube-search to use yeetube-request-headers as well. --- yeetube.el | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/yeetube.el b/yeetube.el index e4e9225..5c28324 100644 --- a/yeetube.el +++ b/yeetube.el @@ -268,7 +268,14 @@ This is used to download thumbnails from `yeetube-content', within '(("Relevance" . "EgIQAQ%253D%253D") ("Date" . "CAISAhAB") ("Views" . "CAMSAhAB") - ("Rating" . "CAESAhAB"))) + ("Rating" . "CAESAhAB")) + "Filter codes.") + +(defvar yeetube-request-headers + '(("Accept-Language" . "Accept-Language: en-US,en;q=0.9") + ("Accept" . "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8") + ("User-Agent" . "Mozilla/5.0 (Windows NT 10.0; rv:122.0) Gecko/20100101 Firefox/122.0")) + "HTTP Request extra headers") (defun yeetube-get-filter-code (filter) "Get filter code for sorting search results." @@ -278,8 +285,7 @@ This is used to download thumbnails from `yeetube-content', within (defun yeetube-search (query) "Search for QUERY." (interactive "sYeetube Search: ") - (let ((url-request-extra-headers - '(("Accept-Language" . "Accept-Language: en-US,en;q=0.9")))) + (let ((url-request-extra-headers yeetube-request-headers)) (with-current-buffer (url-retrieve-synchronously (concat "https://youtube.com/search?q=" -- cgit v1.2.3 From 9f3d9962279df31659e3d0d6b0bfe232e2edac9a Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Fri, 9 Feb 2024 09:10:24 +0200 Subject: Add yeetube-mpv-video-quality --- yeetube-mpv.el | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/yeetube-mpv.el b/yeetube-mpv.el index 474b88f..cd436e6 100644 --- a/yeetube-mpv.el +++ b/yeetube-mpv.el @@ -40,6 +40,11 @@ (defvar yeetube-mpv-torsocks (executable-find "torsocks") "Path to torsocks executable.") +(defvar yeetube-mpv-video-quality "720" + "Video resolution/quality + +Accepted values include: 1080, 720, 480, 360, 240, 144") + (defun yeetube-mpv-toggle-torsocks () "Toggle torsocks." (interactive) -- cgit v1.2.3 From 5db25e807fb6fc67d40bdb3126487d442523e989 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Fri, 9 Feb 2024 09:10:45 +0200 Subject: Add yeetube-mpv-ytdl-format-video-quality --- yeetube-mpv.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/yeetube-mpv.el b/yeetube-mpv.el index cd436e6..5b43ae1 100644 --- a/yeetube-mpv.el +++ b/yeetube-mpv.el @@ -72,6 +72,10 @@ Accepted values include: 1080, 720, 480, 360, 240, 144") (start-process-shell-command "yeetube" nil command)))) +(defun yeetube-mpv-ytdl-format-video-quality (resolution) + "Return shell quoted argument for ytdlp with RESOLUTION." + (shell-quote-argument (format "bestvideo[height<=?%s]+bestaudio/best" resolution))) + (defun yeetube-mpv-play (input) "Start yeetube process to play INPUT using mpv. @@ -80,7 +84,9 @@ to play local files." (yeetube-mpv-process (concat (when yeetube-mpv-enable-torsocks (concat yeetube-mpv-torsocks " ")) - yeetube-mpv-path " " + yeetube-mpv-path " --ytdl-format=" + (yeetube-mpv-ytdl-format-video-quality yeetube-mpv-video-quality) + " " (shell-quote-argument input) (when yeetube-mpv-disable-video " --no-video"))) (message (if yeetube-mpv-enable-torsocks -- cgit v1.2.3 From fbe5bd642c6a8d1cae3b7b37bfb96420a18fe5ff Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Fri, 9 Feb 2024 11:28:16 +0200 Subject: Add yeetube-mpv-change-video-quality --- yeetube-mpv.el | 6 ++++++ yeetube.el | 1 + 2 files changed, 7 insertions(+) diff --git a/yeetube-mpv.el b/yeetube-mpv.el index 5b43ae1..2c925a4 100644 --- a/yeetube-mpv.el +++ b/yeetube-mpv.el @@ -45,6 +45,12 @@ Accepted values include: 1080, 720, 480, 360, 240, 144") +(defun yeetube-mpv-change-video-quality () + (interactive) + (let ((new-value (completing-read (format "Set video quality (current value %s):" yeetube-mpv-video-quality) + '("1080" "720" "480" "360" "240" "144") nil t))) + (setf yeetube-mpv-video-quality new-value))) + (defun yeetube-mpv-toggle-torsocks () "Toggle torsocks." (interactive) diff --git a/yeetube.el b/yeetube.el index 5c28324..6a2e9db 100644 --- a/yeetube.el +++ b/yeetube.el @@ -481,6 +481,7 @@ FIELDS-FACE-PAIRS is a list of fields and faces." "r" #'yeetube-replay "t" #'yeetube-view-thumbnail "T" #'yeetube-mpv-toggle-torsocks + "C-q" #'yeetube-mpv-change-video-quality "q" #'quit-window) (define-derived-mode yeetube-mode tabulated-list-mode "Yeetube" -- cgit v1.2.3 From e857377830071c0d86e55f923c711a8554a4e9b1 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Fri, 9 Feb 2024 11:42:50 +0200 Subject: Update README --- README.md | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e92df6e..a2efdbc 100644 --- a/README.md +++ b/README.md @@ -84,11 +84,25 @@ For example: This will filter & sort the search results according to the number of views. +### Torsocks -### FAQ -#### Feature request: display thumbnails -Formatting images in a text buffer is not something that I found easy -or fun to do. Feel free to submit a patch if you manage to make an -appealing version of it +If you are using `yeetube-mpv-play` as your media player & running +[tor](https://wiki.archlinux.org/title/Tor), you can use torsocks to +route your traffic via the tor network. +``` emacs-lisp +(setf yeetube-mpv-enable-torsocks t) +``` + +*You can toggle that option with `yeetube-mpv-toggle-torsocks`* + +### Video Quality + +If you are using `yeetube-mpv-play` as your media player, you can +specify video quality using `yeetube-mpv-change-video-quality` +*recommended* or by using this snippet. + +``` emacs-lisp +(setf yeetube-mpv-video-quality "720") ;; Accepted values include: 1080, 720, 480, 360, 240, 144 +``` -- cgit v1.2.3 From e86aa36f36ee009d39bdb6827c7931f1bad191ba Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Fri, 9 Feb 2024 18:15:25 +0200 Subject: README: Redo as plain text --- README | 8 +++++ README.md | 108 -------------------------------------------------------------- 2 files changed, 8 insertions(+), 108 deletions(-) create mode 100644 README delete mode 100644 README.md diff --git a/README b/README new file mode 100644 index 0000000..2222516 --- /dev/null +++ b/README @@ -0,0 +1,8 @@ + +YeeTube +======== +YouTube Front End for GNU Emacs + + +Project's Page: +Upstream: diff --git a/README.md b/README.md deleted file mode 100644 index a2efdbc..0000000 --- a/README.md +++ /dev/null @@ -1,108 +0,0 @@ -[![MELPA](https://melpa.org/packages/yeetube-badge.svg)](https://melpa.org/#/yeetube) - -# YeeTube - -![yeetube showcase](/showcase/example.gif?raw=true "Showcase Yeetube") -## About - -This package provides the ability to scrape YouTube, with the results -displayed in a proced-like buffer. - - -Package functionality includes: - -- Query YouTube -- Play video url *by default using mpv* -- Bookmark/Save video url -- Download video *using yt-dlp* -- A minimal yt-dlp front-end, *which is independent of the rest - YouTube functionality*. - -*This package does not use Invidious or YouTube's API, just "parses" -html & json.* - - -## Installation -This package is available via [MELPA](https://melpa.org/#/yeetube) - -### Straight.el - -``` emacs-lisp -(straight-use-package - '(yeetube :type git - :host nil - :repo "https://git.thanosapollo.org/yeetube")) -``` - - -### Manual -``` shell -$ git clone https://git.thanosapollo.org/yeetube -``` - -*Add this to your emacs configuration:* - -``` emacs-lisp - (add-to-list 'load-path "/path/to/yeetube") - (load-file "~/path/to/yeetube.el") - (require 'yeetube) -``` - -### Dependencies -- [mpv](https://mpv.io/): default multimedia player -- [yt-dlp](https://github.com/yt-dlp/yt-dlp): download functionality - -*Debian/Ubuntu* -``` shell -$ sudo apt install mpv yt-dlp -``` - -## Configuration -### Media Player -By default `yeetube-player` is set to `yeetube-mpv-play`, you can -use [mpv.el](https://github.com/kljohann/mpv.el), -[GNU/Emms](https://www.gnu.org/software/emms/) or other similar -packages like so: - -``` emacs-lisp -(setf yeetube-player #'emms-play-url) -``` - -Make sure that the media player of your choice can directly play -youtube urls. - -### Apply Filters - -To filter the search results based on a specific criterion, you can -modify the `yeetube-filter` value to your preferred option. - -For example: - -```emacs-lisp -(setf yeetube-filter "Views") -``` - -This will filter & sort the search results according to the number of views. - -### Torsocks - -If you are using `yeetube-mpv-play` as your media player & running -[tor](https://wiki.archlinux.org/title/Tor), you can use torsocks to -route your traffic via the tor network. - -``` emacs-lisp -(setf yeetube-mpv-enable-torsocks t) -``` - -*You can toggle that option with `yeetube-mpv-toggle-torsocks`* - -### Video Quality - -If you are using `yeetube-mpv-play` as your media player, you can -specify video quality using `yeetube-mpv-change-video-quality` -*recommended* or by using this snippet. - -``` emacs-lisp -(setf yeetube-mpv-video-quality "720") ;; Accepted values include: 1080, 720, 480, 360, 240, 144 -``` - -- cgit v1.2.3 From 099c3c672d48158c7cd860338e86521f8529a344 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Fri, 9 Feb 2024 18:25:05 +0200 Subject: Add CONTRIBUTING.org --- CONTRIBUTING.org | 29 +++++++++++++++++++++++++++++ yeetube.el | 2 -- 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 CONTRIBUTING.org diff --git a/CONTRIBUTING.org b/CONTRIBUTING.org new file mode 100644 index 0000000..c5d7ae3 --- /dev/null +++ b/CONTRIBUTING.org @@ -0,0 +1,29 @@ +#+title: Contributing | YeeTube +#+author: Thanos Apollo + + +* Sources ++ [[https://git.thanosapollo.org/yeetube][Upstream]] + +* How To Contribute + +Before starting to work on any big feature, that is not mentioned on +the [[Task List][Task List]], I recommend you to send me an email first. + +** How to submit a PR? ++ Feel free to send me a patch, here's how to create one + +#+begin_src bash +$ git clone https://git.thanosapollo.com/.git && cd +$ emacs something +$ git add something +$ git commit -m "Fix something" +$ git format-patch HEAD^1 +0001-Fix-something.patch +#+end_src + +/You can find my email on the git log/ + + +* Tasks +** TODO Add sorting for tabulated list views/date/title/duration diff --git a/yeetube.el b/yeetube.el index 6a2e9db..34582c9 100644 --- a/yeetube.el +++ b/yeetube.el @@ -7,8 +7,6 @@ ;; URL: https://git.thanosapollo.org/yeetube ;; Version: 2.1.2-dev - - ;; Package-Requires: ((emacs "27.2") (compat "29.1.4.2")) ;; This program is free software; you can redistribute it and/or modify -- cgit v1.2.3 From 1d86459ac1fa7900cda699db539cbf537d718166 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sat, 10 Feb 2024 08:21:40 +0200 Subject: [package] Update URL Change URL to point to my projects' home page --- yeetube.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yeetube.el b/yeetube.el index 34582c9..35ad3b7 100644 --- a/yeetube.el +++ b/yeetube.el @@ -4,7 +4,7 @@ ;; Author: Thanos Apollo ;; Keywords: extensions youtube videos -;; URL: https://git.thanosapollo.org/yeetube +;; URL: https://thanosapollo.org/projects/yeetube/ ;; Version: 2.1.2-dev ;; Package-Requires: ((emacs "27.2") (compat "29.1.4.2")) -- cgit v1.2.3 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 From 6203d10e395d2a12829ab8db57bb4c723a6d6e53 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sat, 10 Feb 2024 11:42:28 +0200 Subject: contributing: Mark task done & add credits --- CONTRIBUTING.org | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.org b/CONTRIBUTING.org index c5d7ae3..6454f5d 100644 --- a/CONTRIBUTING.org +++ b/CONTRIBUTING.org @@ -26,4 +26,6 @@ $ git format-patch HEAD^1 * Tasks -** TODO Add sorting for tabulated list views/date/title/duration +** DONE Add sorting for tabulated list views/date/title/duration +CLOSED: [2024-02-10 Sat 11:38] ++ With the help of Boruch Baum -- cgit v1.2.3 From 3172527a6a8f1297587cf1c90eaaf594b1009f68 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sat, 10 Feb 2024 12:07:53 +0200 Subject: Version bump 2.1.2 --- yeetube.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yeetube.el b/yeetube.el index 74894cd..ff6c16d 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-dev +;; Version: 2.1.2 ;; Package-Requires: ((emacs "27.2") (compat "29.1.4.2")) -- cgit v1.2.3