ytdious icon indicating copy to clipboard operation
ytdious copied to clipboard

ytdious--format-video-length: Wrong type argument: number-or-marker-p, nil

Open genomorro opened this issue 3 years ago • 4 comments

Hi.

I just installed this extension, thanks for your work. Some times I search something and I can read this in Message buffer:

ytdious--format-video-length: Wrong type argument: number-or-marker-p, nil

When that happen ytdious buffer is empty. If I insist and press < or > results are shown.

My config:

(use-package ytdious
  :ensure t
  :config (setq ytdious-invidious-api-url "https://invidious.snopyta.org"))

genomorro avatar May 26 '22 07:05 genomorro

Having the same problem, have you found a solution?

scholablade avatar Mar 06 '23 10:03 scholablade

(defun ytdious--create-entry (video) "Create tabulated-list VIDEO entry." (list (assoc-default 'videoId video) (vector (ytdious--format-video-published (assoc-default 'published video)) (ytdious--format-author (assoc-default 'author video)) (ytdious--format-video-length (assoc-default 'lengthSeconds video)) (assoc-default 'title video) (ytdious--format-video-views (assoc-default 'viewCount video))))) This piece of code appears to be what's causing the issue.

scholablade avatar Mar 06 '23 11:03 scholablade

Hi, my elisp knowledge is not enough but seems that (assoc-default 'lengthSeconds video) is not always a number. It is unclear to me why is happening, but this package seems is not active anymore.

genomorro avatar May 11 '23 04:05 genomorro

That is because the search API returns non-videos as well (e.g. playlists). Don't want to make a fork just for this, so here is the patch:

From e6a654cbab4d7ed81cdabd43d08f35f07f9bb1b1 Mon Sep 17 00:00:00 2001
From: Sergey Trofimov <[email protected]>
Date: Tue, 19 Dec 2023 08:27:04 +0100
Subject: [PATCH] Filter out non-videos when searching.

---
 ytdious.el | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/ytdious.el b/ytdious.el
index 8cfa7e7..faa7822 100644
--- a/ytdious.el
+++ b/ytdious.el
@@ -77,7 +77,7 @@
 (defvar ytdious-invidious-api-url "https://invidio.us"
   "Url to an Invidious instance.")
 
-(defvar ytdious-invidious-default-query-fields "author,lengthSeconds,title,videoId,authorId,viewCount,published"
+(defvar ytdious-invidious-default-query-fields "type,author,lengthSeconds,title,videoId,authorId,viewCount,published"
   "Default fields of interest for video search.")
 
 (defvar-local ytdious-videos '()
@@ -337,9 +337,11 @@ Optional argument _NOCONFIRM revert expects this param."
 				  ("Views" 10 nil . (:right-align t))])
     (unless (boundp 'ytdious-skip-request)
       (setf ytdious-videos
-	    (funcall
-	     (if ytdious-channel 'ytdious--query-channel 'ytdious--query)
-	     title)))
+	    (cl-remove-if-not
+	     (lambda (video) (equal "video" (assoc-default 'type video)))
+	     (funcall
+	      (if ytdious-channel 'ytdious--query-channel 'ytdious--query)
+	      title))))
     (let* ((title-string
 	    (propertize
 	     (apply 'format "[%s: %s]"
-- 
2.41.0

sarg avatar Dec 19 '23 07:12 sarg