Merge pull request #331 from Mastermindzh/feature/electron-28-and-like-api-call

5.8.0
This commit is contained in:
Rick van Lieshout 2024-01-07 16:01:17 +01:00 committed by GitHub
commit 5bd28913da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 1310 additions and 2409 deletions

View File

@ -5,6 +5,9 @@
"extends": [ "extends": [
"stylelint-config-standard-scss" "stylelint-config-standard-scss"
], ],
"ignoreFiles": [
"src/themes/**.scss"
],
"rules": { "rules": {
"prettier/prettier": true, "prettier/prettier": true,
"scss/at-extend-no-missing-placeholder": null, "scss/at-extend-no-missing-placeholder": null,

View File

@ -4,6 +4,22 @@ 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/), 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). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [5.8.0]
- Updated Electron to 28.1.1 (fixes [325](https://github.com/Mastermindzh/tidal-hifi/issues/325))
- Updated dependencies to latest
- added theme files to stylelint ignore
- fixed other stylelint errors
- Added functionality to favorite a song (fixes [#323](https://github.com/Mastermindzh/tidal-hifi/issues/323))
- Added a hotkey to favorite ("Add to collection") songs: Control+a
- Added the "favorite" field in the `mediaInfo` and the API `/current` endpoint
- Added an endpoint to toggle favoriting a song: `http://localhost:47836/favorite/toggle`
- Fixed wrong "end time stamp" for currently playing song (fixes [#282](https://github.com/Mastermindzh/tidal-hifi/issues/282))
- Affected the API + all integrations
- As requested we also added toggle to sync the timestamps to Discord (default = true)
## [5.7.1] ## [5.7.1]
- Fixed mpris not being set up correctly due to capitalization of the instance name. - Fixed mpris not being set up correctly due to capitalization of the instance name.

View File

@ -1,7 +1,7 @@
appId: com.rickvanlieshout.tidal-hifi appId: com.rickvanlieshout.tidal-hifi
electronVersion: 24.1.2 electronVersion: 28.1.1
electronDownload: electronDownload:
version: 24.1.2+wvcus version: 28.1.1+wvcus
mirror: https://github.com/castlabs/electron-releases/releases/download/v mirror: https://github.com/castlabs/electron-releases/releases/download/v
snap: snap:
plugs: plugs:

3554
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,13 @@
{ {
"name": "tidal-hifi", "name": "tidal-hifi",
"version": "5.7.1", "version": "5.8.0",
"description": "Tidal on Electron with widevine(hifi) support", "description": "Tidal on Electron with widevine(hifi) support",
"main": "ts-dist/main.js", "main": "ts-dist/main.js",
"scripts": { "scripts": {
"start": "electron --inspect=0.0.0.0:5858 .", "start": "electron --inspect=0.0.0.0:5858 .",
"watchStart": "nodemon dist -x \"npm run start\"", "watchStart": "nodemon dist -x \"npm run start\"",
"compile": "tsc && npm run sass-and-copy", "compile": "tsc && npm run sass-and-copy",
"deps": "npm run watch",
"watch": "tsc-watch --onSuccess \"npm run sass-and-copy\"", "watch": "tsc-watch --onSuccess \"npm run sass-and-copy\"",
"copy-files": "copyfiles -u 1 --exclude './src/**/*.ts' --exclude './src/**/*.scss' \"./src/**/*\" ts-dist", "copy-files": "copyfiles -u 1 --exclude './src/**/*.ts' --exclude './src/**/*.scss' \"./src/**/*\" ts-dist",
"copy-themes-dev": "copyfiles -u 1 \"./themes/*\" node_modules/electron/dist/resources", "copy-themes-dev": "copyfiles -u 1 \"./themes/*\" node_modules/electron/dist/resources",
@ -38,38 +39,38 @@
"homepage": "https://github.com/Mastermindzh/tidal-hifi", "homepage": "https://github.com/Mastermindzh/tidal-hifi",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@electron/remote": "^2.1.0", "@electron/remote": "^2.1.1",
"axios": "^1.6.4", "axios": "^1.6.5",
"discord-rpc": "^4.0.1", "discord-rpc": "^4.0.1",
"electron-store": "^8.1.0", "electron-store": "^8.1.0",
"express": "^4.18.2", "express": "^4.18.2",
"hotkeys-js": "^3.12.1", "hotkeys-js": "^3.13.3",
"mpris-service": "^2.1.2", "mpris-service": "^2.1.2",
"request": "^2.88.2", "request": "^2.88.2",
"sass": "^1.69.5" "sass": "^1.69.7"
}, },
"devDependencies": { "devDependencies": {
"@mastermindzh/prettier-config": "^1.0.0", "@mastermindzh/prettier-config": "^1.0.0",
"@types/discord-rpc": "^4.0.5", "@types/discord-rpc": "^4.0.8",
"@types/express": "^4.17.17", "@types/express": "^4.17.21",
"@types/node": "^20.4.4", "@types/node": "^20.10.6",
"@types/request": "^2.48.8", "@types/request": "^2.48.12",
"@typescript-eslint/eslint-plugin": "^6.1.0", "@typescript-eslint/eslint-plugin": "^6.18.0",
"@typescript-eslint/parser": "^6.1.0", "@typescript-eslint/parser": "^6.18.0",
"copyfiles": "^2.4.1", "copyfiles": "^2.4.1",
"electron": "git+https://github.com/castlabs/electron-releases.git#v24.1.2+wvcus", "electron": "git+https://github.com/castlabs/electron-releases#v28.1.1+wvcus",
"electron-builder": "^24.4.0", "electron-builder": "^24.9.1",
"eslint": "^8.45.0", "eslint": "^8.56.0",
"js-yaml": "^4.1.0", "js-yaml": "^4.1.0",
"markdown-toc": "^1.2.0", "markdown-toc": "^1.2.0",
"nodemon": "^3.0.1", "nodemon": "^3.0.2",
"prettier": "^3.0.0", "prettier": "^3.1.1",
"stylelint": "^15.10.2", "stylelint": "^16.1.0",
"stylelint-config-standard": "^34.0.0", "stylelint-config-standard": "^36.0.0",
"stylelint-config-standard-scss": "^10.0.0", "stylelint-config-standard-scss": "^13.0.0",
"stylelint-prettier": "^4.0.0", "stylelint-prettier": "^5.0.0",
"tsc-watch": "^6.0.4", "tsc-watch": "^6.0.4",
"typescript": "^5.1.6" "typescript": "^5.3.3"
}, },
"prettier": "@mastermindzh/prettier-config" "prettier": "@mastermindzh/prettier-config"
} }

View File

@ -16,11 +16,12 @@
search: '[class^="searchField"]', search: '[class^="searchField"]',
shuffle: '*[data-test="shuffle"]', shuffle: '*[data-test="shuffle"]',
repeat: '*[data-test="repeat"]', repeat: '*[data-test="repeat"]',
account: '*[data-test^="profile-image-button"]', account: '*[class^="profileOptions"]',
settings: '*[data-test^="open-settings"]',
media: '*[data-test="current-media-imagery"]', media: '*[data-test="current-media-imagery"]',
image: "img", image: "img",
current: '*[data-test="current-time"]', current: '*[data-test="current-time"]',
duration: '*[data-test="duration"]', duration: '*[class^=playbackControlsContainer] *[data-test="duration"]',
bar: '*[data-test="progress-bar"]', bar: '*[data-test="progress-bar"]',
footer: "#footerPlayer", footer: "#footerPlayer",
mediaItem: "[data-type='mediaItem']", mediaItem: "[data-type='mediaItem']",
@ -29,6 +30,7 @@
album_name_cell: '[class^="album"]', album_name_cell: '[class^="album"]',
tracklist_row: '[data-test="tracklist-row"]', tracklist_row: '[data-test="tracklist-row"]',
volume: '*[data-test="volume"]', volume: '*[data-test="volume"]',
favorite: '*[data-test="footer-favorite-button"]',
}; };
let results = []; let results = [];

View File

@ -12,4 +12,5 @@ export const globalEvents = {
error: "error", error: "error",
whip: "whip", whip: "whip",
log: "log", log: "log",
toggleFavorite: "toggleFavorite",
}; };

View File

@ -23,6 +23,7 @@ export const settings = {
discord: { discord: {
detailsPrefix: "discord.detailsPrefix", detailsPrefix: "discord.detailsPrefix",
buttonText: "discord.buttonText", buttonText: "discord.buttonText",
includeTimestamps: "discord.includeTimestamps",
}, },
ListenBrainz: { ListenBrainz: {
root: "ListenBrainz", root: "ListenBrainz",

View File

@ -10,4 +10,5 @@ export interface MediaInfo {
current: string; current: string;
duration: string; duration: string;
image: string; image: string;
favorite: boolean;
} }

View File

@ -9,4 +9,5 @@ export interface Options {
"app-name": string; "app-name": string;
image: string; image: string;
icon: string; icon: string;
favorite: boolean;
} }

View File

@ -48,6 +48,7 @@ let adBlock: HTMLInputElement,
listenbrainz_delay: HTMLInputElement, listenbrainz_delay: HTMLInputElement,
enableWaylandSupport: HTMLInputElement, enableWaylandSupport: HTMLInputElement,
discord_details_prefix: HTMLInputElement, discord_details_prefix: HTMLInputElement,
discord_include_timestamps: HTMLInputElement,
discord_button_text: HTMLInputElement; discord_button_text: HTMLInputElement;
addCustomCss(app); addCustomCss(app);
@ -135,6 +136,7 @@ function refreshSettings() {
ListenBrainzToken.value = settingsStore.get(settings.ListenBrainz.token); ListenBrainzToken.value = settingsStore.get(settings.ListenBrainz.token);
listenbrainz_delay.value = settingsStore.get(settings.ListenBrainz.delay); listenbrainz_delay.value = settingsStore.get(settings.ListenBrainz.delay);
discord_details_prefix.value = settingsStore.get(settings.discord.detailsPrefix); discord_details_prefix.value = settingsStore.get(settings.discord.detailsPrefix);
discord_include_timestamps.checked = settingsStore.get(settings.discord.includeTimestamps);
discord_button_text.value = settingsStore.get(settings.discord.buttonText); discord_button_text.value = settingsStore.get(settings.discord.buttonText);
// set state of all switches with additional settings // set state of all switches with additional settings
@ -246,6 +248,7 @@ window.addEventListener("DOMContentLoaded", () => {
ListenBrainzAPI = get("ListenBrainzAPI"); ListenBrainzAPI = get("ListenBrainzAPI");
ListenBrainzToken = get("ListenBrainzToken"); ListenBrainzToken = get("ListenBrainzToken");
discord_details_prefix = get("discord_details_prefix"); discord_details_prefix = get("discord_details_prefix");
discord_include_timestamps = get("discord_include_timestamps");
listenbrainz_delay = get("listenbrainz_delay"); listenbrainz_delay = get("listenbrainz_delay");
discord_button_text = get("discord_button_text"); discord_button_text = get("discord_button_text");
@ -280,5 +283,6 @@ window.addEventListener("DOMContentLoaded", () => {
addInputListener(ListenBrainzToken, settings.ListenBrainz.token); addInputListener(ListenBrainzToken, settings.ListenBrainz.token);
addInputListener(listenbrainz_delay, settings.ListenBrainz.delay); addInputListener(listenbrainz_delay, settings.ListenBrainz.delay);
addInputListener(discord_details_prefix, settings.discord.detailsPrefix); addInputListener(discord_details_prefix, settings.discord.detailsPrefix);
addInputListener(discord_include_timestamps, settings.discord.includeTimestamps);
addInputListener(discord_button_text, settings.discord.buttonText); addInputListener(discord_button_text, settings.discord.buttonText);
}); });

View File

@ -216,6 +216,17 @@
</label> </label>
</div> </div>
<div id="discord_options"> <div id="discord_options">
<div class="group__option" class="hidden">
<div class="group__description">
<h4>Include timestamps</h4>
<p>Show current/end playtime in the Discord client</p>
</div>
<label class="switch">
<input id="discord_include_timestamps" type="checkbox" />
<span class="switch__slider"></span>
</label>
</div>
<div class="group__option" class="hidden"> <div class="group__option" class="hidden">
<div class="group__description"> <div class="group__description">
<h4>Details prefix</h4> <h4>Details prefix</h4>
@ -389,7 +400,7 @@
<img alt="tidal icon" class="about-section__icon" src="./icon.png" /> <img alt="tidal icon" class="about-section__icon" src="./icon.png" />
<h4>TIDAL Hi-Fi</h4> <h4>TIDAL Hi-Fi</h4>
<div class="about-section__version"> <div class="about-section__version">
<a href="">5.7.1</a> <a href="https://github.com/Mastermindzh/tidal-hifi/releases/tag/5.8.0">5.8.0</a>
</div> </div>
<div class="about-section__links"> <div class="about-section__links">
<a href="https://github.com/mastermindzh/tidal-hifi/" class="about-section__button">Github <i <a href="https://github.com/mastermindzh/tidal-hifi/" class="about-section__button">Github <i

View File

@ -323,16 +323,19 @@ html {
max-width: 500px; max-width: 500px;
margin: -15px auto 0; margin: -15px auto 0;
} }
&__table { &__table {
width: 120px; width: 120px;
margin: 0 auto 0; margin: 0 auto;
td { td {
text-align: left; text-align: left;
} }
} }
&__version { &__version {
margin: -10px 0px 30px 0px; margin: -10px 0 30px;
a { a {
background-color: $tidal-grey-darker; background-color: $tidal-grey-darker;
border: none; border: none;
@ -349,6 +352,7 @@ html {
&__links { &__links {
width: 300px; width: 300px;
margin: 0 auto; margin: 0 auto;
a { a {
border-radius: 10px; border-radius: 10px;
border: none; border: none;
@ -418,10 +422,11 @@ html {
align-items: center; align-items: center;
width: 100%; width: 100%;
max-width: 100%; max-width: 100%;
padding: 25px 0 25px 0px; padding: 25px 0;
border: 1px dashed $tidal-grey; border: 1px dashed $tidal-grey;
border-radius: 3px; border-radius: 3px;
transition: 0.2s; transition: 0.2s;
&.is-active { &.is-active {
background-color: $black; background-color: $black;
} }
@ -459,6 +464,7 @@ html {
width: 100%; width: 100%;
cursor: pointer; cursor: pointer;
opacity: 0; opacity: 0;
&:focus { &:focus {
outline: none; outline: none;
} }

View File

@ -45,7 +45,7 @@ const elements = {
media: '*[data-test="current-media-imagery"]', media: '*[data-test="current-media-imagery"]',
image: "img", image: "img",
current: '*[data-test="current-time"]', current: '*[data-test="current-time"]',
duration: '*[data-test="duration"]', duration: '*[class^=playbackControlsContainer] *[data-test="duration"]',
bar: '*[data-test="progress-bar"]', bar: '*[data-test="progress-bar"]',
footer: "#footerPlayer", footer: "#footerPlayer",
mediaItem: "[data-type='mediaItem']", mediaItem: "[data-type='mediaItem']",
@ -54,6 +54,7 @@ const elements = {
album_name_cell: '[class^="album"]', album_name_cell: '[class^="album"]',
tracklist_row: '[data-test="tracklist-row"]', tracklist_row: '[data-test="tracklist-row"]',
volume: '*[data-test="volume"]', volume: '*[data-test="volume"]',
favorite: '*[data-test="footer-favorite-button"]',
/** /**
* Get an element from the dom * Get an element from the dom
* @param {*} key key in elements object to fetch * @param {*} key key in elements object to fetch
@ -131,6 +132,10 @@ const elements = {
return this.get("volume").getAttribute("aria-checked") === "false"; // it's muted if aria-checked is false return this.get("volume").getAttribute("aria-checked") === "false"; // it's muted if aria-checked is false
}, },
isFavorite: function () {
return this.get("favorite").getAttribute("aria-checked") === "true";
},
/** /**
* Shorthand function to get the text of a dom element * Shorthand function to get the text of a dom element
* @param {*} key key in elements object to fetch * @param {*} key key in elements object to fetch
@ -208,6 +213,10 @@ function addHotKeys() {
handleLogout(); handleLogout();
}); });
addHotkey("Control+a", function () {
elements.click("favorite");
});
addHotkey("Control+h", function () { addHotkey("Control+h", function () {
elements.click("home"); elements.click("home");
}); });
@ -306,6 +315,9 @@ function addIPCEventListeners() {
case globalEvents.pause: case globalEvents.pause:
elements.click("pause"); elements.click("pause");
break; break;
case globalEvents.toggleFavorite:
elements.click("favorite");
break;
default: default:
break; break;
} }
@ -516,6 +528,7 @@ setInterval(function () {
"app-name": appName, "app-name": appName,
image: "", image: "",
icon: "", icon: "",
favorite: elements.isFavorite(),
}; };
const titleOrArtistsChanged = currentSong !== songDashArtistTitle; const titleOrArtistsChanged = currentSong !== songDashArtistTitle;

View File

@ -30,30 +30,38 @@ const observer = () => {
settingsStore.get<string, string>(settings.discord.detailsPrefix) ?? "Listening to "; settingsStore.get<string, string>(settings.discord.detailsPrefix) ?? "Listening to ";
const buttonText = const buttonText =
settingsStore.get<string, string>(settings.discord.buttonText) ?? "Play on TIDAL"; settingsStore.get<string, string>(settings.discord.buttonText) ?? "Play on TIDAL";
const includeTimestamps =
settingsStore.get<string, boolean>(settings.discord.includeTimestamps) ?? true;
let activity = {
...idleStatus,
...{
startTimestamp: includeTimestamps ? now : undefined,
endTimestamp: includeTimestamps ? remaining : undefined,
},
};
if (mediaInfo.url) { if (mediaInfo.url) {
rpc.setActivity({ activity = {
...idleStatus, ...activity,
...{ ...{
details: `${detailsPrefix}${mediaInfo.title}`, details: `${detailsPrefix}${mediaInfo.title}`,
state: mediaInfo.artists ? mediaInfo.artists : "unknown artist(s)", state: mediaInfo.artists ? mediaInfo.artists : "unknown artist(s)",
startTimestamp: now,
endTimestamp: remaining,
largeImageKey: mediaInfo.image, largeImageKey: mediaInfo.image,
largeImageText: mediaInfo.album ? mediaInfo.album : `${idleStatus.largeImageText}`, largeImageText: mediaInfo.album ? mediaInfo.album : `${idleStatus.largeImageText}`,
buttons: [{ label: buttonText, url: mediaInfo.url }], buttons: [{ label: buttonText, url: mediaInfo.url }],
}, },
}); };
} else { } else {
rpc.setActivity({ activity = {
...idleStatus, ...activity,
...{ ...{
details: `Watching ${mediaInfo.title}`, details: `Watching ${mediaInfo.title}`,
state: mediaInfo.artists, state: mediaInfo.artists,
startTimestamp: now,
endTimestamp: remaining,
}, },
}); };
} }
rpc.setActivity(activity);
} }
}; };

View File

@ -40,6 +40,9 @@ export const startExpress = (mainWindow: BrowserWindow) => {
if (settingsStore.get(settings.playBackControl)) { if (settingsStore.get(settings.playBackControl)) {
expressApp.get("/play", (req, res) => handleGlobalEvent(res, globalEvents.play)); expressApp.get("/play", (req, res) => handleGlobalEvent(res, globalEvents.play));
expressApp.post("/favorite/toggle", (req, res) =>
handleGlobalEvent(res, globalEvents.toggleFavorite)
);
expressApp.get("/pause", (req, res) => handleGlobalEvent(res, globalEvents.pause)); expressApp.get("/pause", (req, res) => handleGlobalEvent(res, globalEvents.pause));
expressApp.get("/next", (req, res) => handleGlobalEvent(res, globalEvents.next)); expressApp.get("/next", (req, res) => handleGlobalEvent(res, globalEvents.next));
expressApp.get("/previous", (req, res) => handleGlobalEvent(res, globalEvents.previous)); expressApp.get("/previous", (req, res) => handleGlobalEvent(res, globalEvents.previous));

View File

@ -11,6 +11,7 @@ export const mediaInfo = {
current: "", current: "",
duration: "", duration: "",
image: "tidal-hifi-icon", image: "tidal-hifi-icon",
favorite: false,
}; };
export const updateMediaInfo = (arg: MediaInfo) => { export const updateMediaInfo = (arg: MediaInfo) => {
@ -23,6 +24,7 @@ export const updateMediaInfo = (arg: MediaInfo) => {
mediaInfo.current = propOrDefault(arg.current); mediaInfo.current = propOrDefault(arg.current);
mediaInfo.duration = propOrDefault(arg.duration); mediaInfo.duration = propOrDefault(arg.duration);
mediaInfo.image = propOrDefault(arg.image); mediaInfo.image = propOrDefault(arg.image);
mediaInfo.favorite = arg.favorite;
}; };
/** /**

View File

@ -21,6 +21,7 @@ export const settingsStore = new Store({
discord: { discord: {
detailsPrefix: "Listening to ", detailsPrefix: "Listening to ",
buttonText: "Play on Tidal", buttonText: "Play on Tidal",
includeTimestamps: true,
}, },
ListenBrainz: { ListenBrainz: {
enabled: false, enabled: false,
@ -61,6 +62,13 @@ export const settingsStore = new Store({
migrationStore.get(settings.ListenBrainz.delay) ?? 5000 migrationStore.get(settings.ListenBrainz.delay) ?? 5000
); );
}, },
"5.8.0": (migrationStore) => {
console.log("running migrations for 5.8.0");
migrationStore.set(
settings.discord.includeTimestamps,
migrationStore.get(settings.discord.includeTimestamps) ?? true
);
},
}, },
}); });