pauloo27/tuner

Soundcloud support

Closed this issue · 11 comments

I'd love to see SoundCloud search supported by this, as the only other cli streaming alternative I've found, mopidy-soundcloud, requires you to have a SoundCloud account and it's written in Python.

Perhaps you could use this unofficial golang SoundCloud API or maybe take some inspiration from NewPipeExtractor's SoundCloud service.

I will take a look, thanks.

How you suggest I implement it?

I as thinking of adding a command to toggle soundcloud search source. This way, when the user do a search, the displayed results come from the search sources he enabled.

Is that good?

The toggle method sounds good, but I'd also suggest adding a preference inside ~/.cache/tuner/data.json (maybe called Source), so that the user can choose what source do they want to use by default, with possible values "soundcloud", "youtube", and if it's possible to merge the search results, "all".

It's WIP in the dev branch. I had to create "migration" so the saved playlists from previous versions doesn't break (since now the URL isn't based in the stored ID).

Right now, the search sourcers are always enabled and results from SoundCloud are yellow:

image

image

Now I need to "parse" the duration (right now it displays ???), display the album art and make commands to toggle the sources.

  • Fix duration
  • Show album art
  • Command to toggle sources

image

Awesome! Hopefully SoundCloud doesn't rate limit the requests on its v2 API. I've realised two things while using tuner over these days. First, the screen flashes every ~5s, I assume this is done to update the duration status bar, but is there any way to work around this issue? It's not visible in the gif below but it's something definitely present.
20201220-154906
Second, as show in the above gif, the loop icon isn't displayed when toggling it, do I need a certain font? I'm currently using a patched font from nerd-fonts.

I've noticed the screen flickering as well, but it doesn't happen that often here. Right now, every second or every important player event triggers the display function. The display function clear the terminal and print everything again. I was thinking of creating a different function to the progress bar, removing it from the display function. I guess that's already enough to reduce this problem.

About the loop icon, it uses Font Awesome 5. I forgot to add it to the README, sorry.

I think the last commits fixed the flashing screen.

Now, there's a renderPlayer() and a renderProgressBar(). This reduced the amount of times that the player is redraw. The progress bar continues to be redraw every second and when the player is seeked, but I think it's not going to "flick".

I've just built the latest dev branch, Soundcloud support works as expected and no more flickering! However, I've noticed MPRIS is not working, even though I've enabled it with /m and it shows as true in ~/.cache/tuner/data.json. MPRIS is working on master and I've also checked the file /etc/mpv/scripts/mpris.so is present. Also, is there any reason why the default volume is now 50%?

Additionally, it'd be great if one could use custom mpv commands within tuner without having to toggle video mode. One use case would be to download a video with youtube-dl or to show video comments if available with straw-viewer like the following in mpv's config

# Display video comments
c run "/bin/sh" "-c" "term 'straw-viewer  --comments=${path} --page=1 | bat --style=plain --paging=always'"

# Display video info
i run "/bin/sh" "-c" "term 'straw-viewer --info=${path} --page=1 | bat --style=plain --paging=always'"

Hello, happy holidays!

However, I've noticed MPRIS is not working, even though I've enabled it with /m and it shows as true in ~/.cache/tuner/data.json.

The master code uses the mpv-mpris to communicate with MPV, that works, but it wasn't the best way to do it. The code in dev uses libmpv instead. The "problem" is that libmpv doesn't load any scripts by default, so I have to tell it to load the mpv-mpris script. I was trying to load only the file at ~/.config/mpv/scripts/mpris.so but in the last commit I fixed it and now it tries to load either ~/.config/mpv/scripts/mpris.so or /etc/mpv/scripts/mpris.so. Can you test it?

Also, is there any reason why the default volume is now 50%?

No reason. Should I change it? I was thinking of 75% or maybe 100%. What do you think?

Additionally, it'd be great if one could use custom mpv commands within tuner without having to toggle video mode.

That's a great idea. I will try to add this in a future release.

Thanks a lot for your feedback!

The master code uses the mpv-mpris to communicate with MPV, that works, but it wasn't the best way to do it. The code in dev uses libmpv instead.

I see, thank you for the quick fix, it's already working as intended.

My setup consists of mpd to play local files and tuner to stream songs. However, I'd like to be able to switch between those two seamlessly without having to kill their processes. I have a module in my panel bar to display current MPRIS data, but as soon as I open tuner the data from my playing mpd song is gone, is there any way to call mpv-mpris only when actually playing audio and killing it after one has quit the song? That would allow me to get the MPRIS data for other applications but keep tuner open.

No reason. Should I change it? I was thinking of 75% or maybe 100%. What do you think?

IMO the default should be 100%

Thank you for your ongoing hard work, it's highly appreciated!

I have a module in my panel bar to display current MPRIS data, but as soon as I open tuner the data from my playing mpd song is gone, is there any way to call mpv-mpris only when actually playing audio and killing it after one has quit the song?

I don't think it's possible to "unload" a MPV script so I would have to kill the entire MPV instance and I think that's not good.

Usually "idle" (with "Stopped" Playback status) players are ignored (or treated with lower priority) by panel bar modules.

Right now I use a module that was made by me and it works with polybar (https://github.com/Pauloo27/gotroller). It looks nice, but is kinda buggy.

image

When you click the "menu" icon a GTK window opens and you can select the player to be displayed in the bar:

image
image

This GTK window comes with a cost, the RAM/CPU usage isn't great.

I think that best solution is to find a way to "configure" your bar module to show "playing/paused" over "stopped" players.