TheQwertiest / foo_discord_rich

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

Allow artwork url as the large image #37

Closed s0hv closed 3 weeks ago

s0hv commented 2 years ago

I've written some documentation about this feature (such as how to configure it) to https://s0hv.github.io/foo_discord_rich/docs/album-artwork. I also wrote a rust program for the upload process. The repository can be found here and installation instructions here.

For things not related to implementation details or problems in code such as installation problems, use the discussion forum on my repo as that's a better place to organize those discussions https://github.com/s0hv/foo_discord_rich/discussions. Also @JizzMasterBladee created a video tutorial on the installation process which you can find here https://www.youtube.com/watch?v=E-uq0WT2pwk

This PR tries to implement a simple way of using artwork in the discord status. I've implemented in a way that leaves the uploading of the file to the user in order to allow for flexibility as to where and how the uploading is done.

~Important features currently not implemented~ Should be fine now

The path to the image upload command is set in Preferences -> Tools -> Discord Rich Presence Integration -> Advanced -> Artwork upload command. A checkbox used to enable and disable this feature is also found in the advanced tab (disabled by default).

Seagulls commented 2 years ago

Would love to see this come to fruition.

Elixcore commented 1 year ago

Hey is it possible I could get a built version of this? The appveyor artifact expired a while ago and I have no clue how to compile this. Thanks!

s0hv commented 1 year ago

@Elixcore Created a new release on my fork of the repo. https://github.com/s0hv/foo_discord_rich/releases/tag/1.3.0-beta You can download the build from there until this PR gets activity

Elixcore commented 1 year ago

@s0hv thanks a bunch! works perfectly! image

afraidofwomen28 commented 1 year ago

two things:

how exactly do i set the uploading album art up from the new release? also, do you think it would be possible to enable the discord rich presence button feature?

s0hv commented 1 year ago

@JizzMasterBladee I updated the PR description with a tiny bit more detailed instructions. The script itself still requires you to have python 3.7 or later installed with the requests library and an imgur API key. A windows batch script could also work, but UTF-8 support for that is more tricky.

As for the button feature, that is probably possible but not in the scope of this PR.

afraidofwomen28 commented 1 year ago

@s0hv im gonna be honest ive tried my best to follow the instructions but still have no result. is there any way i could add you on discord?

edit: seem to have figured it out by myself, thank you for the instructions though! :)

ANOTHER edit: if anybody is like me and sorta has no idea what to do, i made a really low quality but hopefully easy to follow tutorial https://youtu.be/E-uq0WT2pwk

sapphonie commented 1 year ago

couldn't you leverage winhttp for uploading instead of using a python script w/ requests? other than that, this seems pretty okay, though i'm a little scared of the char* caused weird random changes comment somewhere in there lol

s0hv commented 1 year ago

@sapphonie I'm not that familiar with the Windows API so I settled with something simple in terms of lines of code. Also that would require embedding the imgur API key which might create some problems (don't know what kind of ratelimits or other constraints they have). If you were wondering why I opted for a script instead of an embedded solution was for flexibility. I for example don't use imgur so it would lock me to only using that. Scripts also allow for more sophisticated solutions if you require those.

As for the char* random changes, the memory would randomly change during upload partially or completely changing the filename. Never figured out the exact reason for this but it happened after this line.

const auto md5 = static_api_ptr_t<hasher_md5>()->process_single(artwork.data->get_ptr(), artwork.data->get_size()).asString();

Might be some problem with album_art_data_ptr causing that method to overwrite data.

BobbyWibowo commented 1 year ago

I'd like to add that me, as an end-user, also prefer the custom script approach, as likewise I don't use Imgur either And modifying the module source directly (if it was baked in), as opposed to a simple python script, is much more of a pain to be honest

Gallus780 commented 1 year ago

I've gone through all steps, even updated foobar2000 with all its plugins. I have downloaded Pyhton both from its official website and Microsoft Store. However the cover art still doesn't show in Discord. What is wrong?

s0hv commented 1 year ago

@Gallus780 I created a discussion tab to my repository with a new discussion for this problem, as I don't think this PR is the correct place to talk about installation problems. You can find the discussion with my response there https://github.com/s0hv/foo_discord_rich/discussions/2. I also updated the PR description to guide others to the discussion forum instead of here for situations like this.

s0hv commented 1 year ago

As the status of this PR has not really changed I started to write some of the documentation alongside a rust program that will handle the uploading to imgur with minimal user configuration. The documentation can be found here and the instructions for the rust program can also be found from the same page

HerXayah commented 1 year ago

Anything bout 64bit yet?

mechabubba commented 1 year ago

hey there, just wanted to drop by and say this component is awesome. i whipped together a script to upload to catbox.moe over imgur. perhaps this is more useful to people who don't want to sign up for an api key for imgur;

import requests
import sys

sys.stdin.reconfigure(encoding='utf-8')
filename = sys.stdin.read().strip()

with open(filename, 'rb') as f:
    data = {
        'reqtype': (None, 'fileupload'),
        'userhash': (None, ''),
        'fileToUpload': f
    }
    r = requests.post("https://catbox.moe/user/api.php", files=data)

if not r.ok:
    print(r.text[:1000])
    exit(1)

print(r.text, end='')
s0hv commented 1 year ago

@mechabubba Thank you. I can add that script to the documentation if you create a gist of it.

mechabubba commented 1 year ago

@s0hv sure thing, posted it here: https://gist.github.com/mechabubba/db1200c05fbbecf753b23c92ee8e9271

with the original script i started having some issues with a mysterious error 259, which seemed to correspond to image size (seemed to struggle uploading anything past like 128kb?). i also posted an experimental script that sizes down and compresses the image to a reasonable size.

with some experimentation, i've had a lot more luck with this script than the original.

