Wojnstup / PipeCatTurbo

PipeCat - but better. And written in bash!
GNU General Public License v3.0
23 stars 1 forks source link

Ability to display current song in notification demon #2

Open krillin666 opened 3 years ago

krillin666 commented 3 years ago

Thank you for the last update !

Is there a way one could get a notification, through notify-send or dunst of the current playing song when a song changes in a playlist ? I see that you can display it in the Controls menu, so maybe it's not that easy to implement. I tried using this MPV script https://github.com/emilazy/mpv-notify-send, however it displays the file aka the YouTube link and not the song text.

Thank you once again :smile:

Wojnstup commented 3 years ago

Well, I'll think about that. I'm busy today, so this (for sure this time) won't be ready by today. It may be more difficult than displaying the song in the controls menu, since the script isn't multithreaded, you run it two times to get the video and controls at the same time. While the script handles the title in controls menu, it can't be done that way for displaying titles while the playlist is playing. The playlist is handled entirely by mpv and I can't inject bash script between the songs/videos. I might find a way to do it, I just need more time. If you know lua well, you can modify that lua script you found. It doesn't work in this case because it either:

  1. Fetches the title to early, if you do it to early you'll get the url instead of the title. You can observe that when you launch the controls menu in my script while the song changes, then you'll get a URL instead of a title. The solution for that is to set a delay, so the notification arrives when mpv starts buffering the content.
  2. Doesn't request the right property. This one is less likely, I do believe the reason nr 1 is true, but this still might be the case. If it request the path property, it'll return a url. If it request the title property, it MIGHT return the title. Then again, I don't know lua at all, so I can't tell you what's really happening there.
Wojnstup commented 3 years ago

Another solution would be to write a second bash script that would run in the background and check whether or not mpv song changed, and send a notification when it did. That would most likely be the simplest solution.