sll552 / DiscordBee

MusicBee plugin that updates your Discord status with the currently playing track
Apache License 2.0
421 stars 31 forks source link

DiscordBee Doesn't Upload Anything to the Discord Application's Assets #100

Closed Gimzie closed 2 years ago

Gimzie commented 2 years ago

Describe the bug While DiscordBee seems to correctly read and display images that are on the linked Discord Application, it seems to be unwilling to upload anything, even given adequate time.

To Reproduce Steps to reproduce the behavior:

  1. Create a Discord Application.
  2. Enable DiscordBee, and fill in the Application ID.
  3. Restart MusicBee.
  4. Play some music and wait.

Expected behavior DiscordBee uploads the four default images (or sees that they're already there), and then starts uploading album art every now and then, per Discord API limitations.

Environment (please complete the following information):

Additional context I initially waited an hour or so for the default images to upload to the Discord Application, but nothing happened. I went ahead and uploaded my own four icons through the web interface, and in around 5 minutes, DiscordBee could display them properly.

However, even after hours and hours of playing music, DiscordBee simply refuses to upload any cover art assets.

If it helps, these are some other conditions on my end:

At this point I'm not sure what could be causing this, other than some kind of selective bug. I know some people where DiscordBee works for them, I know other people where it uploads default assets but not covers, and I know other people where it doesn't work entirely.

thekirbykid20067 commented 2 years ago

experiencing the exact same issue, although i haven't tried uploading any assets manually

TheAgamer554 commented 2 years ago

2.0.2 here, and same issue, although I am using the MS Store version of MusicBee (the extension works fine besides this issue) and I don't have Nitro on Discord.

lkprod3 commented 2 years ago

Having pretty much the exact same problem, it's essentially what I had described here: https://github.com/sll552/DiscordBee/issues/92#issuecomment-962626717

Fivda commented 2 years ago

Same issue

sll552 commented 2 years ago

Because it seems like many people are still having diverse issues with the upload, I am going to add logging to the next release, to get a clue whats happening. Until that unfortunately I have to ask for your patience.

Rings4 commented 2 years ago

I've never had a single issue with mine for some reason. It just worked from the get go. The only thing I think may be the reason is that I didn't update the config file when updating the plugin. The contents of my mb_DiscordBee.dll.config are:

<?xml version="1.0"?>
<configuration>
    <startup/>
</configuration>

Maybe you guys having issues can try editing the contents of yours to be the same as mine? That's really the only thing I can think of that I'm doing differently here, hopefully it helps you.

Gimzie commented 2 years ago

Maybe you guys having issues can try editing the contents of yours to be the same as mine? That's really the only thing I can think of that I'm doing differently here, hopefully it helps you.

Thanks for the suggestion, but I actually didn't overwrite my config file either, when updating. I later tried with the default config as well, and no dice.

thekirbykid20067 commented 2 years ago

Although this doesn't fix OP's issue, as they had 2FA turned on, I was able to fix mine by enabling it on my account. if anybody else here doesn't have 2FA enabled try turning it on and that may fix it.

sll552 commented 2 years ago

Although this doesn't fix OP's issue, as they had 2FA turned on, I was able to fix mine by enabling it on my account. if anybody else here doesn't have 2FA enabled try turning it on and that may fix it.

This should not be necessary anymore since 2.0.2.

What may help, but only if DiscordBee doesn't upload anything (so no base assets like logo, etc.), is to log out of Discord and delete %APPDATA%/discord/Local Storage/leveldb then start Discord again. Make sure that after the restart you have to login by typing your credentials and not via autodetection, because with autodetection the token might not end up where DiscordBee is looking for it.

Gimzie commented 2 years ago

What may help, but only if DiscordBee doesn't upload anything (so no base assets like logo, etc.), is to log out of Discord and delete %APPDATA%/discord/Local Storage/leveldb then start Discord again.

This did the trick! Everything uploads as intended. Unfortunately, this caused me to lose all my favorited GIFs, so to anyone else trying this; be careful!

The only issue now is that this bug with switching images happens, but overall, DiscordBee works as intended.

Fivda commented 2 years ago

Doesn't seem to do much to me. I did follow @sll552's instructions but I've still only got my manually added image for the logo and that's it. I do have 2FA on too. Do i have to do something more?

EDIT: After some time it seems like it actually works :o

Gimzie commented 2 years ago

Well, this is bizzare;

While the images worked yesterday, and they're all uploaded to the Discord application, DiscordBee does not insist on using them now. Despite them all being uploaded, the default image is still used for those albums.

Are these assets time-sensitive in some way?

sll552 commented 2 years ago

This did the trick! Everything uploads as intended. Unfortunately, this caused me to lose all my favorited GIFs, so to anyone else trying this; be careful!

Sorry I was not aware that any non-temporary data is saved in there. When I tried it I did not notice anything in my client but I do not use many Discord features.

Well, this is bizzare;

While the images worked yesterday, and they're all uploaded to the Discord application, DiscordBee does not insist on using them now. Despite them all being uploaded, the default image is still used for those albums.

Are these assets time-sensitive in some way?

No, at startup the plugin reads the existing assets and uses them. That means that most likely your token could not be extracted again this time.

Gimzie commented 2 years ago

No, at startup the plugin reads the existing assets and uses them. That means that most likely your token could not be extracted again this time.

This is what I'm actually unclear on. Believing that to be the case again, I went ahead and wiped my LocalStorage/leveldb, and restarted both MusicBee & Discord, making sure to log in using my credentials, and... nothing.

Existing images don't get used, and no new images get uploaded, similar to the first time I had experienced problems getting it to work.

EDIT: After about an hour since resetting, it seems to work again? Existing assets show up properly, and new ones get uploaded again. The question remains though as to why it had to be reset first, since it appears to be very inconsistent.

MineRock commented 2 years ago
11/14/2021 6:19:17 PM - 10.0.19043.0 - 3.4.7805.33439D - System.AggregateException: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: authToken
   at MusicBeePlugin.DiscordTools.AssetManager..ctor(String authToken, String discordAppId)
   at MusicBeePlugin.DiscordTools.DiscordClient.<AssetManagerInit>d__18.MoveNext()
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.ArgumentNullException: Value cannot be null.
Parameter name: authToken
   at MusicBeePlugin.DiscordTools.AssetManager..ctor(String authToken, String discordAppId)
   at MusicBeePlugin.DiscordTools.DiscordClient.<AssetManagerInit>d__18.MoveNext()<---

This is the error I have, it seems like it isn't picking up my token. I've tried wiping leveldb lots of times but still the same error

Svarr commented 2 years ago

I haven't tried the new feature yet, but I searched with the non-2FA regex ([\w-]{24}\.[\w-]{6}\.[\w-]{27}) in 000005.ldb using Notepad++ and found multiple tokens (because the regex doesn't require a delimiter) related to Steam ([...],"distributor":"steam","toke[...]) before the actual one. I'm not sure if Regex.Match() in C# behaves the same, but if it does, readToken() may be setting the wrong token, depending on where it is located in the file. In my case, the regex \"[\w-]{24}\.[\w-]{6}\.[\w-]{27}\" would find only the correct token.

sll552 commented 2 years ago

This could of course be an issue, nice catch. I will add the delimiters in the next version, or you can send a pull request if you like to have that faster.

The regex parsing of those files is absolutely not ideal but unfortunately currently the best way, as there is no parser for the fileformat (leveldb) in c#.

Svarr commented 2 years ago

Opened a PR (#104), it was just a small change... I tested it and it fixes the issue for me.

I just don't know why even the already merged commits are included in the PR. 🤨

sll552 commented 2 years ago

I just don't know why even the already merged commits are included in the PR. 🤨

This can have multiple reasons try https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork and then rebase your branch. But for now I squashed and merged as there were no conflicts.

For everyone having problems with no assets uploading please try this build https://ci.appveyor.com/api/buildjobs/91o60escxx6qch50/artifacts/DiscordBee-Release--190.zip which contains the fix from @Svarr I would like to have a little more feedback before releasing it as a new version.

instilledbee commented 2 years ago

Hi,

I tried the build with the fix but I don't think the issue is resolved for me. I tried uninstalling the plugin from MusicBee and copying the files in the new build manually.

The MusicBee error logs doesn't show anything related to DiscordBee itself.

If it matters, I use 2FA and have not tried logging out of Discord/clearing app data.

Svarr commented 2 years ago

If it matters, I use 2FA and have not tried logging out of Discord/clearing app data.

The fix is for non-2FA only.

You should try the logging out stuff.

VelocityRa commented 2 years ago

I tried the logging out & leveldb clear method and now DiscordBee doesn't work at all.

@sll552

I am going to add logging to the next release, to get a clue whats happening.

Was this done? The log file which is presumably C:\Users\Nikos\AppData\Local\Packages\50072StevenMayall.MusicBee_kcr266et74avj\LocalCache\Roaming\MusicBee\ErrorLog.dat (the option to see it from within MusicBee didn't work) does not contain anything relevant, it hasn't been written to in weeks.

I'm using https://betterdiscord.app/ with Discord PTB. MusicBee is the latest Store version.


Also, does this work with vanilla Discord for anyone? Is it just because I'm using BetterDiscord.

Rings4 commented 2 years ago

Also, does this work with vanilla Discord for anyone? Is it just because I'm using BetterDiscord.

I've never had a single issue on vanilla discord with musicbee portable.

VelocityRa commented 2 years ago

Installed vanilla, worked for a bit (no album covers, just like before) but after logging out & clearing leveldb, DiscordBee doesnt work at all now. Same bug as before but now with vanilla too. No errors on ErrorLog.dat, except for this one, once, earlier.

Parameter name: authToken
   at MusicBeePlugin.DiscordTools.AssetManager..ctor(String authToken, String discordAppId)
   at MusicBeePlugin.DiscordTools.DiscordClient.<AssetManagerInit>d__18.MoveNext()
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.ArgumentNullException: Value cannot be null.
Parameter name: authToken
   at MusicBeePlugin.DiscordTools.AssetManager..ctor(String authToken, String discordAppId)
   at MusicBeePlugin.DiscordTools.DiscordClient.<AssetManagerInit>d__18.MoveNext()<---

(now i get no errors, it just doesnt work, also tried to reinstall it, and the logging out method, multiple times)

I have the project set up on Visual Studio, please let me know how I can debug this. I'm not sure how to attach the Visual Studio debugger, or at least see debug log output somewhere.

VelocityRa commented 2 years ago

Oh nice, can just paste the debug build files to MusicBee's Plugin's folder and attach VS to the MusicBee process, the VS debugger then fully works.

Edit: Just saw you have a postbuild task to copy the files, but I guess it silently failed for me because I have the MusicBee Store version so the path is wrong.

VelocityRa commented 2 years ago
Trace: Failed connection to discord-ipc-7. The operation has timed out.
Trace: Tried to close a already closed pipe.
(more such spam)

hmm

VelocityRa commented 2 years ago

Figured it out, the issue was a zombie DiscordPTB.exe process that I had to kill via Task Manager (wasn't visible in the taskbar).

VelocityRa commented 2 years ago

Btw, it works for me with BetterDiscord too now (including album covers), not sure what exactly the issue before was. There's still the issue of many minute delay though, need pre-uploading to fix that.

sll552 commented 2 years ago

Great that it works for you now.

To shine a little light on why it might not have worked before and after clearing leveldb etc.:

It seems like the login token that is required for uploading the covers is not always written to the leveldb or at least not always in a readable form (as the parsing is really janky at best). That's why it might not always work. So the best thing you can try is to delete the db and try again. I guess the success rate is about 80% as during the course of testing it did happen to me once.

VelocityRa commented 2 years ago

Yup, makes sense, thanks.

Sleepdealr commented 2 years ago

Having this same issue :/ The leveldb and login with user+pass fixed presence not appearing sometimes. But I just can't get the album art to work.

All I get is this error every so often. Still happens after manually killing/restarting discord, VelocityRa's fix didn't help.

1/15/2022 11:55:02 AM - 10.0.22000.0 - 3.4.7805.33439D - System.AggregateException: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: authToken
   at MusicBeePlugin.DiscordTools.AssetManager..ctor(String authToken, String discordAppId)
   at MusicBeePlugin.DiscordTools.DiscordClient.<AssetManagerInit>d__18.MoveNext()
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.ArgumentNullException: Value cannot be null.
Parameter name: authToken
   at MusicBeePlugin.DiscordTools.AssetManager..ctor(String authToken, String discordAppId)
   at MusicBeePlugin.DiscordTools.DiscordClient.<AssetManagerInit>d__18.MoveNext()<---

Using: DiscordCanary Powercord MusicBee v3.4.7805 (No plugins except discordbee) Latest discordbee v2.0.2

VelocityRa commented 2 years ago

@Sleepdealr Can you confirm that nothing is uploaded in https://discord.com/developers/applications Rich Presence -> Art Assets?

Sleepdealr commented 2 years ago

@VelocityRa Yeah, nothing shows up there

VelocityRa commented 2 years ago

I've noticed sometimes it randomly stops working for me too so try again some other time maybe.

DevrajDln commented 2 years ago

I have a solution in order to manually upload files when they are not automatically uploaded:

  1. Go to a website such as https://www.base64encode.org and upload the album cover (scroll to the bottom).
  2. Download the encoded file and copy all of the text in the file.
  3. Go to a website such as http://onlinemd5.com
  4. Paste the encoded text into the website.
  5. Copy the resulting string hash.
  6. Go to the Discord Developer Portal, and navigate to the Assets page for your application used for MusicBee.
  7. Upload the file for the album cover.
  8. Paste the string hash you got earlier as the name of the file when it has been uploaded to the webpage.
  9. Now it should all work properly. If this isn't the case, try restarting both MusicBee and Discord, and wait for a few minutes until it starts working.
sll552 commented 2 years ago

It is now broken for everyone wondering, please see #119

VelocityRa commented 2 years ago

@DevrajDln Cool.

Steps 1 through 4 can be done quickly with this CyberChef recipe: https://gchq.github.io/CyberChef/#recipe=To_Base64('A-Za-z0-9%2B/%3D')MD5() Just drag the image in the Input panel on the top right.

Kiwaof commented 2 years ago

I have the same issue, so before this is fixed, is there any way to add/upload just one image to show for all songs?