foo_drpc icon indicating copy to clipboard operation
foo_drpc copied to clipboard

Artwork/cover showing in discord(?) + title format

Open claire-rouge opened this issue 6 years ago • 4 comments

is it possible to make so the foo_drpc component show the artwork/cover? (if the file ur playing have it) instead of foobar2000 logo in discord?

maybe a option to turn that off and on for people that wants it in components preference. (idunno if u want to do it, sound like alot of work to do. but would be a nice option to have)

if u dont want to do the thing above, is it possible to make so we can change how the songs are being showed atleast? (i dont like how it shows artist-title, i like it like "title" by artist) if we could add our own title format script it would be nice. since i like using this:

$if($and(%artist%,%title%), "%title%" By %artist% ) $if($and(%title%,$not(%artist%)), %title% )

(and some may like to use their own)

claire-rouge avatar Mar 08 '18 13:03 claire-rouge

Hey there, First of all, thanks for telling me your wishes and ideas.

Regarding artwork and covers, I unfortunately have to tell you that this is not quite possible. :( The images shown inside the rich presence work kind of like this: Each "app" using the Discord Rich Presence has a unique registered ID it sends together with the Rich Presence message packets. On Discords end, this ID is linked with an "Rich Presence app" that I registered there, also the name and images this app can use inside of the Rich Presence are stored there. So, inside of the Rich Presence messages, each app sends the name of one of those images (or more for the small icon and background) to Discord.

If my plugin should be able to show artwork or a cover, I would need to upload them to the Discord application registration as assets for the Presence App to use. AFAIK there is a limit on how many assets you can upload there and automated upload for them is not available yet (still Ignoring the fact, that artwork from every plugin user would need to be uploaded).

For the second thing, I havent figured out yet how to register a configuration/settings page inside of the foobar2000 preferences window. I could however try to store some sort of config inside of a file that could be edited. I'll gonna try to implement that!

ultrasn0w avatar Mar 08 '18 16:03 ultrasn0w

  1. oh, thank you for quick answer, I see. Well it cant be helped then ^^

  2. ye that would be cool if you manage to implement that :)

Thank you again for answering so fast, so far i love this component for Discord Rich Presence. keep up the good work 👍

claire-rouge avatar Mar 08 '18 16:03 claire-rouge

I've been thinking about this too. Each user would need to create their own Discord "app" and set the ID accordingly, but you could probably easily automate the act of uploading a picture with an HTTP library. I'm not a C++ guy, but I want to try and get a proof of concept working of this.

ayancey avatar Aug 15 '18 06:08 ayancey

def change_album_art(f_name):
    with open(f_name, "rb") as f:
        album_cover_base64 = base64.b64encode(f.read())
    requests.post(
        "https://discordapp.com/api/oauth2/applications/YOUR APP ID/assets",
        headers={"Authorization": "YOUR AUTH HEADER HERE"},
        json={
            "name": "album",
            "image": "data:image/jpeg;base64,{}".format(
                album_cover_base64.decode("ascii")
            ),
            "type": "1",
        },
    )

This above method will upload a JPG to the app assets list, given the users app id and authorization header. Unfortunately, I couldn't get the proof of concept to work that uploads album art and sets the activity on the fly. I think it's an issue with caching or something like that.

ayancey avatar Aug 15 '18 20:08 ayancey