feat: added the ability to skip artists automatically. Takes precedence over muting. fixes #175

This commit is contained in:
Rick van Lieshout 2023-01-22 21:18:20 +01:00
parent 0620d87d8b
commit c0d9cd2834
7 changed files with 43 additions and 2 deletions

View File

@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Move the quit command from the system sub-menu to the main menu - Move the quit command from the system sub-menu to the main menu
- Added single click focus/show on the tray icon - Added single click focus/show on the tray icon
- Doesn't work on all platforms. Nothing I can do about that unfortunately! - Doesn't work on all platforms. Nothing I can do about that unfortunately!
- Added a list of artists to automatically skip.
- I don't like the vast majority of dutch music so I added one of them to my list to test: [./docs/no-dutch-music.mp4](./docs/no-dutch-music.mp4)
## 4.3.1 ## 4.3.1

BIN
docs/no-dutch-music.mp4 Normal file

Binary file not shown.

View File

@ -15,6 +15,8 @@ const settings = {
playBackControl: "playBackControl", playBackControl: "playBackControl",
muteArtists: "muteArtists", muteArtists: "muteArtists",
mutedArtists: "mutedArtists", mutedArtists: "mutedArtists",
skipArtists: "skipArtists",
skippedArtists: "skippedArtists",
disableBackgroundThrottle: "disableBackgroundThrottle", disableBackgroundThrottle: "disableBackgroundThrottle",
apiSettings: { apiSettings: {
root: "apiSettings", root: "apiSettings",

View File

@ -4,12 +4,14 @@ let trayIcon,
enableCustomHotkeys, enableCustomHotkeys,
enableDiscord, enableDiscord,
muteArtists, muteArtists,
skipArtists,
notifications, notifications,
playBackControl, playBackControl,
api, api,
port, port,
menuBar, menuBar,
mutedArtists, mutedArtists,
skippedArtists,
disableBackgroundThrottle, disableBackgroundThrottle,
singleInstance, singleInstance,
disableHardwareMediaKeys, disableHardwareMediaKeys,
@ -36,6 +38,8 @@ function refreshSettings() {
minimizeOnClose.checked = store.get(settings.minimizeOnClose); minimizeOnClose.checked = store.get(settings.minimizeOnClose);
muteArtists.checked = store.get(settings.muteArtists); muteArtists.checked = store.get(settings.muteArtists);
mutedArtists.value = store.get(settings.mutedArtists).join("\n"); mutedArtists.value = store.get(settings.mutedArtists).join("\n");
skipArtists.checked = store.get(settings.skipArtists);
skippedArtists.value = store.get(settings.skippedArtists).join("\n");
singleInstance.checked = store.get(settings.singleInstance); singleInstance.checked = store.get(settings.singleInstance);
disableHardwareMediaKeys.checked = store.get(settings.flags.disableHardwareMediaKeys); disableHardwareMediaKeys.checked = store.get(settings.flags.disableHardwareMediaKeys);
gpuRasterization.checked = store.get(settings.flags.gpuRasterization); gpuRasterization.checked = store.get(settings.flags.gpuRasterization);
@ -119,6 +123,8 @@ window.addEventListener("DOMContentLoaded", () => {
enableDiscord = get("enableDiscord"); enableDiscord = get("enableDiscord");
muteArtists = get("muteArtists"); muteArtists = get("muteArtists");
mutedArtists = get("mutedArtists"); mutedArtists = get("mutedArtists");
skipArtists = get("skipArtists");
skippedArtists = get("skippedArtists");
disableBackgroundThrottle = get("disableBackgroundThrottle"); disableBackgroundThrottle = get("disableBackgroundThrottle");
singleInstance = get("singleInstance"); singleInstance = get("singleInstance");
disableHardwareMediaKeys = get("disableHardwareMediaKeys"); disableHardwareMediaKeys = get("disableHardwareMediaKeys");
@ -138,6 +144,8 @@ window.addEventListener("DOMContentLoaded", () => {
addInputListener(minimizeOnClose, settings.minimizeOnClose); addInputListener(minimizeOnClose, settings.minimizeOnClose);
addInputListener(muteArtists, settings.muteArtists); addInputListener(muteArtists, settings.muteArtists);
addTextAreaListener(mutedArtists, settings.mutedArtists); addTextAreaListener(mutedArtists, settings.mutedArtists);
addInputListener(skipArtists, settings.skipArtists);
addTextAreaListener(skippedArtists, settings.skippedArtists);
addInputListener(disableBackgroundThrottle, settings.disableBackgroundThrottle); addInputListener(disableBackgroundThrottle, settings.disableBackgroundThrottle);
addInputListener(singleInstance, settings.singleInstance); addInputListener(singleInstance, settings.singleInstance);
addInputListener(disableHardwareMediaKeys, settings.flags.disableHardwareMediaKeys); addInputListener(disableHardwareMediaKeys, settings.flags.disableHardwareMediaKeys);

View File

@ -63,6 +63,18 @@
</label> </label>
</div> </div>
<textarea id="mutedArtists" class="textarea" cols="40" rows="5" spellcheck="false"></textarea> <textarea id="mutedArtists" class="textarea" cols="40" rows="5" spellcheck="false"></textarea>
<div class="group__option">
<div class="group__description">
<h4>Skip Artists automatically</h4>
<p>The following list of artists (1 per line) will be skipped automatically.</p>
</div>
<label class="switch">
<input id="skipArtists" type="checkbox">
<span class="switch__slider"></span>
</label>
</div>
<textarea id="skippedArtists" class="textarea" cols="40" rows="5" spellcheck="false"></textarea>
</div> </div>
<div class="group"> <div class="group">
<p class="group__title">UI</p> <p class="group__title">UI</p>

View File

@ -7,6 +7,7 @@ const { downloadFile } = require("./scripts/download");
const statuses = require("./constants/statuses"); const statuses = require("./constants/statuses");
const hotkeys = require("./scripts/hotkeys"); const hotkeys = require("./scripts/hotkeys");
const globalEvents = require("./constants/globalEvents"); const globalEvents = require("./constants/globalEvents");
const { skipArtists } = require("./constants/settings");
const notificationPath = `${app.getPath("userData")}/notification.jpg`; const notificationPath = `${app.getPath("userData")}/notification.jpg`;
const appName = "Tidal Hifi"; const appName = "Tidal Hifi";
let currentSong = ""; let currentSong = "";
@ -327,7 +328,8 @@ function getTrackURL() {
setInterval(function () { setInterval(function () {
const title = elements.getText("title"); const title = elements.getText("title");
const artists = elements.getArtists(); const artists = elements.getArtists();
muteArtistIfFoundInMutedArtistsList(); // doing this here so that nothing can possibly fail before we call this function skipArtistsIfFoundInSkippedArtistsList(artists);
muteArtistIfFoundInMutedArtistsList(artists); // doing this here so that nothing can possibly fail before we call this function
const album = elements.getAlbumName(); const album = elements.getAlbumName();
const current = elements.getText("current"); const current = elements.getText("current");
@ -382,7 +384,7 @@ setInterval(function () {
/** /**
* Checks whether the current artist is included in the "muted artists" list and if so it will automatically mute the player * Checks whether the current artist is included in the "muted artists" list and if so it will automatically mute the player
*/ */
function muteArtistIfFoundInMutedArtistsList() { function muteArtistIfFoundInMutedArtistsList(artists) {
if (store.get(settings.muteArtists)) { if (store.get(settings.muteArtists)) {
const mutedArtists = store.get(settings.mutedArtists); const mutedArtists = store.get(settings.mutedArtists);
if (mutedArtists.find((artist) => artist === artists) !== undefined) { if (mutedArtists.find((artist) => artist === artists) !== undefined) {
@ -396,6 +398,19 @@ setInterval(function () {
} }
} }
} }
/**
* automatically skip a song if the artists are found in the list of artists to skip
* @param {*} artists list of artists to skip
*/
function skipArtistsIfFoundInSkippedArtistsList(artists) {
if (store.get(skipArtists)) {
const skippedArtists = store.get(settings.skippedArtists);
if (skippedArtists.find((artist) => artist === artists) !== undefined) {
elements.click("next");
}
}
}
}, 1000); }, 1000);
if (process.platform === "linux" && store.get(settings.mpris)) { if (process.platform === "linux" && store.get(settings.mpris)) {

View File

@ -12,6 +12,8 @@ const store = new Store({
playBackControl: true, playBackControl: true,
muteArtists: false, muteArtists: false,
mutedArtists: ["TIDAL"], mutedArtists: ["TIDAL"],
skipArtists: false,
skippedArtists: [""],
disableBackgroundThrottle: true, disableBackgroundThrottle: true,
menuBar: true, menuBar: true,
apiSettings: { apiSettings: {