From d6f63ac560a1b2e02fc7f19cb55e3de3a62242b9 Mon Sep 17 00:00:00 2001 From: Mastermindzh Date: Sun, 30 May 2021 15:40:27 +0200 Subject: [PATCH] fixed artists retrieval, removed arch build steps --- CHANGELOG.md | 9 +++++ build/linux/arch/.SRCINFO | 20 ----------- build/linux/arch/PKGBUILD | 56 ----------------------------- build/linux/arch/install.sh | 18 ---------- build/linux/arch/tidal-hifi.desktop | 13 ------- package.json | 2 +- src/preload.js | 26 ++++++++++---- src/scripts/discord.js | 10 +++--- 8 files changed, 36 insertions(+), 118 deletions(-) delete mode 100644 build/linux/arch/.SRCINFO delete mode 100644 build/linux/arch/PKGBUILD delete mode 100644 build/linux/arch/install.sh delete mode 100644 build/linux/arch/tidal-hifi.desktop diff --git a/CHANGELOG.md b/CHANGELOG.md index f15f8e100..13881d853 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 2.2.1 + +- artists is now gotten specifically from the footer. This fixes the [unknown artists bug](https://github.com/Mastermindzh/tidal-hifi/issues/45). +- the discord module will check whether the artists is empty and if so substitute it with a default message. This is to prevent sending an empty state to Discord (which it doesn't support). fixes [#45](https://github.com/Mastermindzh/tidal-hifi/issues/54) + +### removed arch build details from source control + +moved to: [https://github.com/Mastermindzh/tidal-hifi-aur](https://github.com/Mastermindzh/tidal-hifi-aur) + ## 2.2.0 - The discord integration now adds a time remaining field based on the song duration diff --git a/build/linux/arch/.SRCINFO b/build/linux/arch/.SRCINFO deleted file mode 100644 index 1483db780..000000000 --- a/build/linux/arch/.SRCINFO +++ /dev/null @@ -1,20 +0,0 @@ -pkgbase = tidal-hifi-git - pkgdesc = The web version of listen.tidal.com running in electron with hifi support thanks to widevine. - pkgver = 2.1.1 - pkgrel = 1 - url = https://github.com/Mastermindzh/tidal-hifi - arch = x86_64 - license = custom:MIT - makedepends = npm - makedepends = git - depends = libxss - depends = nss - depends = gtk3 - provides = tidal-hifi - source = https://github.com/Mastermindzh/tidal-hifi/archive/2.1.1.zip - source = tidal-hifi.desktop - sha512sums = 510c94d9db8573103ee900dcd75b0416ea06ea62af7ed21818d2a5a77ab009a2737c852e7e20b97f846e14b07754a9e5a36ac5b9d0cd0a2a8d0aff3bbc75e622 - sha512sums = 35f38ac308b871c1822d7f6f760f2fb54c3748cf769822cb0f0dfb90f0f5754ba9316da5e903a0d2e9839de3a43ec76f238f3f2e44021956fa1da19142081349 - -pkgname = tidal-hifi-git - diff --git a/build/linux/arch/PKGBUILD b/build/linux/arch/PKGBUILD deleted file mode 100644 index 0853b984b..000000000 --- a/build/linux/arch/PKGBUILD +++ /dev/null @@ -1,56 +0,0 @@ -# Maintainer: Rick van Lieshout - -_pkgname=tidal-hifi -pkgname="$_pkgname-git" -pkgver=2.1.1 -pkgrel=1 -pkgdesc="The web version of listen.tidal.com running in electron with hifi support thanks to widevine." -arch=("x86_64") -url="https://github.com/Mastermindzh/tidal-hifi" -license=("custom:MIT") - -depends=("libxss" "nss" "gtk3") -makedepends=("npm" "git") -provides=("$_pkgname") - -source=("https://github.com/Mastermindzh/tidal-hifi/archive/$pkgver.zip" - "${_pkgname}.desktop") -sha512sums=('510c94d9db8573103ee900dcd75b0416ea06ea62af7ed21818d2a5a77ab009a2737c852e7e20b97f846e14b07754a9e5a36ac5b9d0cd0a2a8d0aff3bbc75e622' - '35f38ac308b871c1822d7f6f760f2fb54c3748cf769822cb0f0dfb90f0f5754ba9316da5e903a0d2e9839de3a43ec76f238f3f2e44021956fa1da19142081349') - -cdToPkg(){ - cd "tidal-hifi-$pkgver" -} - -prepare() { - cdToPkg - - # install build dependencies - npm install -} - -build() { - cdToPkg - - # We are not using the systems Electron as we need castlab's Electron. - npm run build-arch -} - -package() { - cdToPkg - - install -d "${pkgdir}/opt/${_pkgname}/" "${pkgdir}/usr/bin" "${pkgdir}/usr/share/doc" "${pkgdir}/usr/share/licenses" - - cp -r dist/linux-unpacked/* "${pkgdir}/opt/${_pkgname}/" - chmod +x "${pkgdir}/opt/${_pkgname}/${_pkgname}" - - ln -s "/opt/${_pkgname}/${_pkgname}" "${pkgdir}/usr/bin/${_pkgname}" - - install -Dm 644 "build/icon.png" "${pkgdir}/usr/share/pixmaps/${_pkgname}.png" - install -Dm 644 "${srcdir}/${_pkgname}.desktop" "${pkgdir}/usr/share/applications/${_pkgname}.desktop" - - install -Dm 644 "README.md" "${pkgdir}/usr/share/doc/${pkgname}/README.md" - install -Dm 644 "LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE" - ln -s "/opt/${_pkgname}/LICENSE.electron.txt" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE.electron.txt" - ln -s "/opt/${_pkgname}/LICENSES.chromium.html" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSES.chromium.html" -} diff --git a/build/linux/arch/install.sh b/build/linux/arch/install.sh deleted file mode 100644 index d93625ca8..000000000 --- a/build/linux/arch/install.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -# Will generate a correctly formatted SRCINFO file - -SCRIPT_DIST=".SRCINFO" - -# generate SRCINFO -makepkg --printsrcinfo > $SCRIPT_DIST - -# replace pkgbase with tidal-hifi-git -pkgName="tidal-hifi-git" -sed -i "1s/.*/pkgbase = $pkgName/" $SCRIPT_DIST - -# replace pkgbase with tidal-hifi-git -sed -i '/^pkgname/ d' $SCRIPT_DIST -echo "pkgname = $pkgName" >> $SCRIPT_DIST - -# remove double line breaks and replace with single line breaks -sed -i '/^$/N;/^\n$/D' $SCRIPT_DIST diff --git a/build/linux/arch/tidal-hifi.desktop b/build/linux/arch/tidal-hifi.desktop deleted file mode 100644 index f198d2647..000000000 --- a/build/linux/arch/tidal-hifi.desktop +++ /dev/null @@ -1,13 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Name=tidal-hifi -GenericName=tidal-hifi -Comment=The web version of listen.tidal.com running in electron with hifi support thanks to widevine. -Exec=tidal-hifi %u -Icon=tidal-hifi.png -StartupNotify=true -Terminal=false -Type=Application -Categories=Network;Application;Audio;Video -StartupWMClass=tidal-hifi -X-PulseAudio-Properties=media.role=music diff --git a/package.json b/package.json index c01e40ca8..c97c3c97a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tidal-hifi", - "version": "2.2.0", + "version": "2.2.1", "description": "Tidal on Electron with widevine(hifi) support", "main": "src/main.js", "scripts": { diff --git a/src/preload.js b/src/preload.js index ed1f846d7..ef7854f7e 100644 --- a/src/preload.js +++ b/src/preload.js @@ -23,7 +23,7 @@ const elements = { next: '*[data-test="next"]', previous: 'button[data-test="previous"]', title: '*[data-test^="footer-track-title"]', - artists: '*[class^="elemental__text elemental__text css-oxcos"]', + artists: '*[data-test^="grid-item-detail-text-title-artist"]', home: '*[data-test="menu--home"]', back: '[class^="backwardButton"]', forward: '[class^="forwardButton"]', @@ -38,6 +38,7 @@ const elements = { current: '*[data-test="current-time"]', duration: '*[data-test="duration-time"]', bar: '*[data-test="progress-bar"]', + footer: "#footerPlayer", /** * Get an element from the dom @@ -63,6 +64,19 @@ const elements = { return ""; }, + getArtists: function () { + const footer = this.get("footer"); + + if (footer) { + const artists = footer.querySelector(this["artists"]); + if (artists) { + return artists.innerText; + } + } + + return "unknown artist(s)"; + }, + /** * Shorthand function to get the text of a dom element * @param {*} key key in elements object to fetch @@ -266,7 +280,7 @@ function updateURL() { */ setInterval(function () { const title = elements.getText("title"); - const artists = elements.getText("artists"); + const artists = elements.getArtists(); const current = elements.getText("current"); const duration = elements.getText("duration"); const progressBarcurrentTime = elements.get("bar").getAttribute("aria-valuenow"); @@ -293,21 +307,21 @@ setInterval(function () { currentPlayStatus = currentStatus; // check progress bar value and make sure current stays up to date after switch - if(progressBarTime != progressBarcurrentTime && !titleOrArtistChanged) { + if (progressBarTime != progressBarcurrentTime && !titleOrArtistChanged) { progressBarTime = progressBarcurrentTime; currentTime = options.current; options.duration = duration; currentTimeChanged = true; } - if(currentTimeChanged) { - if(options.current == currentTime && currentStatus != "paused") return; + if (currentTimeChanged) { + if (options.current == currentTime && currentStatus != "paused") return; currentTime = options.current; currentTimeChanged = false; } // make sure current is set to 0 if title changes - if(titleOrArtistChanged) { + if (titleOrArtistChanged) { options.current = "0:00"; currentTime = options.current; progressBarTime = progressBarcurrentTime; diff --git a/src/scripts/discord.js b/src/scripts/discord.js index aae5ca650..668a0100b 100644 --- a/src/scripts/discord.js +++ b/src/scripts/discord.js @@ -6,8 +6,8 @@ const mediaInfoModule = require("./mediaInfo"); const discordModule = []; function timeToSeconds(timeArray) { - let minutes = (timeArray[0] * 1); - let seconds = (minutes * 60) + (timeArray[1] * 1); + let minutes = timeArray[0] * 1; + let seconds = minutes * 60 + timeArray[1] * 1; return seconds; } @@ -19,14 +19,16 @@ const observer = (event, arg) => { const currentSeconds = timeToSeconds(mediaInfoModule.mediaInfo.current.split(":")); const durationSeconds = timeToSeconds(mediaInfoModule.mediaInfo.duration.split(":")); const date = new Date(); - const now = date.getTime() / 1000 | 0; + const now = (date.getTime() / 1000) | 0; const remaining = date.setSeconds(date.getSeconds() + (durationSeconds - currentSeconds)); if (mediaInfoModule.mediaInfo.url) { rpc.setActivity({ ...idleStatus, ...{ details: `Listening to ${mediaInfoModule.mediaInfo.title}`, - state: mediaInfoModule.mediaInfo.artist, + state: mediaInfoModule.mediaInfo.artist + ? mediaInfoModule.mediaInfo.artist + : "unknown artist(s)", startTimestamp: parseInt(now), endTimestamp: parseInt(remaining), buttons: [{ label: "Play on Tidal", url: mediaInfoModule.mediaInfo.url }],