karthink / elfeed-tube

Youtube integration for Elfeed, the feed reader for Emacs
The Unlicense
258 stars 13 forks source link

wrong-type-argument number-or-marker-p error with elfeed-protocol #2

Closed ration closed 2 years ago

ration commented 2 years ago

Minimal configuration to produce, obviously requires tinytiny installed and elfeed protocol configured to auth and connect to it. The tinytiny part is simple enough with docker installation. Replace ttrss+https://user@my.tinitinyrss.server with whatever server you wish to use and create the authinfo.

(setq straight-disable-compile t)
(setq straight-build-dir "/tmp/debug-elfeed") ;; Don't pollute our normal builds
(defvar bootstrap-version)
 (let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 5))
   (unless (file-exists-p bootstrap-file)
     (with-current-buffer
         (url-retrieve-synchronously
         "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
          'silent 'inhibit-cookies)
       (goto-char (point-max))
       (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))

(straight-use-package 'use-package)
(straight-use-package 'el-patch)
(setq straight-use-package-by-default t)

(use-package elfeed
  :config
    (setq shr-width 80)) ;; Read view narrowing

(use-package elfeed-protocol
  :straight (elfeed-protocol
             :local-repo "~/git/own/github/elfeed-protocol"
             :type git)
  :config
  (setq elfeed-use-curl t)
  (setq elfeed-protocol-ttrss-maxsize 2000) ;; bigger than 200 is invalid (unless you hack tt ;)
  (setq elfeed-feeds
      '(
        ("ttrss+https://user@my.tinitinyrss.server"
         :use-authinfo t
        )))
  (elfeed-protocol-enable))

(use-package elfeed-tube
  :straight (:host github :repo "karthink/elfeed-tube" :build (:not compile))
  :config
  (elfeed-tube-setup)
  :bind (:map elfeed-show-mode-map
         ("F" . elfeed-tube-fetch)
         ([remap save-buffer] . elfeed-tube-save)
         :map elfeed-search-mode-map
         ("F" . elfeed-tube-fetch)
         ([remap save-buffer] . elfeed-tube-save)))

(use-package elfeed-tube-mpv
  :straight (:host github :repo "karthink/elfeed-tube")
  :bind (:map elfeed-show-mode-map
              ("C-c C-f" . elfeed-tube-mpv-follow-mode)
              ("C-c C-w" . elfeed-tube-mpv-where)))

Produces error:

Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
  signal(wrong-type-argument (number-or-marker-p nil))
  (closure ((cps-state-atom-826 closure #2 nil (setq cps-current-value-763 ...)) (cps-state-if-825 closure #2 nil (setq cps-current-state-764 ...)) (cps-state-atom-824 closure #2 nil (setq cps-current-value-763 ...)) (cps-state-atom-823 closure #2 nil (setq cps-current-value-763 ...)) (cps-state-let*-822 closure #2 nil (progn ... ...)) (cps-state-atom-821 closure #2 nil (setq cps-current-value-763 ...)) (cps-state-let*-820 closure #2 nil (progn ... ...)) (cps-state-atom-819 closure #2 nil (setq cps-current-value-763 ...)) (cps-state-let*-818 closure #2 nil (progn ... ...)) (cps-state-atom-817 closure #2 nil (setq cps-current-value-763 ...)) (cps-state-let*-816 closure #2 nil (progn ... ...)) (cps-state-atom-815 closure #2 nil (setq cps-current-value-763 ...)) (cps-state-let*-814 closure #2 nil (progn ... ...)) (cps-state-atom-813 closure #2 nil (setq cps-current-value-763 ...)) (cps-state-let*-812 closure #2 nil (progn ... ...)) (cps-state-atom-811 closure #2 nil (setq cps-current-value-763 ...)) (cps-state-if-810 closure #2 nil (setq cps-current-state-764 ...)) (cps-state-atom-809 closure #2 nil (setq cps-current-value-763 ...)) (cps-state-atom-808 closure #2 nil (setq cps-current-value-763 ...)) (cps-state-and-807 closure #2 nil (setq cps-current-state-764 ...)) (cps-state-atom-806 closure #2 nil (setq cps-current-value-763 ...)) (cps-state-iter-yield-805 closure #2 nil (progn ... ...)) (cps-state-let*-804 closure #2 nil (progn ... ...)) (cps-state-atom-803 closure #2 nil (setq cps-current-value-763 ...)) (cps-binding-cps-argument-801-802) (cps-state-let*-800 closure #2 nil (progn ... ...)) ...) nil (signal (car cps-binding-condition-case-error-770) (cdr cps-binding-condition-case-error-770)))()
  funcall((closure ((cps-state-atom-826 closure #3 nil (setq cps-current-value-763 ...)) (cps-state-if-825 closure #3 nil (setq cps-current-state-764 ...)) (cps-state-atom-824 closure #3 nil (setq cps-current-value-763 ...)) (cps-state-atom-823 closure #3 nil (setq cps-current-value-763 ...)) (cps-state-let*-822 closure #3 nil (progn ... ...)) (cps-state-atom-821 closure #3 nil (setq cps-current-value-763 ...)) (cps-state-let*-820 closure #3 nil (progn ... ...)) (cps-state-atom-819 closure #3 nil (setq cps-current-value-763 ...)) (cps-state-let*-818 closure #3 nil (progn ... ...)) (cps-state-atom-817 closure #3 nil (setq cps-current-value-763 ...)) (cps-state-let*-816 closure #3 nil (progn ... ...)) (cps-state-atom-815 closure #3 nil (setq cps-current-value-763 ...)) (cps-state-let*-814 closure #3 nil (progn ... ...)) (cps-state-atom-813 closure #3 nil (setq cps-current-value-763 ...)) (cps-state-let*-812 closure #3 nil (progn ... ...)) (cps-state-atom-811 closure #3 nil (setq cps-current-value-763 ...)) (cps-state-if-810 closure #3 nil (setq cps-current-state-764 ...)) (cps-state-atom-809 closure #3 nil (setq cps-current-value-763 ...)) (cps-state-atom-808 closure #3 nil (setq cps-current-value-763 ...)) (cps-state-and-807 closure #3 nil (setq cps-current-state-764 ...)) (cps-state-atom-806 closure #3 nil (setq cps-current-value-763 ...)) (cps-state-iter-yield-805 closure #3 nil (progn ... ...)) (cps-state-let*-804 closure #3 nil (progn ... ...)) (cps-state-atom-803 closure #3 nil (setq cps-current-value-763 ...)) (cps-binding-cps-argument-801-802) (cps-state-let*-800 closure #3 nil (progn ... ...)) (cps-state-atom-799 closure #3 nil (setq cps-current-value-763 ...)) (cps-binding-api-data-798) (cps-state-atom-797 closure #3 nil (setq cps-current-value-763 ...)) (cps-state-if-796 closure #3 nil (setq cps-current-state-764 ...)) (cps-state-atom-795 closure #3 nil (setq cps-current-value-763 ...)) (cps-state-atom-794 closure #3 nil (setq cps-current-value-763 ...)) ...) nil (signal (car cps-binding-condition-case-error-770) (cdr cps-binding-condition-case-error-770))))
  (if (funcall fetched-p) (progn (elfeed-tube-show (or entry elfeed-show-entry))))
  (closure ((entry . #s(elfeed-entry :id ("www.youtube.com" . "{\"ver\":2,\"uid\":1,\"hash\":\"SHA1:ceeb4216a3ba603ff48d...") :title "Beaver State Fling | Final Round, Back 9 | Gurthie..." :link "https://www.youtube.com/watch?v=lo7Qo5mLzcc" :date 1655152928 :content #s(elfeed-ref :id "da39a3ee5e6b4b0d3255bfef95601890afd80709") :content-type html :enclosures nil :tags (Discgolf) :feed-id "ttrss+https://user@my.tinitinyrss.server::https://www.you..." :meta (:author "Disc Golf Pro Tour" :protocol-id "ttrss+https://user@my.tinitinyrss.server" :id 1098203 :guid-hash "{\"ver\":2,\"uid\":1,\"hash\":\"SHA1:ceeb4216a3ba603ff48d..." :feed-id 638))) cl-struct-elfeed-tube-item-tags t) (fetched-p) (if (funcall fetched-p) (progn (elfeed-tube-show (or entry elfeed-show-entry)))))((closure ((cps-state-atom-826 closure #3 nil ...) (cps-state-if-825 closure #3 nil ...) (cps-state-atom-824 closure #3 nil ...) (cps-state-atom-823 closure #3 nil ...) (cps-state-let*-822 closure #3 nil ...) (cps-state-atom-821 closure #3 nil ...) (cps-state-let*-820 closure #3 nil ...) (cps-state-atom-819 closure #3 nil ...) (cps-state-let*-818 closure #3 nil ...) (cps-state-atom-817 closure #3 nil ...) (cps-state-let*-816 closure #3 nil ...) (cps-state-atom-815 closure #3 nil ...) (cps-state-let*-814 closure #3 nil ...) (cps-state-atom-813 closure #3 nil ...) (cps-state-let*-812 closure #3 nil ...) (cps-state-atom-811 closure #3 nil ...) (cps-state-if-810 closure #3 nil ...) (cps-state-atom-809 closure #3 nil ...) (cps-state-atom-808 closure #3 nil ...) (cps-state-and-807 closure #3 nil ...) (cps-state-atom-806 closure #3 nil ...) (cps-state-iter-yield-805 closure #3 nil ...) (cps-state-let*-804 closure #3 nil ...) (cps-state-atom-803 closure #3 nil ...) (cps-binding-cps-argument-801-802) (cps-state-let*-800 closure #3 nil ...) ...) nil (signal (car cps-binding-condition-case-error-770) (cdr cps-binding-condition-case-error-770))))
  apply((closure ((entry . ...) cl-struct-elfeed-tube-item-tags t) (fetched-p) (if (funcall fetched-p) (progn ...))) (closure ((cps-state-atom-826 closure #4 nil ...) (cps-state-if-825 closure #4 nil ...) (cps-state-atom-824 closure #4 nil ...) (cps-state-atom-823 closure #4 nil ...) (cps-state-let*-822 closure #4 nil ...) (cps-state-atom-821 closure #4 nil ...) (cps-state-let*-820 closure #4 nil ...) (cps-state-atom-819 closure #4 nil ...) (cps-state-let*-818 closure #4 nil ...) (cps-state-atom-817 closure #4 nil ...) (cps-state-let*-816 closure #4 nil ...) (cps-state-atom-815 closure #4 nil ...) (cps-state-let*-814 closure #4 nil ...) (cps-state-atom-813 closure #4 nil ...) (cps-state-let*-812 closure #4 nil ...) (cps-state-atom-811 closure #4 nil ...) (cps-state-if-810 closure #4 nil ...) (cps-state-atom-809 closure #4 nil ...) (cps-state-atom-808 closure #4 nil ...) (cps-state-and-807 closure #4 nil ...) (cps-state-atom-806 closure #4 nil ...) (cps-state-iter-yield-805 closure #4 nil ...) (cps-state-let*-804 closure #4 nil ...) (cps-state-atom-803 closure #4 nil ...) (cps-binding-cps-argument-801-802) (cps-state-let*-800 closure #4 nil ...) ...) nil (signal (car cps-binding-condition-case-error-770) (cdr cps-binding-condition-case-error-770))))
  timer-event-handler([t 25255 45306 296085 nil (closure ((entry . #s(elfeed-entry :id ("www.youtube.com" . "{\"ver\":2,\"uid\":1,\"hash\":\"SHA1:ceeb4216a3ba60...") :title "Beaver State Fling | Final Round, Back 9 | G..." :link "https://www.youtube.com/watch?v=lo7Qo5mLzcc" :date 1655152928 :content #s(elfeed-ref :id "da39a3ee5e6b4b0d3255bfef95601890afd80709") :content-type html :enclosures nil :tags (Discgolf) :feed-id "ttrss+https://user@my.tinitinyrss.server::https://w..." :meta (:author "Disc Golf Pro Tour" :protocol-id "ttrss+https://user@my.tinitinyrss.server" :id 1098203 :guid-hash "{\"ver\":2,\"uid\":1,\"hash\":\"SHA1:ceeb4216a3ba60..." :feed-id 638))) cl-struct-elfeed-tube-item-tags t) (fetched-p) (if (funcall fetched-p) (progn (elfeed-tube-show (or entry elfeed-show-entry))))) ((closure ((cps-state-atom-826 closure #5 nil (setq cps-current-value-763 ...)) (cps-state-if-825 closure #5 nil (setq cps-current-state-764 ...)) (cps-state-atom-824 closure #5 nil (setq cps-current-value-763 ...)) (cps-state-atom-823 closure #5 nil (setq cps-current-value-763 ...)) (cps-state-let*-822 closure #5 nil (progn ... ...)) (cps-state-atom-821 closure #5 nil (setq cps-current-value-763 ...)) (cps-state-let*-820 closure #5 nil (progn ... ...)) (cps-state-atom-819 closure #5 nil (setq cps-current-value-763 ...)) (cps-state-let*-818 closure #5 nil (progn ... ...)) (cps-state-atom-817 closure #5 nil (setq cps-current-value-763 ...)) (cps-state-let*-816 closure #5 nil (progn ... ...)) (cps-state-atom-815 closure #5 nil (setq cps-current-value-763 ...)) (cps-state-let*-814 closure #5 nil (progn ... ...)) (cps-state-atom-813 closure #5 nil (setq cps-current-value-763 ...)) (cps-state-let*-812 closure #5 nil (progn ... ...)) (cps-state-atom-811 closure #5 nil (setq cps-current-value-763 ...)) (cps-state-if-810 closure #5 nil (setq cps-current-state-764 ...)) (cps-state-atom-809 closure #5 nil (setq cps-current-value-763 ...)) (cps-state-atom-808 closure #5 nil (setq cps-current-value-763 ...)) (cps-state-and-807 closure #5 nil (setq cps-current-state-764 ...)) (cps-state-atom-806 closure #5 nil (setq cps-current-value-763 ...)) (cps-state-iter-yield-805 closure #5 nil (progn ... ...)) (cps-state-let*-804 closure #5 nil (progn ... ...)) (cps-state-atom-803 closure #5 nil (setq cps-current-value-763 ...)) (cps-binding-cps-argument-801-802) (cps-state-let*-800 closure #5 nil (progn ... ...)) (cps-state-atom-799 closure #5 nil (setq cps-current-value-763 ...)) (cps-binding-api-data-798) (cps-state-atom-797 closure #5 nil (setq cps-current-value-763 ...)) (cps-state-if-796 closure #5 nil (setq cps-current-state-764 ...)) (cps-state-atom-795 closure #5 nil (setq cps-current-value-763 ...)) (cps-state-atom-794 closure #5 nil (setq cps-current-value-763 ...)) (cps-state-and-793 closure #5 nil (setq cps-current-state-764 ...)) (cps-state-atom-792 closure #5 nil (setq cps-current-value-763 ...)) (cps-state-iter-yield-791 closure #5 nil (progn ... ...)) (cps-state-let*-790 closure #5 nil (progn ... ...)) (cps-state-atom-789 closure #5 nil (setq cps-current-value-763 ...)) (cps-binding-cps-argument-787-788 closure (... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...) nil (signal ... ...)) (cps-state-let*-786 closure #5 nil (progn ... ...)) (cps-state-atom-785 closure #5 nil (setq cps-current-value-763 ...)) (cps-binding-caps-new-784) (cps-state-atom-783 closure #5 nil (setq cps-current-value-763 ...)) (cps-binding-error-782) (cps-binding-caps-781) ...) nil (signal (car cps-binding-condition-case-error-770) (cdr cps-binding-condition-case-error-770)))) nil 491000 nil])

Tested with GNU Emacs 28.1.50 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.16.0) of 2022-05-12.

karthink commented 2 years ago

Thanks @ration. I don't have a ttrss instance deployed yet. Before I do that, I'd like to check if the problem is more local to elfeed-tube, as opposed to with the elfeed-protocol integration.

Can you open up a youtube entry in Elfeed and call C-u M-x elfeed-tube-fetch? (Or C-u F according to your keybindings above.) I'd like to know if the same error occurs with manual fetches of information.

If this also fails, it will fail without a traceback. We can then generate a traceback by calling it synchronously. Open a scratch buffer and run:

(let ((entry (buffer-local-value 'elfeed-show-entry
                                 (get-buffer "*elfeed-entry*"))))
  (aio-wait-for (elfeed-tube--fetch-1 entry))
  (if-let ((item (elfeed-tube--gethash entry)))
      (prin1 
       (elfeed-tube-item-error item)
       (current-buffer))))
ration commented 2 years ago

It fails with a similar stack.

Looking at the code I think my entry-structs are built different:

#s(elfeed-entry ("www.youtube.com" . "{\"ver\":2,\"uid\":1,\"hash\":\"SHA1:4a06b89a09a2632d4a2bd2612920577525068a05\"}") "What if Rome Never Conquered Britain?" "https://www.youtube.com/watch?v=wVP80TMuZ5s" 1655203134 #s(elfeed-ref "da39a3ee5e6b4b0d3255bfef95601890afd80709") html nil (Youtube) "ttrss+https://my.tintytiny.server::https://www.youtube.com/feeds/videos.xml?channel_id=UClfEht64_NrzHf8Y0slKEjw" (:author "AlternateHistoryHub" :protocol-id "ttrss+https://admin@my.tinytiny.server" :id 1098208 :guid-hash "{\"ver\":2,\"uid\":1,\"hash\":\"SHA1:4a06b89a09a2632d4a2bd2612920577525068a05\"}" :feed-id 674))

And it causes elfeed-tube--get-video-id to fail.

karthink commented 2 years ago

Thanks, that's very helpful! Can you run the following code in a scratch buffer with a (tt-rss derived) youtube entry open in Elfeed and add the results here?

(let ((entry (buffer-local-value 'elfeed-show-entry
                                 (get-buffer "*elfeed-entry*"))))
  (cl-loop for prop in
           '(title id feed-id link tags date content meta)
           collect
           (cons prop (funcall (intern-soft
                                (concat "elfeed-entry-"
                                        (symbol-name prop)))
                               entry))))

Entries created by tt-rss clearly use a different entry structure from regular Elfeed. I can account for it in my code once I can see what it looks like.

karthink commented 2 years ago

I tried making elfeed-tube--get-video-id more generic in 869f65b. Please check if this works for tt-rss derived entries for you.

ration commented 2 years ago
((title . "Nightflyer & DX17 - Signal Dust (Synthwave / Retrowave)") (id "www.youtube.com" . "{\"ver\":2,\"uid\":1,\"hash\":\"SHA1:7944ea6f56cd8e8a8d8aa145f4582d599dbc1f1a\"}") (feed-id . "ttrss+https://user@tinytiny.server::https://www.youtube.com/feeds/videos.xml?channel_id=UC6ghlxmJNMd8BE_u1HR-bTg") (link . "https://www.youtube.com/watch?v=Zn9m2mW--TE") (tags Youtube) (date . 1655146800) (content . #s(elfeed-ref "da39a3ee5e6b4b0d3255bfef95601890afd80709")) (meta :author "The '80s Guy" :protocol-id "ttrss+https://user@tinytiny.server" :id 1098193 :guid-hash "{\"ver\":2,\"uid\":1,\"hash\":\"SHA1:7944ea6f56cd8e8a8d8aa145f4582d599dbc1f1a\"}" :feed-id 634))
karthink commented 2 years ago

Looks good. This structure should work with 869f65b.

ration commented 2 years ago

Yeah thanks! Now it doesn't throw an error, but it still looks limited - I only see the transcript and no thumbnail or metadata.

karthink commented 2 years ago

Yeah thanks! Now it doesn't throw an error, but it still looks limited - I only see the transcript and no thumbnail or metadata.

I'm looking into it, but in the meantime, did you try C-u M-x elfeed-tube-fetch? This clears the cache (including logged errors that might be keeping it from trying to fetch again) and forces a refetch of all metadata.

ration commented 2 years ago

I'm looking into it, but in the meantime, did you try C-u M-x elfeed-tube-fetch? This clears the cache (including logged errors that might be keeping it from trying to fetch again) and forces a refetch of all metadata.

Yes this did it! Awesome!

karthink commented 2 years ago

Okay. To be clear M-x elfeed-tube-fetch is not a command the user is expected to remember or invoke when auto-fetching is turned on, which is the default. It should just work. (The hope is that elfeed-tube will work pretty much invisibly with Elfeed with the default settings.)

karthink commented 2 years ago

I'm assuming it's been working fine since - feel free to reopen this issue if ssomething fails again.