[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[emms-help] emms-info-youtube
From: |
Konstantin Reich |
Subject: |
[emms-help] emms-info-youtube |
Date: |
Thu, 05 Sep 2019 17:19:21 +0300 |
Hi,
I am trying to write an emms info function, which fetches the title from
youtube url.
The synchronous version of such function works good, but freezes Emacs. So i am
trying to figure out how to do it asynchronously.
Somehow, (emms-track-set track 'info-title title) does not work, even although
I provided "track" and "title".
Could you help me to figure out what is wrong. The code is below:
(defun emms-info-youtube (track)
(when (eq 'url (emms-track-type track))
(let ((url (emms-track-name track)))
(when (string-match "youtube" url)
(let* ((id (make-temp-name ""))
(process-name (format "youtube-%s" id))
(buffer-name (format "*youtube-%s*" id))
(buffer (get-buffer-create buffer-name)))
(with-current-buffer buffer
(make-local-variable 'url)
(make-local-variable 'track)
(set-process-sentinel
(start-process process-name buffer "youtube-dl" "-e" url)
'youtube-sentinel)))))))
(defun youtube-sentinel (process event)
(let ((buffer (process-buffer process)))
(with-current-buffer buffer
(when (string-match-p "finished" event)
(goto-char (point-min))
(let ((title (buffer-substring (point-min) (line-end-position))))
;;;; To this point everything works well. The title and track are
determined, but the following line does nothing.
(emms-track-set track 'info-title title))
(kill-buffer buffer))
(when (string-match-p "abnormal" event)
(message "youtube failed: %s" url)))))
- [emms-help] emms-info-youtube,
Konstantin Reich <=
- Re: [emms-help] emms-info-youtube, Mike Kazantsev, 2019/09/05
- Re: [emms-help] emms-info-youtube, Konstantin Reich, 2019/09/05
- Re: [emms-help] emms-info-youtube, Mike Kazantsev, 2019/09/05
- Re: [emms-help] emms-info-youtube, Mike Kazantsev, 2019/09/05
- Re: [emms-help] emms-info-youtube, Konstantin Reich, 2019/09/06
- Re: [emms-help] emms-info-youtube, Mike Kazantsev, 2019/09/06
- Re: [emms-help] emms-info-youtube, Konstantin Reich, 2019/09/06