Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Soundcloud support #6

Closed
ghost opened this issue Dec 17, 2020 · 11 comments
Closed

Soundcloud support #6

ghost opened this issue Dec 17, 2020 · 11 comments
Labels
enhancement New feature or request

Comments

@ghost
Copy link

ghost commented Dec 17, 2020

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.

@pauloo27 pauloo27 added the enhancement New feature or request label Dec 19, 2020
@pauloo27
Copy link
Owner

pauloo27 commented Dec 19, 2020

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?

@ghost
Copy link
Author

ghost commented Dec 19, 2020

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".

@pauloo27
Copy link
Owner

pauloo27 commented Dec 19, 2020

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.

@pauloo27
Copy link
Owner

pauloo27 commented Dec 19, 2020

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

image

@pauloo27 pauloo27 mentioned this issue Dec 19, 2020
3 tasks
@ghost
Copy link
Author

ghost commented Dec 20, 2020

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.

@pauloo27
Copy link
Owner

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.

@pauloo27
Copy link
Owner

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".

@ghost
Copy link
Author

ghost commented Dec 26, 2020

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'"

@pauloo27
Copy link
Owner

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!

@ghost
Copy link
Author

ghost commented Dec 26, 2020

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!

@pauloo27
Copy link
Owner

pauloo27 commented Dec 26, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant