Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


upmpdcli Tidal plugin
#1
TO NEW READERS - there's still work being done on the upmpdcli Tidal plugin. The first few posts in this thread are interesting, perhaps, but skip to my post #14 to find the current procedure for getting the plugin working in moOde.
_______________________________________________________________________________________________

@Tim Curtis 
@GioF_71 

[I'm placing this thread here rather than in the Test Team section so that Gio can see it too.]

So starting over, I was able to bring up the latest Tidal plugin code in moOde 9.0.6 through the following steps.

1. on the moOde player, install the necessary Python3 tidalapi module which is not included in the upmpdcli distro nor, apparently, in Raspberry Pi debs.


Code:
sudo python3 -m pip install tidalapi==0.7.6 --break-system-packages

Note: The --break-system-packages option was necessary because I was forcing the installation of a non-Debian-packaged Python package "system wide". Debian wants me to install it in a virtual environment instead, but I was too lazy to explore this with the moOde/mpd/upmpdcli lashup.

-----

2. replace the existing upmpdcli-1.8.12 Tidal plugin code in the moOde player with the same code in latest upmpdcli sources (upmpdcli-1.8.16.tar.gz ATM)

Code:
# get the tarball to my home directory on my moOde player
cd
wget https://www.lesbonscomptes.com/upmpdcli/downloads/upmpdcli-1.8.16.tar.gz

# extract just the subdirectory containing the tidal plugin code
tar xf upmpdcli-1.8.16.tar.gz upmpdcli-1.8.16/src/mediaserver/cdplugins/tidal

# park the existing tidal subdirectory out of harm's way
sudo mv /usr/share/upmpdcli/cdplugins/tidal /usr/share/upmpdcli/tidal.dist

# copy over the new code
sudo cp -r upmpdcli-1.8.16/src/mediaserver/cdplugins/tidal /usr/share/upmpdcli/cdplugins/

Notes: 
1. If I were smarter I'd know how to extract the needed subdirectory without bringing along the full path
2. I parked the existing code one level above the cdplugins directory so upmpdcli didn't interpret it as another plugin; could have stashed it in a tar or zip file somewhere else, or just deleted it for good.

-----

3. get Tidal credentials for this player. Here we have a choice of OAUTH2 or PKCE authentication (see upmpcli: Tidal). For the following, I've chosen to seek PKCE authentication so I can play Hi-Res files (up to 24bit/192kHz it says somewhere). OAUTH2 authentication apparently limits us to 24bit/48kHz. Doesn't matter to my aging ears but why not go for gold?

Code:
sudo python3 /usr/share/upmpdcli/cdplugins/tidal/get_credentials.py -t PKCE -f /var/cache/upmpdcli/tidal/pkce.credentials.json

At a glance, the output of this command seems intimidating

Code:
Credentials will be written to [/var/cache/upmpdcli/tidal/pkce.credentials.json]
Authentication type is [PKCE]
Keep existing pkce file: [False]
READ CAREFULLY!
---------------
You need to open this link and login with your username and password. Afterwards you will be redirected to an 'Oops' page. To complete the login you must copy the URL from this 'Oops' page and paste it to the input field.
https://login.tidal.com/authorize?response_type=code&redirect_uri=https%3A%2F%2Ftidal.com%2Fandroid%2Flogin%2Fauth&client_id=...&lang=EN&appMode=android&client_unique_key=...
Paste 'Ooops' page URL here and press <ENTER>:

where I have deleted the info relating to my account.

As it says, open the link in your browser and log into your Tidal account. A new 'Ooops' page will appear; paste the URL of that page into the command line and hit enter. Done and dusted. 

OAUTH2 authentication is somewhat different (see the aforementioned link) but still entails a conversation with your browser.

-----

4. edit the /etc/upmpdcli.conf file to uncomment the tidaluser line. Don't bother changing the default value 'tidal' to something else. No need to enter Tidal credentials in this file because they've just been stored in the cache.

-----

5. go to the Renderers config screen in the moOde player's webUI and enable (or restart) the UPnP renderer.
ETA - this enables both the existing UPnP Media Renderer that moOde already had, as it did before, and also the UPnP MediaServer we just configured.

Should be good to go. 

ATM I'm listening to a Tidal playlist of classical selections. According to moOde's audio info, these tracks are FLAC files coming in at 24bit/96kHz. According to the upmpdcli docs, with PKCE authentication we dealing with MPEG-DASH streams. How that's all being handled behind the screen is above my pay grade.

If this doesn't work, hit me up. I've been known to make a mistake from time to time Big Grin

As an aside, I don't use UPnP daily so I can't answer to issues relating to the behavior of the moOdeUI when playing Tidal/Qobuz/local Media Server tracks, nor to issues relating to the behavior of various third-party UPnP control points. (ATM I'm using mconnectLite on my iPad but I've used others on my Android phone.)

As another aside, at first I set out to build an up-to-date upmpcli deb ala the moOde build recipes but I screwed up somewhere. Kept running into an undefined symbol error (this with upmpdcli-1.8.13.tar.gz a few days ago; suppose I should try again with 1.8.16). 

Regards,
Kent
Reply
#2
Hello, thank you for the nice write-up.
Just a small correction. When creating the PKCE authentication file, the resulting file should be named "pkce.credentials.json", so the command line should be:


Code:
sudo python3 /usr/share/upmpdcli/cdplugins/tidal/get_credentials.py -t PKCE -f /var/cache/upmpdcli/tidal/pkce.credentials.json


while when using OAUTH2 (default for -t) the file should be "/var/cache/upmpdcli/tidal/credentials.json" so:


Code:
sudo python3 /usr/share/upmpdcli/cdplugins/tidal/get_credentials.py -f /var/cache/upmpdcli/tidal/credentials.json


The plugin examines those files and creates the session choosing the best available option. If pkce.credentials.json is available, a pkce session is created, otherwise it falls back to the regular credentials.json file and an oauth2 session will be created.
A good Last.fm scrobbler solution for Moode here, docker image here
Reply
#3
(08-21-2024, 12:12 AM)GioF_71 Wrote: while when using OAUTH2 (default for -t) the file should be "/var/cache/upmpdcli/tidal/pkce.credentials.json" so:

I think this is a copy-paste typo... ;-)
Reply
#4
It is indeed... I will correct later!
A good Last.fm scrobbler solution for Moode here, docker image here
Reply
#5
Hello, a quick update (you might have seen this already).
Things are going to get simpler for the Tidal plugin, see here, thanks to tehkillerbee.
I already have a working version of the plugin running and I will prepare a release soon.
Of course, the Tidal account will always be a requirement (should go without saying), but the authentication scheme will be only one, and we will be back to the original one (1-step).
A good Last.fm scrobbler solution for Moode here, docker image here
Reply
#6
(09-18-2024, 07:56 PM)GioF_71 Wrote: Hello, a quick update (you might have seen this already).
Things are going to get simpler for the Tidal plugin, see here, thanks to tehkillerbee.
I already have a working version of the plugin running and I will prepare a release soon.
Of course, the Tidal account will always be a requirement (should go without saying), but the authentication scheme will be only one, and we will be back to the original one (1-step).