s0hv commented 1 year ago

@mechabubba Thanks I'll add it the next time I edit the docs. Error 259 can be many different exceptions. By default exceptions get written to stderr which is not read by the plugin causing the error without error message. I updated my upload script and wrapped it inside a try except and an error printing function. You should probably wrap your script in a try except like this so it's easier to know what the error actually is instead of just a random error number.

realoksi commented 1 year ago

I went ahead and made a script in Rust that uploads to catbox as well using curl. Repo is here and I built a release if you guys want to check it out

Markigagaxd commented 1 year ago

So far I want to do that and it won't let me. Can someone pass me the script?

s0hv commented 1 year ago

@Markigagaxd

So far I want to do that and it won't let me. Can someone pass me the script?

The documentation at https://s0hv.github.io/foo_discord_rich/docs/album-artwork/ should have all of the necessary info and links

nullobsi commented 11 months ago

I've been looking at plugins for Discord RPC for foobar2000, and this seems like a really nice fork.

But one thing that bugs me is that I already have all my music tagged with MusicBrainz MBIDs. The upload strategy works well, but there is already the Cover Art Archive. Another similar project for MPD already uses this strategy, but I'm not sure how tags are exposed in foobar2000 so that you're able to grab the tag.

https://github.com/JakeStanger/mpd-discord-rpc here is the project for reference.

And https://github.com/JakeStanger/mpd-discord-rpc/blob/83cefa7ef522e0bf4f4f93bfb34a293474819f13/src/album_art.rs#L167 is the specific line; it is basically as easy as concatenating the MBID with the coverartarchive URL.

I might look into changing the code and adding this as an option in addition to the current upload strategy, but I hope it's something you think is interesting and would be fun to implement.

Thank you for your work :)

s0hv commented 11 months ago

@nullobsi I think the smartest way to implement something like that would be to allow for title formatting in the command string. Then you could use something like script --param "%MUSICBRAINZ_ID%" or whatever you need as the command and the title formatting would handle replacing the special strings. That would allow for maximum flexibility without introducing too specific features in this code. This does however require you to implement the actual script that returns the url. Also, I don't really know when I'd have time to implement and test something like this.

bsdinis1 commented 10 months ago

@Elixcore Created a new release on my fork of the repo. https://github.com/s0hv/foo_discord_rich/releases/tag/1.3.0-beta You can download the build from there until this PR gets activity

Is it possible to get the x64 version? I'd really like to try this out

s0hv commented 10 months ago

Is it possible to get the x64 version? I'd really like to try this out

@bsdinis1 Here https://github.com/s0hv/foo_discord_rich/releases/tag/64-bit-prerelase

bsdinis1 commented 10 months ago

As the status of this PR has not really changed I started to write some of the documentation alongside a rust program that will handle the uploading to imgur with minimal user configuration. The documentation can be found here and the instructions for the rust program can also be found from the same page

Not sure if this is a Discord issue, or your upload script, or foo_discord_rich, but it is not working with .webp album art. Except for that, everything seems to work perfect.

s0hv commented 10 months ago

Not sure if this is a Discord issue, or your upload script, or foo_discord_rich, but it is not working with .webp album art. Except for that, everything seems to work perfect.

@bsdinis1 Seems like imgur does not support webp https://help.imgur.com/hc/en-us/articles/115000083326-What-files-can-I-upload-Is-there-a-size-limit- Catbox.moe which has upload scripts listed in the documentation seems to support webp though. Or you can create your own script for an image host you'd like to use.

okdargy commented 9 months ago

just wanted to add this since i saw the imgur and catbox.moe version of the upload album python script so i decided to make my own for aws s3

import boto3
import sys

try:
    sys.stdin.reconfigure(encoding='utf-8')
    filename = sys.stdin.read().strip()

    bucket = ''
    directory = 'foobar2000/albums'
    region = '' # example: us-east-1
    access_key = ''
    secret_access_key = ''

    s3 = boto3.client(
        's3',
        aws_access_key_id=access_key,
        aws_secret_access_key=secret_access_key,
        region_name=region,
    )

    s3.upload_file(filename, bucket, f'{directory}/{filename}')

    print(f'https://s3.{region}.amazonaws.com/{bucket}/{directory}/{filename}')
except:
    import traceback
    traceback.print_exc(file=sys.stdout)
    exit(1)
s0hv commented 9 months ago

@okdargy I can add that to the list. Could you create a gist of the script so it is easier to link.

okdargy commented 9 months ago

@okdargy I can add that to the list. Could you create a gist of the script so it is easier to link.

Sure, here: https://gist.github.com/okdargy/a55f40c7b339ee0a8b10a9827015453b

JDJGInc commented 6 months ago

so you have to use imgur or another image uploader to get this to work?

s0hv commented 6 months ago

so you have to use imgur or another image uploader to get this to work?

@JDJGInc Yes. You can create your own or use one of the ones already available

TheQwertiest commented 3 weeks ago

Huge thanks @s0hv for your idea and implementation! A variation of this feature is now in master, which would've never been there without your PR :) Closing this PR, since it's not intended to be merged now anyway.

TheQwertiest commented 3 weeks ago

Oh, and I've taken the liberty of reusing your docs for the feature. Hope you don't mind :)

okdargy commented 3 weeks ago

Correct me if I'm wrong but I believe v2.0.0 breaks the python scripts. Before, in @s0hv's branch, it created a temp image then sent that image's path thru instead of the actual music file path.

image

TheQwertiest commented 3 weeks ago

My bad, forgot to test embedded images. Please open a separate issue though.

s0hv commented 3 weeks ago

Oh, and I've taken the liberty of reusing your docs for the feature. Hope you don't mind :)

Great to hear this also got implemented 🙌 And please do reuse the docs. I have no problems with that