From 440f5616458bed272e09ce7c040ae21e17cecbcb Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Wed, 7 Feb 2024 08:16:08 +0200 Subject: yeetube-search: Fix indentation & comments --- yeetube.el | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/yeetube.el b/yeetube.el index 402e085..fe65181 100644 --- a/yeetube.el +++ b/yeetube.el @@ -264,10 +264,9 @@ 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-content)) ;; (yeetube-get-thumbnails yeetube-content) ;; download thumbnails - ;; unfortunately can't use images them with tabulated list - ) + ;; 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 a9ccca869b4b122c7b738b5d2b9a24742a5d6574 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Wed, 7 Feb 2024 08:21:41 +0200 Subject: Add yeetube-sort-by Value to sort results for --- yeetube.el | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/yeetube.el b/yeetube.el index fe65181..569948a 100644 --- a/yeetube.el +++ b/yeetube.el @@ -73,6 +73,20 @@ Example Usage: :type 'string :group 'yeetube) +(defcustom yeetube-sort-by "Relevance" + "Sorty search results for value. + +Valid options include: +- \"Relevance\" +- \"Date\" +- \"Views\" +- \"Rating\"" + :type '(radio (const "Relevance") + (const "Date") + (const "Views") + (const "Rating")) + :group 'yeetube) + (defgroup yeetube-faces nil "Faces used by yeetube." :group 'yeetube -- cgit v1.2.3 From 754dc9407ba2d6a62abfd154c5d245105e47b94e Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Wed, 7 Feb 2024 08:43:48 +0200 Subject: Add yeetube-filter-code-alist List of filter codes used by youtube.com --- yeetube.el | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/yeetube.el b/yeetube.el index 569948a..c9e456a 100644 --- a/yeetube.el +++ b/yeetube.el @@ -264,6 +264,11 @@ This is used to download thumbnails from `yeetube-content', within (concat "wget " (shell-quote-argument thumbnail) " -O" (shell-quote-argument title)) nil 0))))) +(defvar yeetube-filter-code-alist + '(("Relevance" . "CAASAhAB") + ("Date" . "CAISAhAB") + ("Views" . "CAMSAhAB") + ("Rating" . "CAESAhAB"))) ;;;###autoload (defun yeetube-search (query) "Search for QUERY." -- cgit v1.2.3 From 0679fa6529bd82ffbb0d2186dea374bafd8df84b Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Wed, 7 Feb 2024 08:44:14 +0200 Subject: Add yeetube-get-filter-code Return for sorty-by value based on yeetube-filter-code-alist --- yeetube.el | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/yeetube.el b/yeetube.el index c9e456a..d4330aa 100644 --- a/yeetube.el +++ b/yeetube.el @@ -269,6 +269,11 @@ This is used to download thumbnails from `yeetube-content', within ("Date" . "CAISAhAB") ("Views" . "CAMSAhAB") ("Rating" . "CAESAhAB"))) + +(defun yeetube-get-filter-code (sort-by) + "Get filter code for sorting search results." + (cdr (assoc sort-by yeetube-filter-code-alist))) + ;;;###autoload (defun yeetube-search (query) "Search for QUERY." -- cgit v1.2.3 From ce74dbd98241863810e9486ca3be6f4cf9fd4f2f Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Wed, 7 Feb 2024 08:44:55 +0200 Subject: yeetube-search: Use yeetube-get-filter-code with yeetube-sort-by This applies a filter based on the value of yeetube-sorty-by. --- yeetube.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/yeetube.el b/yeetube.el index d4330aa..cffed92 100644 --- a/yeetube.el +++ b/yeetube.el @@ -283,7 +283,8 @@ This is used to download thumbnails from `yeetube-content', within (concat "https://youtube.com/search?q=" (replace-regexp-in-string " " "+" query) ;; Filter parameter to remove live videos. - "&sp=EgQQASAB") + "&sp=" + (yeetube-get-filter-code yeetube-sort-by)) 'silent 'inhibit-cookies 30) (decode-coding-region (point-min) (point-max) 'utf-8) (goto-char (point-min)) -- cgit v1.2.3 From 037771c77ea1007b62d773400fef1ef151a76919 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Wed, 7 Feb 2024 08:51:12 +0200 Subject: Rename yeetube-sort-by -> yeetube-filter It's not a sorting value but rather a filter applied with the query. Using sort-by as the name might maybe users think it has to do with the tabulated-list sorting func --- yeetube.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/yeetube.el b/yeetube.el index cffed92..bd54e31 100644 --- a/yeetube.el +++ b/yeetube.el @@ -73,7 +73,7 @@ Example Usage: :type 'string :group 'yeetube) -(defcustom yeetube-sort-by "Relevance" +(defcustom yeetube-filter "Relevance" "Sorty search results for value. Valid options include: @@ -270,9 +270,9 @@ This is used to download thumbnails from `yeetube-content', within ("Views" . "CAMSAhAB") ("Rating" . "CAESAhAB"))) -(defun yeetube-get-filter-code (sort-by) +(defun yeetube-get-filter-code (filter) "Get filter code for sorting search results." - (cdr (assoc sort-by yeetube-filter-code-alist))) + (cdr (assoc filter yeetube-filter-code-alist))) ;;;###autoload (defun yeetube-search (query) @@ -284,7 +284,7 @@ This is used to download thumbnails from `yeetube-content', within (replace-regexp-in-string " " "+" query) ;; Filter parameter to remove live videos. "&sp=" - (yeetube-get-filter-code yeetube-sort-by)) + (yeetube-get-filter-code yeetube-filter)) 'silent 'inhibit-cookies 30) (decode-coding-region (point-min) (point-max) 'utf-8) (goto-char (point-min)) -- cgit v1.2.3 From b57d036e2c60918b01adbf70e4fd691de9b7d3e9 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Wed, 7 Feb 2024 08:58:18 +0200 Subject: Update README Add `Apply Filters` section --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index fb210a8..97b5ad2 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,21 @@ packages like so: 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 +each video. + + ### FAQ #### Feature request: display thumbnails Formatting images in a text buffer is not something that I found easy -- cgit v1.2.3 From a0070ea827031ec5adfdb589c4732d5ea029a3ff Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Wed, 7 Feb 2024 08:59:11 +0200 Subject: Package: Version bump --- yeetube.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yeetube.el b/yeetube.el index bd54e31..144f01d 100644 --- a/yeetube.el +++ b/yeetube.el @@ -5,7 +5,7 @@ ;; Author: Thanos Apollo ;; Keywords: extensions youtube videos ;; URL: https://git.thanosapollo.org/yeetube -;; Version: 2.0.10 +;; Version: 2.1.0 ;; Package-Requires: ((emacs "27.2") (compat "29.1.4.2")) -- cgit v1.2.3