Skip to content

Commit

Permalink
fixed artists retrieval, removed arch build steps
Browse files Browse the repository at this point in the history
  • Loading branch information
Mastermindzh committed May 30, 2021
1 parent d34ddfe commit d6f63ac
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 118 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 0 additions & 20 deletions build/linux/arch/.SRCINFO

This file was deleted.

56 changes: 0 additions & 56 deletions build/linux/arch/PKGBUILD

This file was deleted.

18 changes: 0 additions & 18 deletions build/linux/arch/install.sh

This file was deleted.

13 changes: 0 additions & 13 deletions build/linux/arch/tidal-hifi.desktop

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
26 changes: 20 additions & 6 deletions src/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"]',
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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");
Expand All @@ -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;
Expand Down
10 changes: 6 additions & 4 deletions src/scripts/discord.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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 }],
Expand Down

0 comments on commit d6f63ac

Please sign in to comment.