Closed clean-sys closed 3 years ago
I have also looked into adding artworks. However, I couldn't find a way how to dynamically upload them to Discord. Can you describe how to solve this or point me to a website?
I think we can merge this feature into the master branch when ready, but keep it disabled by default. Instead, we allow the user to enter authentication details into a config file, which will then enable it. I'd like to place this file in '%localappdata%/Discord-RPC-TIDAL/config.json'. Also, this file should be easily accessible through a button in the tray menu. I can take care of the config part.
I'm doing this through the assets endpoint in the Discord API. (https://discordapp.com/api/oauth2/applications/{app-id}/assets) Depending on the request it can delete, get the asset-list or upload an asset if the authorization header is filled.
You get the asset list by just doing a simple get request to it and it returns a json of all the assets that are currently uploaded. I just end up doing a .contains on the string it returns for the "SanizitizedAlbumName".
To upload an image you can do a POST as application/json and pass through
The name of your asset, ["name"]
Type (1 or 2 but i haven't found 2 ever used or found out what it was.), ["type"]
Your full Base64 encoded image. ["image"]
To delete an asset you do a delete request to https://discordapp.com/api/oauth2/applications/{app-id}/assets/{asset-id}
Album names need to be "sanitized" or free of most symbols, in the process i also force lowercase for the album name. I "sanitize" the name by passing it through a regex of @"[!@#$%^&*()+=\'[\""{\]};:<>|./?,\s-]"
and replace any matches with an underscore.
I also slightly changed the search function at Line 85
To: var searchResult = await Client.Search(LoginKey, newSong, 1000, 0, eType.SEARCH);
(Provided me more accurate results when searching for a song most of the times, and even though 1000 is the max i never really realized a slowdown.)
I also have a repo that does basically the same task, just for musicbee.
Thank you for your detailed explanation. This is exactly what I was looking for. Let me know, where I can help.
There's one thing that is still missing, which is the deletion of assets when there is no space left. I will look into this in the coming days.
If you have improvement ideas, let me know :)
The replacement of assets when no more space is available is now fully implemented in the form of LRU (Least Recently Used).
First off, thanks for making this RPC enabler for Tidal. I really like the look of it by default but thought it would look a little better with artworks (which it does). Utilizes Discord's asset system of course which has a limit but they've recently upped it to 300 which is enough for me.
This probably wouldn't be able to merge into master because of a couple reasons:
Still would probably be cool to have it in its own branch for people that want the feature, let me know if you're interested.