diff --git a/lidarr/Audio.service.bash b/lidarr/Audio.service.bash index 32a62831..6a185330 100644 --- a/lidarr/Audio.service.bash +++ b/lidarr/Audio.service.bash @@ -1,5 +1,5 @@ #!/usr/bin/with-contenv bash -scriptVersion="2.48" +scriptVersion="2.5" scriptName="Audio" ### Import Settings @@ -71,7 +71,10 @@ verifyConfig () { preferSpecialEditions="true" fi - audioPath="$downloadPath/audio" + audioPath="$downloadPath/audio" + tidalDlNgConfigDir="/config/extended/tidal_dl_ng" + tidalDlNgConfigFile="${tidalDlNgConfigDir}/config.json" + tidalDlNgConfigTemplate="/config/extended/tidal-dl.json" } @@ -101,8 +104,11 @@ Configuration () { - if [ ! -d /config/xdg ]; then - mkdir -p /config/xdg + if [ ! -d /config/extended ]; then + mkdir -p /config/extended + fi + if [ ! -d "$tidalDlNgConfigDir" ]; then + mkdir -p "$tidalDlNgConfigDir" fi if [ -z $topLimit ]; then @@ -206,16 +212,16 @@ DownloadFormat () { if [ "$audioFormat" == "native" ]; then if [ "$audioBitrate" == "master" ]; then - tidalQuality=Master + tidalQuality=HI_RES_LOSSLESS deemixQuality=flac elif [ "$audioBitrate" == "lossless" ]; then - tidalQuality=HiFi + tidalQuality=LOSSLESS deemixQuality=flac elif [ "$audioBitrate" == "high" ]; then - tidalQuality=High + tidalQuality=HIGH deemixQuality=320 elif [ "$audioBitrate" == "low" ]; then - tidalQuality=128 + tidalQuality=LOW deemixQuality=128 else log "ERROR :: Invalid audioFormat and audioBitrate options set..." @@ -229,7 +235,7 @@ DownloadFormat () { else bitrateError="false" audioFormatError="false" - tidalQuality=HiFi + tidalQuality=LOSSLESS deemixQuality=flac case "$audioBitrate" in @@ -269,7 +275,7 @@ DownloadFormat () { exit fi - tidal-dl -q HiFi + XDG_CONFIG_HOME=/config/extended tidal-dl-ng cfg quality_audio LOSSLESS 2>&1 | tee -a "/config/logs/$logFileName" deemixQuality=flac bitrateError="" audioFormatError="" @@ -301,32 +307,36 @@ NotFoundFolderCleaner () { } TidalClientSetup () { - log "TIDAL :: Verifying tidal-dl configuration" - touch /config/xdg/.tidal-dl.log - if [ -f /config/xdg/.tidal-dl.json ]; then - rm /config/xdg/.tidal-dl.json - fi - if [ ! -f /config/xdg/.tidal-dl.json ]; then - log "TIDAL :: No default config found, importing default config \"tidal.json\"" - if [ -f /config/extended/tidal-dl.json ]; then - cp /config/extended/tidal-dl.json /config/xdg/.tidal-dl.json - chmod 777 -R /config/xdg/ + log "TIDAL :: Verifying tidal-dl-ng configuration" + touch "${tidalDlNgConfigDir}/tidal-dl-ng.log" + if [ -f "$tidalDlNgConfigFile" ]; then + rm "$tidalDlNgConfigFile" + fi + if [ ! -f "$tidalDlNgConfigFile" ]; then + log "TIDAL :: No default config found, importing default config \"tidal-dl.json\"" + if [ -f "$tidalDlNgConfigTemplate" ]; then + cp "$tidalDlNgConfigTemplate" "$tidalDlNgConfigFile" + chmod 777 -R "$tidalDlNgConfigDir" fi fi TidaldlStatusCheck - tidal-dl -o "$audioPath"/incomplete 2>&1 | tee -a "/config/logs/$logFileName" DownloadFormat + XDG_CONFIG_HOME=/config/extended tidal-dl-ng cfg download_base_path "$audioPath/incomplete" 2>&1 | tee -a "/config/logs/$logFileName" + XDG_CONFIG_HOME=/config/extended tidal-dl-ng cfg quality_audio "$tidalQuality" 2>&1 | tee -a "/config/logs/$logFileName" + XDG_CONFIG_HOME=/config/extended tidal-dl-ng cfg path_binary_ffmpeg "/usr/bin/ffmpeg" 2>&1 | tee -a "/config/logs/$logFileName" - if [ ! -f /config/xdg/.tidal-dl.token.json ]; then + if ! ls "${tidalDlNgConfigDir}"/*auth*.json "${tidalDlNgConfigDir}"/*token*.json 1>/dev/null 2>&1; then TidaldlStatusCheck - #log "TIDAL :: ERROR :: Downgrade tidal-dl for workaround..." - #pip3 install tidal-dl==2022.3.4.2 --no-cache-dir &>/dev/null log "TIDAL :: ERROR :: Loading client for required authentication, please authenticate, then exit the client..." NotifyWebhook "FatalError" "TIDAL requires authentication, please authenticate now (check logs)" TidaldlStatusCheck - tidal-dl + if command -v script >/dev/null 2>&1; then + script -q -c "PYTHONUNBUFFERED=1 XDG_CONFIG_HOME=/config/extended tidal-dl-ng login" /dev/null + else + PYTHONUNBUFFERED=1 XDG_CONFIG_HOME=/config/extended tidal-dl-ng login + fi fi if [ ! -d /config/extended/cache/tidal ]; then @@ -347,8 +357,6 @@ TidalClientSetup () { fi TidaldlStatusCheck - #log "TIDAL :: Upgrade tidal-dl to newer version..." - #pip3 install tidal-dl==2022.07.06.1 --no-cache-dir &>/dev/null } @@ -356,9 +364,9 @@ TidaldlStatusCheck () { until false do running=no - if ps aux | grep "tidal-dl" | grep -v "grep" | read; then + if ps aux | grep "tidal-dl-ng" | grep -v "grep" | read; then running=yes - log "STATUS :: TIDAL-DL :: BUSY :: Pausing/waiting for all active tidal-dl tasks to end..." + log "STATUS :: TIDAL-DL-NG :: BUSY :: Pausing/waiting for all active tidal-dl-ng tasks to end..." sleep 2 continue fi @@ -367,12 +375,12 @@ TidaldlStatusCheck () { } TidalClientTest () { - log "TIDAL :: tidal-dl client setup verification..." + log "TIDAL :: tidal-dl-ng client setup verification..." i=0 while [ $i -lt 3 ]; do i=$(( $i + 1 )) TidaldlStatusCheck - tidal-dl -q Normal -o "$audioPath"/incomplete -l "$tidalClientTestDownloadId" 2>&1 | tee -a "/config/logs/$logFileName" + XDG_CONFIG_HOME=/config/extended tidal-dl-ng dl "https://tidal.com/browse/album/$tidalClientTestDownloadId" 2>&1 | tee -a "/config/logs/$logFileName" downloadCount=$(find "$audioPath"/incomplete -type f -regex ".*/.*\.\(flac\|opus\|m4a\|mp3\)" | wc -l) if [ $downloadCount -le 0 ]; then continue @@ -382,9 +390,7 @@ TidalClientTest () { done tidalClientTest="unknown" if [ $downloadCount -le 0 ]; then - if [ -f /config/xdg/.tidal-dl.token.json ]; then - rm /config/xdg/.tidal-dl.token.json - fi + rm -f "${tidalDlNgConfigDir}"/*auth*.json "${tidalDlNgConfigDir}"/*token*.json log "TIDAL :: ERROR :: Download failed" log "TIDAL :: ERROR :: You will need to re-authenticate on next script run..." log "TIDAL :: ERROR :: Exiting..." @@ -557,7 +563,9 @@ DownloadProcess () { if [ "$2" == "TIDAL" ]; then TidaldlStatusCheck - tidal-dl -q $tidalQuality -o "$audioPath/incomplete" -l "$1" 2>&1 | tee -a "/config/logs/$logFileName" + XDG_CONFIG_HOME=/config/extended tidal-dl-ng cfg download_base_path "$audioPath/incomplete" 2>&1 | tee -a "/config/logs/$logFileName" + XDG_CONFIG_HOME=/config/extended tidal-dl-ng cfg quality_audio "$tidalQuality" 2>&1 | tee -a "/config/logs/$logFileName" + XDG_CONFIG_HOME=/config/extended tidal-dl-ng dl "https://tidal.com/browse/album/$1" 2>&1 | tee -a "/config/logs/$logFileName" # Verify Client Works... clientTestDlCount=$(find "$audioPath"/incomplete/ -type f -regex ".*/.*\.\(flac\|opus\|m4a\|mp3\)" | wc -l) diff --git a/lidarr/TidalVideoDownloader.bash b/lidarr/TidalVideoDownloader.bash index ae8fb399..fce5f010 100644 --- a/lidarr/TidalVideoDownloader.bash +++ b/lidarr/TidalVideoDownloader.bash @@ -1,5 +1,5 @@ #!/usr/bin/with-contenv bash -scriptVersion="2.1" +scriptVersion="2.2" scriptName="TidalVideoDownloader" #### Import Settings @@ -24,6 +24,9 @@ verifyConfig () { downloadPath="/config/extended/downloads" fi videoDownloadPath="$downloadPath/tidal/videos" + tidalDlNgConfigDir="/config/extended/tidal_dl_ng" + tidalDlNgConfigFile="${tidalDlNgConfigDir}/config.json" + tidalDlNgConfigTemplate="/config/extended/tidal-dl.json" if [ -z "$videoScriptInterval" ]; then videoScriptInterval="15m" fi @@ -45,24 +48,35 @@ verifyConfig () { } TidalClientSetup () { - log "TIDAL :: Verifying tidal-dl configuration" - if [ ! -f /config/xdg/.tidal-dl.json ]; then - log "TIDAL :: No default config found, importing default config \"tidal.json\"" - if [ -f /config/extended/tidal-dl.json ]; then - cp /config/extended/tidal-dl.json /config/xdg/.tidal-dl.json - chmod 777 -R /config/xdg/ + log "TIDAL :: Verifying tidal-dl-ng configuration" + if [ ! -d /config/extended ]; then + mkdir -p /config/extended + fi + if [ ! -d "$tidalDlNgConfigDir" ]; then + mkdir -p "$tidalDlNgConfigDir" + fi + if [ ! -f "$tidalDlNgConfigFile" ]; then + log "TIDAL :: No default config found, importing default config \"tidal-dl.json\"" + if [ -f "$tidalDlNgConfigTemplate" ]; then + cp "$tidalDlNgConfigTemplate" "$tidalDlNgConfigFile" + chmod 777 -R "$tidalDlNgConfigDir" fi fi - - tidal-dl -o "$videoDownloadPath"/incomplete 2>&1 | tee -a "/config/logs/$logFileName" - tidalQuality=HiFi - if [ ! -f /config/xdg/.tidal-dl.token.json ]; then - #log "TIDAL :: ERROR :: Downgrade tidal-dl for workaround..." - #pip3 install tidal-dl==2022.3.4.2 --no-cache-dir &>/dev/null + tidalQuality=LOSSLESS + XDG_CONFIG_HOME=/config/extended tidal-dl-ng cfg download_base_path "$videoDownloadPath/incomplete" 2>&1 | tee -a "/config/logs/$logFileName" + XDG_CONFIG_HOME=/config/extended tidal-dl-ng cfg quality_audio "$tidalQuality" 2>&1 | tee -a "/config/logs/$logFileName" + XDG_CONFIG_HOME=/config/extended tidal-dl-ng cfg quality_video "1080" 2>&1 | tee -a "/config/logs/$logFileName" + XDG_CONFIG_HOME=/config/extended tidal-dl-ng cfg path_binary_ffmpeg "/usr/bin/ffmpeg" 2>&1 | tee -a "/config/logs/$logFileName" + + if ! ls "${tidalDlNgConfigDir}"/*auth*.json "${tidalDlNgConfigDir}"/*token*.json 1>/dev/null 2>&1; then log "TIDAL :: ERROR :: Loading client for required authentication, please authenticate, then exit the client..." NotifyWebhook "FatalError" "TIDAL requires authentication, please authenticate now (check logs)" - tidal-dl 2>&1 | tee -a "/config/logs/$logFileName" + if command -v script >/dev/null 2>&1; then + script -q -c "PYTHONUNBUFFERED=1 XDG_CONFIG_HOME=/config/extended tidal-dl-ng login" /dev/null + else + PYTHONUNBUFFERED=1 XDG_CONFIG_HOME=/config/extended tidal-dl-ng login + fi fi if [ ! -d "$videoDownloadPath/incomplete" ]; then @@ -81,9 +95,9 @@ TidaldlStatusCheck () { until false do running=no - if ps aux | grep "tidal-dl" | grep -v "grep" | read; then + if ps aux | grep "tidal-dl-ng" | grep -v "grep" | read; then running=yes - log "STATUS :: TIDAL-DL :: BUSY :: Pausing/waiting for all active tidal-dl tasks to end..." + log "STATUS :: TIDAL-DL-NG :: BUSY :: Pausing/waiting for all active tidal-dl-ng tasks to end..." sleep 2 continue fi @@ -92,12 +106,12 @@ TidaldlStatusCheck () { } TidalClientTest () { - log "TIDAL :: tidal-dl client setup verification..." + log "TIDAL :: tidal-dl-ng client setup verification..." i=0 while [ $i -lt 3 ]; do i=$(( $i + 1 )) TidaldlStatusCheck - tidal-dl -q Normal -o "$videoDownloadPath"/incomplete -l "$tidalClientTestDownloadId" 2>&1 | tee -a "/config/logs/$logFileName" + XDG_CONFIG_HOME=/config/extended tidal-dl-ng dl "https://tidal.com/browse/album/$tidalClientTestDownloadId" 2>&1 | tee -a "/config/logs/$logFileName" downloadCount=$(find "$videoDownloadPath"/incomplete -type f -regex ".*/.*\.\(flac\|opus\|m4a\|mp3\)" | wc -l) if [ $downloadCount -le 0 ]; then continue @@ -107,9 +121,7 @@ TidalClientTest () { done tidalClientTest="unknown" if [ $downloadCount -le 0 ]; then - if [ -f /config/xdg/.tidal-dl.token.json ]; then - rm /config/xdg/.tidal-dl.token.json - fi + rm -f "${tidalDlNgConfigDir}"/*auth*.json "${tidalDlNgConfigDir}"/*token*.json log "TIDAL :: ERROR :: Download failed" log "TIDAL :: ERROR :: You will need to re-authenticate on next script run..." log "TIDAL :: ERROR :: Exiting..." @@ -339,7 +351,10 @@ VideoProcess () { downloadFailed=false log "$processCount/$lidarrArtistCount :: $lidarrArtistName :: $tidalVideoProcessNumber/$tidalVideoIdsCount :: $videoTitle ($id) :: Downloading..." - tidal-dl -r P1080 -o "$videoDownloadPath/incomplete" -l "$videoUrl" 2>&1 | tee -a "/config/logs/$logFileName" + XDG_CONFIG_HOME=/config/extended tidal-dl-ng cfg download_base_path "$videoDownloadPath/incomplete" 2>&1 | tee -a "/config/logs/$logFileName" + XDG_CONFIG_HOME=/config/extended tidal-dl-ng cfg quality_video "1080" 2>&1 | tee -a "/config/logs/$logFileName" + XDG_CONFIG_HOME=/config/extended tidal-dl-ng cfg path_binary_ffmpeg "/usr/bin/ffmpeg" 2>&1 | tee -a "/config/logs/$logFileName" + XDG_CONFIG_HOME=/config/extended tidal-dl-ng dl "$videoUrl" 2>&1 | tee -a "/config/logs/$logFileName" find "$videoDownloadPath/incomplete" -type f -exec mv "{}" "$videoDownloadPath/incomplete"/ \; find "$videoDownloadPath/incomplete" -mindepth 1 -type d -exec rm -rf "{}" \; &>/dev/null find "$videoDownloadPath/incomplete" -type f -regex ".*/.*\.\(mkv\|mp4\)" -print0 | while IFS= read -r -d '' video; do diff --git a/lidarr/setup.bash b/lidarr/setup.bash index 2658d5d0..4fde61d0 100644 --- a/lidarr/setup.bash +++ b/lidarr/setup.bash @@ -52,7 +52,7 @@ uv pip install --system --upgrade --no-cache-dir --break-system-packages \ pylast \ mutagen \ r128gain \ - tidal-dl \ + tidal-dl-ng \ deemix \ langdetect \ apprise && \ @@ -107,7 +107,7 @@ if [ ! -f /config/extended/deemix_config.json ]; then fi if [ ! -f /config/extended/tidal-dl.json ]; then - echo "Download Tidal config..." + echo "Download Tidal (tidal-dl-ng) config..." curl -sfL "https://raw.githubusercontent.com/RandomNinjaAtk/arr-scripts/main/lidarr/tidal-dl.json" -o /config/extended/tidal-dl.json echo "Done" fi diff --git a/lidarr/tidal-dl.json b/lidarr/tidal-dl.json index c986d6fe..de8f2e23 100644 --- a/lidarr/tidal-dl.json +++ b/lidarr/tidal-dl.json @@ -1 +1,16 @@ -{"albumFolderFormat": "atd", "apiKeyIndex": 4, "audioQuality": "HiFi", "checkExist": true, "downloadPath": "/downloads/lidarr-extended/incomplete", "includeEP": true, "language": "0", "lyricFile": true, "multiThread": false, "saveAlbumInfo": false, "saveCovers": false, "showProgress": true, "showTrackInfo": true, "trackFileFormat": "{TrackNumber} - {TrackTitle}", "usePlaylistFolder": false, "videoFileFormat": "{VideoNumber} - {ArtistName} - {VideoTitle}{ExplicitFlag}", "videoQuality": "P1080"} +{ + "download_base_path": "/downloads/lidarr-extended/incomplete", + "quality_audio": "LOSSLESS", + "quality_video": "1080", + "format_album": "{album_artist}/{album_title} ({album_year})", + "format_track": "{track_number} - {track_title}", + "format_playlist": "{playlist_title}/{track_number} - {track_title}", + "format_mix": "{mix_title}/{track_number} - {track_title}", + "format_video": "{artist_name} - {track_title}", + "path_binary_ffmpeg": "/usr/bin/ffmpeg", + "extract_flac": false, + "save_album_info": false, + "save_covers": false, + "save_lyrics": true, + "hide_progress": false +}