Skip to content

Commit

Permalink
Prepare custom image for next-tidal
Browse files Browse the repository at this point in the history
  • Loading branch information
GioF71 committed Oct 28, 2024
1 parent 625cf53 commit 52ff142
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 69 deletions.
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,10 @@ ENV SUBSONIC_ENABLE_INTERNET_RADIOS=""

ENV TIDAL_ENABLE=""
ENV TIDAL_TITLE=""
ENV TIDAL_AUTH_CHALLENGE_TYPE=""
ENV TIDAL_AUDIO_QUALITY=""
ENV TIDAL_PREPEND_NUMBER_IN_ITEM_LIST=""
ENV TIDAL_DOWNLOAD_PLUGIN=""
ENV TIDAL_PLUGIN_BRANCH=""
ENV TIDAL_FORCE_TIDALAPI_VERSION=""

ENV RADIO_PARADISE_ENABLE=""
ENV RADIO_PARADISE_DOWNLOAD_PLUGIN=""
Expand Down
39 changes: 11 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Current version is `1.8.18`.
### Support for HiRes Tidal

Good news, Tidal HiRes is now available.
You need to consider that there is a limitation: only the mpd/upmpdcli combination, as well as gmrender-resurrect, works as a renderer with the Tidal plugin in pkce mode, AFAIK.
You need to consider that there is a limitation: only the mpd/upmpdcli combination and mrender-resurrect work properly as renderers with the Tidal plugin using HI_RES_LOSSLESS quality mode, AFAIK.
A simple installation guide for a mediaserver upmpdcli instance for Tidal Hires is [here](https://github.com/GioF71/audio-tools/blob/main/media-servers/tidal-hires/README.md).

### Subsonic Plugin compatibility
Expand Down Expand Up @@ -254,16 +254,7 @@ PLG_PROXY_METHOD|Proxy method, valid values are `proxy` and `redirect`, defaults
MEDIA_SERVER_FRIENDLY_NAME|Friendly name for the Media Server
TIDAL_ENABLE|Set to `YES` to enable Tidal support, defaults to `no`
TIDAL_TITLE|Set the title for Tidal plugin, defaults to `Tidal`
TIDAL_AUTH_CHALLENGE_TYPE|Default login challenge type, `OAUTH2` (default) or `PKCE`
TIDAL_QUALITY|Possible values are `LOW` (mp3@96k), `HIGH` (mp3@320k), `LOSSLESS` (flac 44.1kHz), `HI_RES` (I believe it's MQA), `HI_RES_LOSSLESS` (flac@hires), defaults to `LOSSLESS`
TIDAL_TOKEN_TYPE|Tidal oauth2 token type
TIDAL_ACCESS_TOKEN|Tidal oauth2 access token
TIDAL_REFRESH_TOKEN|Tidal oauth2 refresh token
TIDAL_EXPIRY_TIME|Tidal oauth2 expiry time
TIDAL_PKCE_TOKEN_TYPE|Tidal pkce token type
TIDAL_PKCE_ACCESS_TOKEN|Tidal pkce access token
TIDAL_PKCE_REFRESH_TOKEN|Tidal pkce refresh token
TIDAL_PKCE_SESSION_ID|Tidal pkce session id
TIDAL_PREPEND_NUMBER_IN_ITEM_LIST|Set to `yes` to create item numbers in lists (`[01] Item` instead of `Item`), mostly for kodi, disabled by default
TIDAL_DOWNLOAD_PLUGIN|If set to `YES`, the updated plugin is downloaded from the upstream repo
TIDAL_PLUGIN_BRANCH|If `TIDAL_DOWNLOAD_PLUGIN`, the branch indicated by this variable will be used. Must be specified if enabling `TIDAL_DOWNLOAD_PLUGIN`. Suggested branch name is `latest-tidal`
Expand Down Expand Up @@ -355,6 +346,8 @@ Refer to the file [radiolist.conf](https://github.com/GioF71/upmpdcli-docker/blo

#### OAUTH2 Mode

##### Create json file

In order to obtain your set of tidal credentials, execute the following command:

```text
Expand All @@ -367,29 +360,19 @@ You will be presented with an output similar to the following prompt:
Visit https://link.tidal.com/XXXXX to log in, the code will expire in 300 seconds
```

Open the link in the browser, login to Tidal and authorize the application. Once that is done, you will be greeted with an output like the following:
Open the link in the browser, login to Tidal and authorize the application. Once that is done, you will be greeted with an output which include the contents of a json file, which should be stored in the tidal plugin cache directory with the name `oauth2.credentials.json`.
Be sure to change the ownership of the copied file according to the uid/gid used to run the upmpdcli container.

```text
Environment variables:
TIDAL_TOKEN_TYPE=Bearer
TIDAL_ACCESS_TOKEN=your-tidal-token
TIDAL_REFRESH_TOKEN=your-refresh-token
TIDAL_EXPIRY_TIME=1694616998.732007
```
##### OAUTH Challenge

The tokens will be very long strings. Those values must be used in your docker-compose file, or, even better, through the separate `.env` file.
With the latest (0.0.8 tagged on 2023-10-10 as latest-tidal) version of the plugin, you can entirely skip the 4 variables listed a few lines above.
If you do so, be sure to monitor the container logs, and follow the Tidal link that will be presented. After you will have granted authorization to the application, the plugin will store a `credentials.json` file in the plugin cache directory. So be sure to use the `/cache` volume, or the credentials won't survire if the container is removed and created again.
With the latest (0.x.x tagged on 202x-xx-xx as latest-tidal) version of the plugin, you can entirely skip the the step before, if you are able to monitor the application logs.
With docker, this should be as easy as using a `docker-compose logs -f`.
Open a control point an try to acccess the Tidal media server. The logs will present a link, and you will have to follow instructions, similarly to what is described in the previous paragraph.
After you will have granted authorization to the application, the plugin will store a `oauth2.credentials.json` file in the plugin cache directory. So be sure to use the `/cache` volume, or the credentials won't survive if the container is removed and created again.
Never share the tokens on the internet (and also on public git repositories).
Remember that currently, the Tidal Plugin actually starts when the first control point (e.g. BubbleUPnP, mConnect) contacts upmpdcli asking for the contents from the Tidal Plugin.
Remember that currently, the Tidal Plugin actually starts when a control point (e.g. BubbleUPnP, mConnect) contacts upmpdcli asking for contents from the Tidal Plugin.
So, you will not see the prompt until you try to use the plugin itself.

#### PKCE Mode

Getting credentials for PKCE mode is slightly different from OAUTH2 mode.
The `challenge` mode, available during while the plugin is running, does not work for pkce mode, because a user input is required, and there is currently no way to make the plugin accept that user input, AFAIK.
So the suggested strategy is described [here](https://github.com/GioF71/audio-tools/blob/main/media-servers/tidal-hires/README.md).

## Usage examples

A few usage examples are available [here](https://github.com/GioF71/upmpdcli-docker/blob/main/doc/example-configurations.md).
Expand Down
2 changes: 1 addition & 1 deletion app/bin/get-tidal-credentials-oauth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def print_setting(name : str, value : str):
if not os.path.exists(file_path):
os.makedirs(file_path)

file_name = f"{file_path}/credentials.json"
file_name = f"{file_path}/oauth2.credentials.json"

session = tidalapi.Session()
# Will run until you visit the printed url and link your account
Expand Down
36 changes: 0 additions & 36 deletions app/bin/run-upmpdcli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -584,42 +584,6 @@ if [[ "${TIDAL_ENABLE^^}" == "YES" ]]; then
TIDAL_AUTOSTART=1
echo "tidalautostart = $TIDAL_AUTOSTART" >> $CONFIG_FILE
fi
if [[ -n "${TIDAL_AUTH_CHALLENGE_TYPE}" ]]; then
echo "Setting Token Type [$TIDAL_AUTH_CHALLENGE_TYPE]"
echo "tidalauthchallengetype = $TIDAL_AUTH_CHALLENGE_TYPE" >> $CONFIG_FILE
fi
if [[ -n "${TIDAL_TOKEN_TYPE}" ]]; then
echo "Setting Token Type [$TIDAL_TOKEN_TYPE]"
echo "tidaltokentype = $TIDAL_TOKEN_TYPE" >> $CONFIG_FILE
fi
if [[ -n "${TIDAL_ACCESS_TOKEN}" ]]; then
echo "Setting Access Token [$TIDAL_ACCESS_TOKEN]"
echo "tidalaccesstoken = $TIDAL_ACCESS_TOKEN" >> $CONFIG_FILE
fi
if [[ -n "${TIDAL_REFRESH_TOKEN}" ]]; then
echo "Setting Refresh Token [$TIDAL_REFRESH_TOKEN]"
echo "tidalrefreshtoken = $TIDAL_REFRESH_TOKEN" >> $CONFIG_FILE
fi
if [[ -n "${TIDAL_EXPIRY_TIME}" ]]; then
echo "Setting Token Expiry Time [$TIDAL_EXPIRY_TIME]"
echo "tidalexpirytime = $TIDAL_EXPIRY_TIME" >> $CONFIG_FILE
fi
if [[ -n "${TIDAL_PKCE_TOKEN_TYPE}" ]]; then
echo "Setting PKCE Token Type [$TIDAL_PKCE_TOKEN_TYPE]"
echo "tidalpkcetokentype = $TIDAL_PKCE_TOKEN_TYPE" >> $CONFIG_FILE
fi
if [[ -n "${TIDAL_PKCE_ACCESS_TOKEN}" ]]; then
echo "Setting PKCE Access Token [$TIDAL_PKCE_ACCESS_TOKEN]"
echo "tidalpkceaccesstoken = $TIDAL_PKCE_ACCESS_TOKEN" >> $CONFIG_FILE
fi
if [[ -n "${TIDAL_PKCE_REFRESH_TOKEN}" ]]; then
echo "Setting PKCE Refresh Token [$TIDAL_PKCE_REFRESH_TOKEN]"
echo "tidalpkcerefreshtoken = $TIDAL_PKCE_REFRESH_TOKEN" >> $CONFIG_FILE
fi
if [[ -n "${TIDAL_PKCE_SESSION_ID}" ]]; then
echo "Setting PKCE Session Id [$TIDAL_PKCE_SESSION_ID]"
echo "tidalpkcesessionid = $TIDAL_PKCE_SESSION_ID" >> $CONFIG_FILE
fi
if [[ -z "$TIDAL_AUDIO_QUALITY" ]]; then
TIDAL_AUDIO_QUALITY="LOSSLESS"
fi
Expand Down
2 changes: 1 addition & 1 deletion app/install/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ if [[ "$BUILD_MODE" == "full" ]]; then
if [ $add_switch -eq 1 ]; then
pip_upgrade="$pip_upgrade --break-system-packages"
fi
python_packages=(pyradios py-sonic subsonic-connector==0.3.2 mutagen rdflib mpegdash tidalapi==0.7.6)
python_packages=(pyradios py-sonic subsonic-connector==0.3.2 mutagen rdflib mpegdash tidalapi==0.8.0)
for pkg in "${python_packages[@]}"
do
echo "Installing ${pkg} with add_switch [$add_switch]..."
Expand Down
2 changes: 1 addition & 1 deletion doc/change-history.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Change Date|Major Changes
2023-11-15|Support different subsonic-connect versions (see issue [#318](https://github.com/GioF71/upmpdcli-docker/issues/318))
2023-11-14|Switch from `lunar` to `mantic` (see issue [#316](https://github.com/GioF71/upmpdcli-docker/issues/316))
2023-11-13|Add tidal package to installation list (see issue [#313](https://github.com/GioF71/upmpdcli-docker/issues/313))
2023-11-04|Add installation of new packages (see issue [#309](https://github.com/GioF71/upmpdcli-docker/issues/309))
2023-11-04|Add installation of new packages (see issue [#309](https://github.com/GioF71/upmpdcli-docker/issues/309))
2023-11-04|Update to Upmpdcli version 1.8.4, first version with new radio plugins (see issue [#305](https://github.com/GioF71/upmpdcli-docker/issues/305))
2023-09-18|Update to Upmpdcli version 1.8.3, first version with new Tidal Plugin (see issue [#282](https://github.com/GioF71/upmpdcli-docker/issues/282))
2023-09-16|Support for upcoming new Tidal Plugin (see issue [#269](https://github.com/GioF71/upmpdcli-docker/issues/269))
Expand Down

0 comments on commit 52ff142

Please sign in to comment.