diff options
author | Thanos Apollo <[email protected]> | 2024-02-07 08:59:29 +0200 |
---|---|---|
committer | Thanos Apollo <[email protected]> | 2024-02-07 08:59:29 +0200 |
commit | be3d736621b4c25665d29fb28a863d0f2179fc5a (patch) | |
tree | e3b04f466a9a7282a3046f545f7af1e7ccdbbd44 | |
parent | 16307d5ccb0bb0ebda2f7b3cb8c5142e3058218e (diff) | |
parent | a0070ea827031ec5adfdb589c4732d5ea029a3ff (diff) |
Release version 2.1.0: Merge branch 'v2.1.0-dev'
- Fix filtering
- Add filtering options
This was inspired by Boruch Baum fork:
https://github.com/Boruch-Baum/emacs-yeetube.el
But instead of sorting using a tabulated-list-sort-key, we apply a
filter for query. This should negate issues issues for sorting by date
based on users region/language, as well as add future possible options
with more filter options
-rw-r--r-- | README.md | 15 | ||||
-rw-r--r-- | yeetube.el | 34 |
2 files changed, 44 insertions, 5 deletions
@@ -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 @@ -5,7 +5,7 @@ ;; Author: Thanos Apollo <[email protected]> ;; 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")) @@ -73,6 +73,20 @@ Example Usage: :type 'string :group 'yeetube) +(defcustom yeetube-filter "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 @@ -250,6 +264,16 @@ 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"))) + +(defun yeetube-get-filter-code (filter) + "Get filter code for sorting search results." + (cdr (assoc filter yeetube-filter-code-alist))) + ;;;###autoload (defun yeetube-search (query) "Search for QUERY." @@ -259,15 +283,15 @@ 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-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-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))) |