TheQwertiest / foo_discord_rich

foobar2000 component for integration with Discord Rich Presence
https://theqwertiest.github.io/foo_discord_rich/
MIT License
378 stars 39 forks source link

Display album art instead of fb2k logo #6

Closed popeyaho001 closed 5 years ago

popeyaho001 commented 5 years ago

As the title, can we show the image album instead foobar icon?

TheQwertiest commented 5 years ago

Unfortunately, there's nothing I can do about it - it's a limitation of Discord API. I wish I could make this plugin look the same as Spotify integration, but, alas, Discord developers are not yet ready to give such tools to 3rd parties =(

TheQwertiest commented 4 years ago

Relevant links on Discord boards: https://support-dev.discordapp.com/hc/en-us/community/posts/360043641772-Allow-use-of-progress-bar-links-in-activity https://support.discordapp.com/hc/en-us/community/posts/360053661011-Allow-different-Rich-Presence-configurations-over-IPC-API

TheLastZombie commented 4 years ago

For anyone who is also trying to hack their way around this, rich presence assets can be uploaded via a POST request:

curl -X POST https://discordapp.com/api/v6/oauth2/applications/<CLIENT ID>/assets \
     -H "Authorization: <TOKEN>" \
     -H "Content-Type: application/json" \
     -d "{'image':'data:image/png;base64,<BASE64 IMAGE>','name':'<ASSET NAME>','type':1}"

When sending the request, Discord returns a JSON object which includes an ID, which in turn can be used to delete the asset again:

curl -X DELETE https://discordapp.com/api/v6/oauth2/applications/<CLIENT ID>/assets/<ASSET ID> \
     -H "Authorization: <TOKEN>"

Some things to note:

Galixte commented 4 years ago

Hi @TheQwertiest,

is it possible to add an option to set a customize image logo of Foobar2k instead of the original?

Regards.

TheQwertiest commented 4 years ago

~No, see https://github.com/TheQwertiest/foo_discord_rich/issues/6#issuecomment-467542756~ [EDIT] If you just want to replace fb2k logo (i.e. just a static image), you can register your own Discord app with image of your preference (see the link I gave you in the other issue)

Mimi1001 commented 2 years ago

The Discord Rich Presence Plug-In for the music player MusicBee, DiscordBee, recently introduced support for custom album art by registering a custom DiscordApp and automatically uploading covers as assets. Would it be possible to implement the feature similarly for this foobar2000 Plug-In?

TwoZeroes commented 2 years ago

Any hopes of this Issue being opened up again? I hope to see this feature added.

Otuxam3 commented 2 years ago

I'm just sending this as a good reason to reopen the Issue.

As I have seen on Reddit, someone managed to use an image link as large asset image, so I wanted to do it myself with a custom RPC client to be sure this wasn't another fake, and I can tell that it indeed works. It can be easily reproduced on your side. (some infos hidden for privacy)

console result

For now there's no official documentation, but it's something to be seen soon enough in the future. It would also be a good reason to allow foobar title formatting in the assets tab.

Our prayers have been heard guys, API isn't anymore limiting us 😄

TheQwertiest commented 2 years ago

@Otuxam3 that's good news :) But I can't use it, since it's not a part of official API (yet?)

Otuxam3 commented 2 years ago

I initially wanted to edit my message at the moment the PR appeared but preferred to send a followup here. So by watching API docs repo every single day this is about to be merged, just a matter of days now 👌🏻. https://github.com/discord/discord-api-docs/pull/4317

So, wait and see I'd say ^^

EDIT: The PR has been merged a few hours ago, update will appear here

LLinoor commented 2 years ago

is there any news?

Otuxam3 commented 2 years ago

Everything is in place Discord-side, PR merge in the repo has been reflected on the website. I just don't know if this is enough for @TheQwertiest to start implementing it since this part of the docs only informs about an activity object as sent by the gateway. RPC docs do redirect to that page (follow the links). As for SDK, I don't use it when doing my stuff since I have no Idea what to change to use it via node-gyp so I stick with RPC only 😅

But my job here is done, it's now your turn to decide what to do, dear maintainer! :)

ghost commented 2 years ago

I was going to start a issue about this but looks like people already thought of wanting to set the album art as the rich presence image instead of the foobar2000 logo.

Can't wait for when the maintainer implements this feature 😄

tort-oise commented 2 years ago

Hi, found a workaround in the meantime while the maintainer is fixing up support for it:

Setting resource IDs to this. image This effectively allows you to use images.

Uploaded to Imgur, then taken through a direct link, allows you to use actual images (as long as it directs properly). It does look a bit weird with the whole "playing a game" thing, but it effectively works: image

tort-oise commented 2 years ago

(Don't mind the "playing image (dark)" section, I was messing around and doing that actually makes it look like this: image Doubles the image. Not recommended, unless you're a huge fan.

Andreas711 commented 2 years ago

I'm sorry if I'm waking a necro thread but I'm sure somebody could easy whip up a script that pulls album covers from fb2k and then set the playing icon to said album cover.

BobbyWibowo commented 2 years ago

The PoC in @tort-oise's comment appears to be the solution that is used in phineas05 / discord-rich-presence-plex, but automated

image

It automatically uploads the currently playing movie's poster into imgur (if it hasn't yet been uploaded, otherwise use cache), then use the direct link as-is for large_image asset

References: https://github.com/phineas05/discord-rich-presence-plex/blob/da7d53d1d698642095559bd4be00930267e869cc/services/PlexAlertListener.py#L203-L219 https://github.com/phineas05/discord-rich-presence-plex/blob/da7d53d1d698642095559bd4be00930267e869cc/services/imgur.py

Discord will automatically proxy the image afterwards without the app having to explicitly do so first: image

It appears Discord does not particularly care from which the remote image comes from, and will just automatically proxy them either way

I'd honestly propose this issue to be re-opened because it's now actually feasible to implement

degu-Tanya commented 2 years ago

bump, as the only still worked on foobar2000 discord presence I could find on google, it would be a nice addition.

DJTOMATO commented 1 year ago

Bump

thatonefaker commented 1 year ago

why is this closed now?

LeviOP commented 1 year ago

it was closed a long time ago, hasn't been reopened because the owner presumably doesn't feel like programming this right now

s0hv commented 1 year ago

I've been working on a prototype for this and I've created something that works in the simplest cases. It can be found on my fork here. You need to manually build it to try it out if you want. I would recommend using a backup instance of foobar instead of your main one if you want to try it out.

Here's an image of the change in action image

This implementation leaves the image uploading to the user, as I didn't want to lock people to one vendor. Also because I use my own image host. The system I wrote just calls a user specified command (e.g. an exe or a bat file) and writes the image filepath to the processes stdin. It then tries to read the output of the process and use that as the url. ~Here's the shell script I used during testing, which uses ShareX for uploading the image.~ Use the imgur script provided in #37 instead unless you really want to use this.

myvar=`cat`

"C:\Program Files\ShareX\ShareX.exe" "$myvar" -s -autoclose -m -nohotkeys
cat /dev/clipboard

I run it with git bash but any shell with cat should suffice. The command looks something like this "C:\Program Files\Git\bin\bash.exe" "C:\path\to\upload.sh" This command should be used in the plugin configuration on the advanced tab, which now has a new section for this feature. image

I can finish this feature using this approach but would be nice to get some feedback from @TheQwertiest as I don't know if this is how they'd want it to work. Also because the code quality might suck since I haven't used C++ in a long time and never written a foobar plugin before.

Maybe this issue should be reopened now since it is possible to make it work.

BDtetra commented 1 year ago

maybe an md5 hash check as well to see if the album art needs an update in the first place before actually uploading the new image (since often times you would listen to an album, where the art doesnt change). Maybe this is taking a little too far but it would help to also open a port to host the image on your ip(through a desired port),

s0hv commented 1 year ago

I've thought about the md5 hashing thing but I am unsure as to how I'd implement the storage of it. I created a new PR #37 for this so it might be best to move the discussion there relating to my implementation.

prism2001 commented 1 year ago

@s0hv how do you compile this? i have visual studio but i've never built a C++ project (or anything off github for that matter) so i'm completely lost. i tried cloning it and building the solution but it threw a bunch of errors, so build instructions would be appreciated for those of us who want to try it out but aren't already developers

s0hv commented 1 year ago

@prism2001 There are automatic AppVeyor builds done every time my PR #37 gets new commits pushed so you snatch one from there. Just use it in a copy of foobar as the plugin might break stuff between updates.

topecnz commented 1 year ago

Discord_hpFg9OkkNf

It took 2-3 days to make but it seems the codes are still messy or lacking some stuffs to add. The problem is, I don't know on how the GUID works for C++.

By the way, I used lastfm api to get the album cover and externally fetched from python. I tried curl and cpr with jsoncpp but something went wrong when compiling. For now, I am using popen to execute (I'm dealing some opening windows when changing the song.)

prism2001 commented 1 year ago

@s0hv

got it working and so far it's been really nice. a few questions though:

  1. where is the JSON file stored? the one that's supposed to keep all the hashes and URLs for cover art. i'm using your provided imgur sample python script now, btw. i was using your sharex one previously
  2. when i was using your sharex shell script, i had briefly disabled the option in sharex to automatically copy the URL of the artwork, which for some reason prevented the artwork from appearing in discord until i turned it back on, but for the albums that had their artwork uploaded when i had the URL copying disabled, they now only show up as a generic icon, and i'm not sure how to force the plugin to forget these albums or force a proper re-upload. even after switching from sharex to the imgur script they still don't show their respective cover arts. any advice on this?
s0hv commented 1 year ago

@prism2001 The json file is stored in your foobar2000 folder in a folder called foo_discord_rich. It might be a few folders deep depending on your version and install type. To clear the urls just select all the affected tracks, right click and select Discord rich presence -> Clear artwork. You can open the console to see logs related to the plugins behaviour.

prism2001 commented 1 year ago

@s0hv I've checked the folder and there doesn't appear to be any JSON file. There are two of these folders, actually. One in _AppData\Roaming\foobar2000\foo_discordrich and another one in _AppData\Roaming\foobar2000\user-components\foo_discordrich - the first one is completely empty, and the other one is just where the plugin DLL is located, along with the licenses

this is all i see in the console: image which doesn't mention anything about the JSON

s0hv commented 1 year ago

@prism2001 The file is created only after an image is actually uploaded with the latest version and the file will probably be created in the first folder.

prism2001 commented 1 year ago

@s0hv

i'm using the latest version that was built by appveyor (5 days ago) and it has uploaded numerous images so far, but nothing is being saved to a JSON on my end

s0hv commented 1 year ago

@prism2001 Try checking the console logs. When it's trying to upload an image again it should say that a hash was found or if it was not found it should say what the upload script output. Otherwise I'm not sure where the file is saved on normal installations. I use a portable installation myself.

prism2001 commented 1 year ago

@s0hv

upon booting foobar and loading any track, the only thing that appears in the console regarding the plugin is that it connected to my discord successfully. when I play tracks from albums that have already had their artworks uploaded nothing pops up at all in the console. the only time i get any other output from the plugin in the console is whenever I load an album that hasn't already had its cover art uploaded - the output for those being what I posted in the screenshot above

s0hv commented 1 year ago

@prism2001 it's working as intended then. Try clearing the artwork and reuploading it (might have to do it twice). If the hashing is working correctly it should find the old url when you try to re-upload the image.

prism2001 commented 1 year ago

@s0hv ah ok so i right clicked an album and saw the option to do what i needed in the context menu. didn't think to look there for some reason haha. got the artwork reuploaded successfully now! what's weird though is the hashing does work properly, although i'm not sure where it's storing the hashes since that JSON that it's supposed to be writing to doesn't seem to exist anywhere at all

s0hv commented 1 year ago

@prism2001 Finally was able to look at the code and it seems that I had forgotten to test the code when the json file has not been created. I did a fix and now the json file should be created correctly in that situation. The hashes won't be created for already uploaded artwork, but that shouldn't really be an issue in most cases.

GH0STDATA commented 1 year ago

@s0hv I have to say, thank you very much for adding this must-have feature to this repo! Everything for the most part seems to be working great on my end using the Imgur API Python script. I am running into one small issue where certain album covers won't upload to Imgur, however. I'm getting a generic: "File is already in use" error when trying to generate the Imgur URL manually in foobar2000. It only seems to happen on specific album covers, but works perfectly fine with majority of my music library.

s0hv commented 1 year ago

@GH0STDATA The code handles album art differently depending on if it is embedded in the music file or if it is a separate file on the disk. For embedded files the image is copied to disk and that temporary file is used. If the file is already on disk that path is used. It's likely that this difference is what causes the "File is already in use" error.

GH0STDATA commented 1 year ago

@s0hv I deleted all of the files from one of the albums I was experiencing this issue with and re-added them from the same source I got it from, and now it seems to work. Very strange... maybe it was an issue with the metadata of the audio files I deleted? Not sure, but its working now. Thanks for the feedback!

SMNFXCN commented 1 year ago

s0hv's fork, is there a way to make the component check for per-album or per-track album covers? they will default to some album cover, usually the first one i play, and never changes if i manually clear it.

s0hv commented 1 year ago

@SimonFoxcoon

s0hv's fork, is there a way to make the component check for per-album or per-track album covers? they will default to some album cover, usually the first one i play, and never changes if i manually clear it.

"Artwork identifier key" might be what you're looking for https://s0hv.github.io/foo_discord_rich/docs/album-artwork/#descriptions-of-options

TobyTobyReal commented 2 months ago

I've been messing with the artwork identifier key for hours now trying to make it show per-track album covers, can someone help please?

s0hv commented 2 months ago

I've been messing with the artwork identifier key for hours now trying to make it show per-track album covers, can someone help please? @TobyTobyReal Would this work %album artist% [- %album%] - %title% [- %discnumber%]

TobyTobyReal commented 2 months ago

I've been messing with the artwork identifier key for hours now trying to make it show per-track album covers, can someone help please? @TobyTobyReal Would this work %album artist% [- %album%] - %title% [- %discnumber%]

Unfortunately that doesnt seem to work either, thanks for trying to help though!

shirafukayayoi commented 1 month ago

@s0hv I am Japanese and am not good at English, so I use translation software. My question is, what is the name of the metadata that contains the album art of imgur used in this s0hv plugin? %title% %artist% It's a part like that.

Addendum.

What I'm thinking of doing now is putting the playback information into a txt file with the nowmusic plugin, reading it and displaying it as DIscordRIchPresence. https://github.com/shirafukayayoi/Node_fb2kRichPresence I want the nowmusic plugin to output the name of the imgur file it creates, but I can't do that because it's not metadata.

Do you have any ideas?

s0hv commented 1 month ago

@shirafukayayoi Unfortunately I don't think what you're trying to do is possible. The plugin does not expose any metadata fields that can be read with the %xxxxxxx% syntax.