Giter Club home page Giter Club logo

nowplaying-for-tidal's Introduction

Better Alternative Out There

I decided to archive this repository. The approach I am using is quite brittle towards future changes from TIDAL's side and does in fact not work currently (#7). I recommend to use https://github.com/Mastermindzh/tidal-hifi instead, which extracts the required information about the currently playing song directly from the DOM.

It was fun working on this and being exposed to the open-source community for the first time so thanks to everybody who interacted with this repository in any way.

NowPlaying-for-TIDAL

Lightweight app that aims to imitate Spotify's Now Playing feature in Discord using Game Activity. This project is neither created nor supported by Discord or TIDAL.

Feel free to make suggestions or report bugs.

Screenshots

Discord Profile Small

Discord Profile Full

Installation Instructions

This application only runs under Windows and requires .NET 5.0.

You can find an installer under releases. The installer will create a StartMenu and Autostart entry. The program shows an icon in the taskbar that allows you to temporarily disable it.

This application runs in your task bar, if you wish to temporarily disable or close it, you can find those options in the tray icon's menu.

Instructions for Album Artwork

This feature is disabled by default because Discord has a limit of 300 asset slots. Due to that, everyone has to create his own Discord Application.

Head over to the Discord Developer Portal's Application Page and create an application. The name you choose will later be visible in your status like so: Playing <application name>. I chose Music on TIDAL which will then show up as Playing Music on TIDAL.

Copy the Application ID from the General Information page and insert it into this program's config file. You can find the config file by right clicking on the tray menu icon.

The last thing we need is an authentication token, so that Discord knows it's you, the owner of the application, who is uploading the album artworks. To attain this token, again, make sure that you are on Discord Developer Portal's Application Page. Open the developer tools of your webbrowser. You can typically accomplish this by pressing Ctrl+Shift+I. Switch to the Network or Network analysis tab. Now click on something, e.g., your newly created Discord application, to trigger a load on the webpage. Some HTTP requests will now appear in the Developer Tools window. In these, search for any request containing a request header called Authorization. When found, copy it's value to this program's config. The final result will look something like this:

{
  "DiscordAppId": "633539288744553243",
  "DiscordMfaToken": "BHNoagHMUUxSg63Rx5NuJHcU.dpPUny.owfVRsszxtzAHmTztKaccQ2jm9S"
}

Implementation Details

My goal was to create a clean, lightweight and easily extensible app.

Currently, the window title is used to retrieve the playing song's title and artist(s). Those information are then sent to Discord using Lachee/discord-rpc-csharp.

In order to retrieve the currently playing song's timecode, I am reading the variable in TIDAL's memory which stores this information. This ensures, that the timecode shown in Discord is always in sync.

How do we get the address of this variable? I am using a similar process to what you would do in Cheat Engine: Do a first scan when the song starts and then rescan using an approximation of the real value (assumption: playback wasn't interrupted) until there is only one address left. To be able to do that programatically and in general read TIDAL's memory, I use Squalr/Squalr.Engine.Scanning.

Since the address has to be found first, there is a slight delay before the timecode is shown in Discord.

Using the earlier attained song's title and artist(s), we can now query TIDAL's API for information about the track. The authentication token needed to interact with TIDAL's API is read from the TIDAL desktop app's log files. However, this token can expire. If you experience that the Play on TIDAL button is no longer visible, simply restart the desktop app and the token will be renewed.

We have now attained an URL pointing to the track and an URL pointing to its album artwork. We can use latter to upload the artwork as an asset to our Discord Application. Due to caching, it takes roughly 15 mins before an uploaded asset becomes usable.

If the space is full, we need to delete an asset first. This asset is chosen using the LRU strategy (Least Recently Used). However, for LRU to work, we need to track when an artwork has been used the last time. This information is stored in DiscordAssets.json.

Big Thanks to maybeclean for teaching me how to manage Discord Application Assets and providing a base implementation of the album artwok feature. Details can be found in this issue.

nowplaying-for-tidal's People

Contributors

jonas-kaufmann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

nowplaying-for-tidal's Issues

DiscordMfaToken

The Header of "Authorization" doesn't exist anymore and if you refresh on the page it automatically signs you off. So album artwork isn't possible anymore.

Better artwork implementation

When I had Windows on my PC I was using this app and it worked great. Only problem: you have to wait for artworks. So I switched to Linux. On Linux there is no official client so I found tidal-hifi which is basically a custom client for Linux. This client has a Discord RPC plugin baked in the client and I was confused on why artworks were working instantly.

So I figured out it somehow uses a URL as the artwork instead of constantly uploading artworks as assets. The image URL loaded on discord looks like this https://media.discordapp.net/external/c78dDCeR1nLDcfVlaxW7s1AzhrdPqhOIbIxjtv0zJw8/https/resources.tidal.com/images/99baaa31/52a0/40ee/a8d0/4525fb5f8a02/640x640.jpg (basically a proxy for the artwork image). As far as I understand if you just set the largeImageKey to an image url, it just works. I haven't tested this, I just wanted to drop this here in case it can improve the app.

Album Artwork Handling

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:

  • 300 asset slots would go out quick being a public app-id
  • Requiring an authorization token for Discord to authenticate and accept your upload request

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.

Showcase

Not uploading artwork

Hey, it seems that the artwork functionality is broken? I am 100% sure that I set up everything correctly since the tidal asset has been successfully uploaded and it's getting used whenever I play something, but none of the album artworks ever get uploaded.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.