spiderbit / ytdious

Youtube "front-end" for Emacs
GNU General Public License v3.0
19 stars 2 forks source link

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

Open genomorro opened 2 years ago

genomorro commented 2 years ago

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"))
scholablade commented 1 year ago

Having the same problem, have you found a solution?

scholablade commented 1 year ago

(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.

genomorro commented 1 year ago

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.

sarg commented 9 months ago

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 <sarg@sarg.org.ru>
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