Thanks. I’ll wait for your release.

Regards,
Kent
Reply
#7
good morning,
with 9.1.0 I tried this starting with 3. (get credentials), first trying OAUTH2 (also with the alternative of editing upmpdcli.conf as instructed) and then PKCE. No error messages but login fails.
Are steps 1. and 2. necassary to get this to work with 9.1.0?
Reply
#8
@Snoil

I haven’t had time to revisit this topic recently. Some of the initial steps may not be necessary now but I was waiting for a new release of the underlying code when real life overtook me. Maybe I can have a look this weekend.

Regards,
Kent
Reply
#9
(09-26-2024, 10:58 AM)Snoil Wrote: good morning,
with 9.1.0 I tried this starting with 3. (get credentials), first trying OAUTH2 (also with the alternative of editing upmpdcli.conf as instructed) and then PKCE. No error messages but login fails.
Are steps 1. and 2. necassary to get this to work with 9.1.0?

Hello, can you provide:

1) upmpdcli.conf
2) listing of /var/cache/upmpdcli/cache/tidal, especially .json files (don't post the contents, just the file names)
3) applications logs

Thank you
A good Last.fm scrobbler solution for Moode here, docker image here
Reply
#10
Code:
...
# Tidal streaming service parameters

# Bogus user name variable.
tidaluser = tidal
# Oath2 authentication token type.
# tidaltokentype = Bearer
# Access Token.
# tidalaccesstoken = yJraWQi......
# Refresh Token.
# tidalrefreshtoken = eyJraWQi....
# Token expiry time.
# tidalexpirytime = 1727939714.900032
# PKCE authentication token type.
#tidalpkcetokentype = Bearer
# PKCE Access Token.
#tidalpkceaccesstoken = your_pkce_access_token
# PKCE Refresh Token.
#tidalpkcerefreshtoken = your_pkce_refresh_token
# PKCE Session id
#tidalpkcesessionid = your_pkce_session_id
# Tidal maximum stream quality.
#tidalaudioquality = LOSSLESS
# Plugin Title.
#tidaltitle = Tidal
# Use item numbers in album lists for kodi compatibility
#tidalprependnumberinitemlist = 0
# Enables tidal image caching
#tidalimagecaching = 0
# Tidal search limit, set to 15 items by default
#tidalsearchlimit = 15
...
2) /var/cache/upmpdcli does not contain a 'cache' folder it seems.
3) I'm not sure what logs you mean

thank you
Reply


Forum Jump: