jeffvli / sonixd

A full-featured Subsonic/Jellyfin compatible desktop music player
GNU General Public License v3.0
1.87k stars 73 forks source link

Local scrobbling / OBS integration #136

Closed h-4-t closed 2 years ago

h-4-t commented 2 years ago

Oh hai o/

Is your feature request related to a problem? Please describe. Being PII aware, I would love to have the ability to scrobble/export current playing song artwork/info locally in a pre-defined folder. This could be useful for those using OBS as a streaming plateform, because it usually needs 3rd party plugin (Tuna-OBS) querying 3rd party services (last.fm usually)

Describe the solution you'd like Depends on your code, it could range from a local query-able API to bridge the gap (Tuna-OBS has webservice capabilities cf https://www.youtube.com/watch?v=sznUjzpx1KE )

Describe alternatives you've considered

Additional context Thanks again for this gem in the *sonic ecosystem \o/

jeffvli commented 2 years ago

That's an interesting use case that I hadn't considered before.

I'll do some testing with Tuna to see how it works.

jeffvli commented 2 years ago

@h-4-t I pushed a dev build with initial support for Tuna OBS. Could you test it and provide feedback for me? I'm not able to properly set up Tuna on my machine so I can't test it fully.

Download a build that starts with Sonixd(dev)_2021-12-22T11 from here: https://ftp.sonixd.com and install/run. Details of the implementation are in #154.

h-4-t commented 2 years ago

LGTM 🎆 Local scrobbing seems to work flawlessly for the aimed workflow, thus bypassing the need of Tuna \o/ Tuna (or Snip) are used to parse metadata played in Spotify & co and export it to text file that are usually used by a html template (Zyphen is the one I use).
I just had to edit the html template to match Sonixd's output file and I was done !

It may be specific to my current setup, but there seems to be a problem with covers as show below:

screen

Thanks again for the gem of software \o/

jeffvli commented 2 years ago

Thanks for testing! The exported cover is just set as cover.jpg so you probably need to edit your OBS overlay html to point to it. I looked at Zyphen and you might need to rename all instances of Snip_Artwork.jpg to cover.jpg. When a song doesn't have an image, no image is exported. Is that fine, or should a placeholder image be added?

I'll probably remove the reference to Tuna then since this feature is more of a catch-all.

h-4-t commented 2 years ago

IMHO a placeholder suits better. The thing is that the cover.jpg file is not actually created in the first place, even if the track has a cover in Sonixd as shown in the previous screenshot. Is there a way to help you track down where this come from? I'm using gonic v0.14.0 as subsonic server if that matters. Cheers o/

jeffvli commented 2 years ago

I just tested on gonic and I'm not seeing any issue with the cover being downloaded. I wonder if you'd be able to modify the html template to point to the cover url provided by the server? If so, then I could just export the cover url to another file like cover.txt. Though I'm confused as to why it's not being downloaded for you.

Troubleshooting would be a pretty involved process:

  1. Clone the pull request branch
  2. Run it locally
  3. Modify the writeTunaFiles function in utils.ts and include a .catch in the download.image() to see why it's not working.

I need to head out now, but I'll do some additional testing/modifications tomorrow to optimize it. In the current implementation, the cover image is being downloaded on every poll which isn't ideal.

h-4-t commented 2 years ago

I think that exporting the url to another text file would be a golden catch-all/workaround \o/ I'll investigate in my specific case from my side anyway. Closing this feature-request, can't wait to see this feature on the next release !

h-4-t commented 2 years ago

FYI, finally tracked down the problem: screen21

It seems that electron has currently trouble with let's encrypt root certificate (cf https://github.com/electron/electron/pull/31213 ). You may need to bump electron version (+v17) if side effects appears in this area.

jeffvli commented 2 years ago

@h-4-t Thanks for figuring out the issue. Bumping the electron version to a new major release isn't a trivial task, as there are a lot of breaking changes. From the issue you linked, it seems that the fix was also merged in v13, which Sonixd is using. I'll bump to the latest minor version, from 13.3.0 -> 13.6.3 and see if it fixes it for you.

h-4-t commented 2 years ago

Oh hai o/ A quick follow up on the new year release regarding this usecase :

Thanks again & a Happy new year!

jeffvli commented 2 years ago

So OBS is able to gracefully handle the image url from a txt file? If so, I can just remove the image download.

h-4-t commented 2 years ago

Technically it's just a matter of changing/adding js routine to deal with it in the HTML file. For documentation purposes, a modified version of the Zyphen's Now playing is available here https://gist.github.com/h-4-t/fdcddaba91e668f0d5bfce63b13c7c59#file-song-html-L75 shows it's done.

jeffvli commented 2 years ago

@h-4-t For some reason I thought I already added the cover.txt in the original implementation. I just added this and removed the image download for the local scrobble, except it is named image.txt now.

FaNt4zMa commented 1 year ago

@h-4-t Would it be possible to have the js routine you're talking about? I've got title and artist name working thanks to your edit to the HTML file but that's as far as I can go without help.

I'm surprised someone else had almost the same use case as me (Scrobbling for OBS Zyphen Now playing widget). Thanks!

Edit: Nevermind, sorry for the ping. A friend told me to use ChatGPT and it figured it out. Here's the code for further documentations purposes :) https://pastebin.com/1XPGJAhS