mirror of
https://github.com/Mastermindzh/tidal-hifi.git
synced 2024-11-22 13:32:42 +01:00
Add switch case for Video/Song
This commit is contained in:
parent
cac5db123f
commit
7a30b125ec
@ -15,6 +15,7 @@ let currentPlayStatus = statuses.paused;
|
||||
let barvalue;
|
||||
let updatecurrent = false;
|
||||
let oldcurrent;
|
||||
let currentURL = undefined;
|
||||
|
||||
const elements = {
|
||||
play: '*[data-test="play"]',
|
||||
@ -22,7 +23,7 @@ const elements = {
|
||||
next: '*[data-test="next"]',
|
||||
previous: 'button[data-test="previous"]',
|
||||
title: '*[data-test^="footer-track-title"]',
|
||||
artists: '*[data-test^="grid-item-detail-text-title-artist"]',
|
||||
artists: '*[class^="elemental__text elemental__text css-oxcos"]',
|
||||
home: '*[data-test="menu--home"]',
|
||||
back: '[class^="backwardButton"]',
|
||||
forward: '[class^="forwardButton"]',
|
||||
@ -249,7 +250,7 @@ function updateMediaInfo(options, notify) {
|
||||
*/
|
||||
setInterval(function () {
|
||||
const title = elements.getText("title");
|
||||
const url = elements.get("url").href.replace(/[^0-9]/g, "");
|
||||
//const id = elements.get("url").href.replace(/[^0-9]/g, "");
|
||||
const artists = elements.getText("artists");
|
||||
const current = elements.getText("current");
|
||||
const duration = elements.getText("duration");
|
||||
@ -260,7 +261,7 @@ setInterval(function () {
|
||||
title,
|
||||
message: artists,
|
||||
status: currentStatus,
|
||||
url: `https://tidal.com/browse/track/${url}`,
|
||||
url: currentURL,
|
||||
current: current,
|
||||
duration: duration,
|
||||
};
|
||||
@ -283,6 +284,17 @@ setInterval(function () {
|
||||
updatecurrent = true;
|
||||
}
|
||||
|
||||
// Video/Song check if it's a video return URL as undefined due to it not having an id.
|
||||
switch(elements.get("url")) {
|
||||
case null:
|
||||
currentURL = undefined;
|
||||
break;
|
||||
default:
|
||||
const id = elements.get("url").href.replace(/[^0-9]/g, "");
|
||||
currentURL = `https://tidal.com/browse/track/${id}`;
|
||||
break;
|
||||
}
|
||||
|
||||
if(updatecurrent) {
|
||||
if(options.current == oldcurrent && currentStatus != "paused") return;
|
||||
oldcurrent = options.current;
|
||||
|
Loading…
Reference in New Issue
Block a user