mirror of
https://github.com/Mastermindzh/tidal-hifi.git
synced 2024-11-22 21:42:46 +01:00
Merge pull request #219 from thanasistrisp/artists
[Bug]: get multiple artists instead of a single one
This commit is contained in:
commit
3d2a9c3992
@ -65,16 +65,29 @@ const elements = {
|
|||||||
return "";
|
return "";
|
||||||
},
|
},
|
||||||
|
|
||||||
getArtists: function () {
|
/**
|
||||||
|
* returns an array of all artists in the current song
|
||||||
|
* @returns {Array} artists
|
||||||
|
*/
|
||||||
|
getArtistsArray: function () {
|
||||||
const footer = this.get("footer");
|
const footer = this.get("footer");
|
||||||
|
|
||||||
if (footer) {
|
if (footer) {
|
||||||
const artists = footer.querySelector(this["artists"]);
|
const artists = footer.querySelectorAll(this.artists);
|
||||||
if (artists) {
|
if (artists)
|
||||||
return artists.innerText;
|
return Array.from(artists).map((artist) => artist.textContent);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return [];
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* unify the artists array into a string separated by commas
|
||||||
|
* @param {Array} artistsArray
|
||||||
|
* @returns {String} artists
|
||||||
|
*/
|
||||||
|
getArtistsString: function (artistsArray) {
|
||||||
|
if (artistsArray.length > 0)
|
||||||
|
return artistsArray.join(", ");
|
||||||
return "unknown artist(s)";
|
return "unknown artist(s)";
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -332,17 +345,18 @@ function getTrackID() {
|
|||||||
*/
|
*/
|
||||||
setInterval(function () {
|
setInterval(function () {
|
||||||
const title = elements.getText("title");
|
const title = elements.getText("title");
|
||||||
const artists = elements.getArtists();
|
const artistsArray = elements.getArtistsArray();
|
||||||
skipArtistsIfFoundInSkippedArtistsList(artists);
|
const artistsString = elements.getArtistsString(artistsArray);
|
||||||
|
skipArtistsIfFoundInSkippedArtistsList(artistsArray);
|
||||||
|
|
||||||
const album = elements.getAlbumName();
|
const album = elements.getAlbumName();
|
||||||
const current = elements.getText("current");
|
const current = elements.getText("current");
|
||||||
const duration = elements.getText("duration");
|
const duration = elements.getText("duration");
|
||||||
const songDashArtistTitle = `${title} - ${artists}`;
|
const songDashArtistTitle = `${title} - ${artistsString}`;
|
||||||
const currentStatus = getCurrentlyPlayingStatus();
|
const currentStatus = getCurrentlyPlayingStatus();
|
||||||
const options = {
|
const options = {
|
||||||
title,
|
title,
|
||||||
message: artists,
|
message: artistsString,
|
||||||
album: album,
|
album: album,
|
||||||
status: currentStatus,
|
status: currentStatus,
|
||||||
url: getTrackURL(),
|
url: getTrackURL(),
|
||||||
@ -387,16 +401,21 @@ setInterval(function () {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* automatically skip a song if the artists are found in the list of artists to skip
|
* automatically skip a song if the artists are found in the list of artists to skip
|
||||||
* @param {*} artists list of artists to skip
|
* @param {*} artists array of artists
|
||||||
*/
|
*/
|
||||||
function skipArtistsIfFoundInSkippedArtistsList(artists) {
|
function skipArtistsIfFoundInSkippedArtistsList(artists) {
|
||||||
if (store.get(skipArtists)) {
|
if (store.get(skipArtists)) {
|
||||||
const skippedArtists = store.get(settings.skippedArtists);
|
const skippedArtists = store.get(settings.skippedArtists);
|
||||||
if (skippedArtists.find((artist) => artist === artists) !== undefined) {
|
if (skippedArtists.length > 0) {
|
||||||
|
const artistsToSkip = skippedArtists.map((artist) => artist);
|
||||||
|
const artistNames = Object.values(artists).map((artist) => artist);
|
||||||
|
const foundArtist = artistNames.some((artist) => artistsToSkip.includes(artist));
|
||||||
|
if (foundArtist) {
|
||||||
elements.click("next");
|
elements.click("next");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}, 100);
|
}, 100);
|
||||||
|
|
||||||
if (process.platform === "linux" && store.get(settings.mpris)) {
|
if (process.platform === "linux" && store.get(settings.mpris)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user