Wish for a emms-add-url to have a "name" parameter

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Wish for a emms-add-url to have a "name" parameter

Stefan Huchler
If I add youtube or invidious urls to the emms-playlist I wish I add a
way to add a label because if I add 10 youtube videos in a playlist it's
hard to navigate through it, without the titles.

I use my own version of a invidious mode to add the video or via
browser hints in the invidious emacs mode I have access to the title
anyway, a trick aronud that would be to create a pls file with only 1
youtube link it and call that file then like the title, but that is a
messy hack.

Not sure that code matters but to give some context maybe it helps:

(defun ytel-emms-append ()
      "Add video at point in emms."
      (interactive)
      (let* ((video (ytel-get-current-video))
             (id    (ytel-video-id-fun video)))
        (emms-add-url (concat "https://www.youtube.com/watch?v=" id))))



Reply | Threaded
Open this post in threaded view
|

Re: Wish for a emms-add-url to have a "name" parameter

Yoni Rabkin-2
Stefan Huchler <[hidden email]> writes:

> If I add youtube or invidious urls to the emms-playlist I wish I add a
> way to add a label because if I add 10 youtube videos in a playlist it's
> hard to navigate through it, without the titles.

You could store the "label" in the track information, either before or
after adding the track to the buffer. For instance, some code to change
the title of a youtube track under point:

(defun emms-ephemeral-title (title)
  (let ((track (emms-playlist-track-at (point))))
    (emms-track-set track 'info-title title)
    (emms-with-inhibit-read-only-t
     (kill-line)
     (emms-playlist-insert-track track))))

Such a change would be indeed ephemeral, since the track doesn't
represent a file, but this information would survive if you then saved
the playlist as a native emms playlist to load it later on.

--
   "Cut your own wood and it will warm you twice"

Reply | Threaded
Open this post in threaded view
|

Re: Wish for a emms-add-url to have a "name" parameter

Stefan Huchler
Yoni Rabkin <[hidden email]> writes:

> You could store the "label" in the track information, either before or
> after adding the track to the buffer. For instance, some code to change
> the title of a youtube track under point:
>
> (defun emms-ephemeral-title (title)
>   (let ((track (emms-playlist-track-at (point))))
>     (emms-track-set track 'info-title title)
>     (emms-with-inhibit-read-only-t
>      (kill-line)
>      (emms-playlist-insert-track track))))
>
> Such a change would be indeed ephemeral, since the track doesn't
> represent a file, but this information would survive if you then saved
> the playlist as a native emms playlist to load it later on.

Just tested that with a interactive function but for some reason I need
2 kill-line or else it adds a empty line after the entry:


(defun emms-ephemeral-title ()
  (interactive)
  (let ((track (emms-playlist-track-at (point))))
    (emms-track-set track 'info-title "TEST")
    (emms-with-inhibit-read-only-t
     (kill-line)
     (kill-line)
     (emms-playlist-insert-track track))))

Now I have to find out how to do that outside of the buffer in a
non-interactive way. I think I need "with-temp-buffer" but that is for
another day but yes it works on prinziple. Any idea why I need 2
kill-line here?


Reply | Threaded
Open this post in threaded view
|

Re: Wish for a emms-add-url to have a "name" parameter

Stefan Huchler
In reply to this post by Yoni Rabkin-2
Yoni Rabkin <[hidden email]> writes:

> Such a change would be indeed ephemeral, since the track doesn't
> represent a file, but this information would survive if you then saved
> the playlist as a native emms playlist to load it later on.

Well the saving is not even that important to me, it's more about managing the
playlist and when I add 10 20 urls that I can find a particular url to
play next, when I did not add them in the same order I want to play
them.

I put together the pieces now and got it working I wonder if there would
be a better solution but for now that works, so thanks for the tipp:

  (defun emms-set-title (title)
    (let ((track (emms-playlist-track-at (point))))
      (emms-track-set track 'info-title title)
      (emms-with-inhibit-read-only-t
       (kill-line 2)
       (emms-playlist-insert-track track))))

  (defun ytel-emms-append ()
    "Add video at point in emms."
    (interactive)
    (let* ((video (ytel-get-current-video))
           (id    (ytel-video-id-fun video))
           (title (assoc-default 'title video)))
      (emms-add-url (format "%s/watch?v=%s" ytel-invidious-api-url id))
      (save-current-buffer
        (set-buffer "Emms Streams")
        (goto-char (buffer-end 1))
        (beginning-of-line)
        (forward-line -1)
        (emms-set-title title))
      (message title)))