Closed popeyaho001 closed 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 =(
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:
Hi @TheQwertiest,
is it possible to add an option to set a customize image logo of Foobar2k instead of the original?
Regards.
~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)
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?
Any hopes of this Issue being opened up again? I hope to see this feature added.
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)
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 😄
@Otuxam3 that's good news :) But I can't use it, since it's not a part of official API (yet?)
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
is there any news?
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! :)
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 😄
Hi, found a workaround in the meantime while the maintainer is fixing up support for it:
Setting resource IDs to this.
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:
(Don't mind the "playing image (dark)" section, I was messing around and doing that actually makes it look like this:
Doubles the image. Not recommended, unless you're a huge fan.
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.
The PoC in @tort-oise's comment appears to be the solution that is used in phineas05 / discord-rich-presence-plex, but automated
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:
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
bump, as the only still worked on foobar2000 discord presence I could find on google, it would be a nice addition.
Bump
why is this closed now?
it was closed a long time ago, hasn't been reopened because the owner presumably doesn't feel like programming this right now
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
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.
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.
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),
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.
@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
@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.
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.)
@s0hv
got it working and so far it's been really nice. a few questions though:
@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.
@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:
which doesn't mention anything about the JSON
@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.
@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
@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.
@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
@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.
@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
@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.
@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.
@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.
@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!
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.
@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
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?
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%]
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!
@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?
@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.
As the title, can we show the image album instead foobar icon?