mirror of
https://github.com/Mastermindzh/tidal-hifi.git
synced 2024-11-23 14:03:04 +01:00
Removed Songwhip (they shut down) and replaced it with TIDAL's universal link system
This commit is contained in:
parent
baf719fc60
commit
2ab5a556ab
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@ -14,7 +14,6 @@
|
|||||||
"rescrobbler",
|
"rescrobbler",
|
||||||
"scrobble",
|
"scrobble",
|
||||||
"scrobbling",
|
"scrobbling",
|
||||||
"Songwhip",
|
|
||||||
"trackid",
|
"trackid",
|
||||||
"tracklist",
|
"tracklist",
|
||||||
"widevine",
|
"widevine",
|
||||||
|
@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
- Added an option to disable the dynamic title and set it to a static one, [#491](https://github.com/Mastermindzh/tidal-hifi/pull/491)
|
- Added an option to disable the dynamic title and set it to a static one, [#491](https://github.com/Mastermindzh/tidal-hifi/pull/491)
|
||||||
- Fixed several element names in the dom scraper
|
- Fixed several element names in the dom scraper
|
||||||
|
- Removed Songwhip (they shut down) and replaced it with TIDAL's universal link system
|
||||||
|
|
||||||
## [5.16.0]
|
## [5.16.0]
|
||||||
|
|
||||||
|
@ -48,7 +48,6 @@ The web version of [listen.tidal.com](https://listen.tidal.com) running in elect
|
|||||||
- AlbumArt in integrations ([best-effort](https://github.com/Mastermindzh/tidal-hifi/pull/88#pullrequestreview-840814847))
|
- AlbumArt in integrations ([best-effort](https://github.com/Mastermindzh/tidal-hifi/pull/88#pullrequestreview-840814847))
|
||||||
- Custom [integrations](#integrations)
|
- Custom [integrations](#integrations)
|
||||||
- [ListenBrainz](https://listenbrainz.org/?redirect=false) integration
|
- [ListenBrainz](https://listenbrainz.org/?redirect=false) integration
|
||||||
- Songwhip.com integration (hotkey `ctrl + w`)
|
|
||||||
- Discord RPC integration (showing "now listening", "Browsing", etc)
|
- Discord RPC integration (showing "now listening", "Browsing", etc)
|
||||||
- Flatpak version only works if both Discord and Tidal-HiFi are flatpaks
|
- Flatpak version only works if both Discord and Tidal-HiFi are flatpaks
|
||||||
- MPRIS integration
|
- MPRIS integration
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
repeat: '*[data-test="repeat"]',
|
repeat: '*[data-test="repeat"]',
|
||||||
account: '*[data-test^="profile-image-button"]',
|
account: '*[data-test^="profile-image-button"]',
|
||||||
settings: '*[data-test^="sidebar-menu-button"]',
|
settings: '*[data-test^="sidebar-menu-button"]',
|
||||||
|
openSettings: '*[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"]',
|
||||||
|
@ -10,7 +10,7 @@ export const globalEvents = {
|
|||||||
showSettings: "showSettings",
|
showSettings: "showSettings",
|
||||||
storeChanged: "storeChanged",
|
storeChanged: "storeChanged",
|
||||||
error: "error",
|
error: "error",
|
||||||
whip: "whip",
|
getUniversalLink: "getUniversalLink",
|
||||||
log: "log",
|
log: "log",
|
||||||
toggleFavorite: "toggleFavorite",
|
toggleFavorite: "toggleFavorite",
|
||||||
toggleShuffle: "toggleShuffle",
|
toggleShuffle: "toggleShuffle",
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"openapi": "3.1.0",
|
"openapi": "3.1.0",
|
||||||
"info": {
|
"info": {
|
||||||
"title": "TIDAL Hi-Fi API",
|
"title": "TIDAL Hi-Fi API",
|
||||||
"version": "5.16.0",
|
"version": "5.17.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"license": {
|
"license": {
|
||||||
"name": "MIT",
|
"name": "MIT",
|
||||||
|
10
src/features/sharingService/sharingService.ts
Normal file
10
src/features/sharingService/sharingService.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
export class SharingService {
|
||||||
|
/**
|
||||||
|
* Retrieve the universal link given a regular track link
|
||||||
|
* @param currentUrl
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
public static getUniversalLink(currentUrl: string): string {
|
||||||
|
return `${currentUrl}?u`;
|
||||||
|
}
|
||||||
|
}
|
@ -1,21 +0,0 @@
|
|||||||
import { ServiceLinks } from "./ServiceLinks";
|
|
||||||
|
|
||||||
export interface Artist {
|
|
||||||
type: string;
|
|
||||||
id: number;
|
|
||||||
path: string;
|
|
||||||
name: string;
|
|
||||||
sourceUrl: string;
|
|
||||||
sourceCountry: string;
|
|
||||||
url: string;
|
|
||||||
image: string;
|
|
||||||
createdAt: string;
|
|
||||||
updatedAt: string;
|
|
||||||
refreshedAt: string;
|
|
||||||
serviceIds: { [key: string]: string };
|
|
||||||
orchardId: string;
|
|
||||||
spotifyId: string;
|
|
||||||
links: { [key: string]: ServiceLinks[] };
|
|
||||||
linksCountries: string[];
|
|
||||||
description: string;
|
|
||||||
}
|
|
@ -1,4 +0,0 @@
|
|||||||
export interface ServiceLinks {
|
|
||||||
link: string;
|
|
||||||
countries: string[];
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
import { Artist } from "./Artist";
|
|
||||||
import { ServiceLinks } from "./ServiceLinks";
|
|
||||||
|
|
||||||
export interface WhippedResult {
|
|
||||||
status: string;
|
|
||||||
data: {
|
|
||||||
item: {
|
|
||||||
type: string;
|
|
||||||
id: number;
|
|
||||||
path: string;
|
|
||||||
name: string;
|
|
||||||
url: string;
|
|
||||||
sourceUrl: string;
|
|
||||||
sourceCountry: string;
|
|
||||||
releaseDate: string;
|
|
||||||
createdAt: string;
|
|
||||||
updatedAt: string;
|
|
||||||
refreshedAt: string;
|
|
||||||
image: string;
|
|
||||||
isrc: string;
|
|
||||||
isExplicit: boolean;
|
|
||||||
links: { [key: string]: ServiceLinks[] };
|
|
||||||
linksCountries: string[];
|
|
||||||
artists: Artist[];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
import { WhippedResult } from "./models/whip";
|
|
||||||
import axios from "axios";
|
|
||||||
|
|
||||||
export class Songwhip {
|
|
||||||
/**
|
|
||||||
* Call the songwhip API and create a shareable songwhip page
|
|
||||||
* @param currentUrl
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
public static async whip(currentUrl: string): Promise<WhippedResult> {
|
|
||||||
try {
|
|
||||||
const response = await axios.post("https://songwhip.com/api/songwhip/create", {
|
|
||||||
url: currentUrl,
|
|
||||||
// doesn't actually matter.. returns everything the same way anyway
|
|
||||||
country: "NL",
|
|
||||||
});
|
|
||||||
|
|
||||||
return response.data;
|
|
||||||
} catch (error) {
|
|
||||||
console.log(JSON.stringify(error));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Transform a songwhip response into a shareable url
|
|
||||||
* @param response
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
public static getWhipUrl(response: WhippedResult) {
|
|
||||||
return `https://songwhip.com${response.data.item.url}`;
|
|
||||||
}
|
|
||||||
}
|
|
@ -10,7 +10,7 @@ import {
|
|||||||
releaseInhibitorIfActive,
|
releaseInhibitorIfActive,
|
||||||
} from "./features/idleInhibitor/idleInhibitor";
|
} from "./features/idleInhibitor/idleInhibitor";
|
||||||
import { Logger } from "./features/logger";
|
import { Logger } from "./features/logger";
|
||||||
import { Songwhip } from "./features/songwhip/songwhip";
|
import { SharingService } from "./features/sharingService/sharingService";
|
||||||
import { MediaInfo } from "./models/mediaInfo";
|
import { MediaInfo } from "./models/mediaInfo";
|
||||||
import { MediaStatus } from "./models/mediaStatus";
|
import { MediaStatus } from "./models/mediaStatus";
|
||||||
import { initRPC, rpc, unRPC } from "./scripts/discord";
|
import { initRPC, rpc, unRPC } from "./scripts/discord";
|
||||||
@ -250,8 +250,8 @@ ipcMain.on(globalEvents.error, (event) => {
|
|||||||
console.log(event);
|
console.log(event);
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.handle(globalEvents.whip, async (event, url) => {
|
ipcMain.handle(globalEvents.getUniversalLink, async (event, url) => {
|
||||||
return Songwhip.whip(url);
|
return SharingService.getUniversalLink(url);
|
||||||
});
|
});
|
||||||
|
|
||||||
Logger.watch(ipcMain);
|
Logger.watch(ipcMain);
|
||||||
|
@ -10,7 +10,7 @@ import {
|
|||||||
} from "./features/listenbrainz/listenbrainz";
|
} from "./features/listenbrainz/listenbrainz";
|
||||||
import { StoreData } from "./features/listenbrainz/models/storeData";
|
import { StoreData } from "./features/listenbrainz/models/storeData";
|
||||||
import { Logger } from "./features/logger";
|
import { Logger } from "./features/logger";
|
||||||
import { Songwhip } from "./features/songwhip/songwhip";
|
import { SharingService } from "./features/sharingService/sharingService";
|
||||||
import { addCustomCss } from "./features/theming/theming";
|
import { addCustomCss } from "./features/theming/theming";
|
||||||
import { convertDurationToSeconds } from "./features/time/parse";
|
import { convertDurationToSeconds } from "./features/time/parse";
|
||||||
import { MediaInfo } from "./models/mediaInfo";
|
import { MediaInfo } from "./models/mediaInfo";
|
||||||
@ -50,6 +50,7 @@ const elements = {
|
|||||||
repeat: '*[data-test="repeat"]',
|
repeat: '*[data-test="repeat"]',
|
||||||
account: '*[data-test^="profile-image-button"]',
|
account: '*[data-test^="profile-image-button"]',
|
||||||
settings: '*[data-test^="sidebar-menu-button"]',
|
settings: '*[data-test^="sidebar-menu-button"]',
|
||||||
|
openSettings: '*[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"]',
|
||||||
@ -220,9 +221,9 @@ ListenBrainzStore.clear();
|
|||||||
function addHotKeys() {
|
function addHotKeys() {
|
||||||
if (settingsStore.get(settings.enableCustomHotkeys)) {
|
if (settingsStore.get(settings.enableCustomHotkeys)) {
|
||||||
addHotkey("Control+p", function () {
|
addHotkey("Control+p", function () {
|
||||||
elements.click("account");
|
|
||||||
setTimeout(() => {
|
|
||||||
elements.click("settings");
|
elements.click("settings");
|
||||||
|
setTimeout(() => {
|
||||||
|
elements.click("openSettings");
|
||||||
}, 100);
|
}, 100);
|
||||||
});
|
});
|
||||||
addHotkey("Control+l", function () {
|
addHotkey("Control+l", function () {
|
||||||
@ -254,11 +255,10 @@ function addHotKeys() {
|
|||||||
elements.click("repeat");
|
elements.click("repeat");
|
||||||
});
|
});
|
||||||
addHotkey("control+w", async function () {
|
addHotkey("control+w", async function () {
|
||||||
const result = await ipcRenderer.invoke(globalEvents.whip, getTrackURL());
|
const url = SharingService.getUniversalLink(getTrackURL());
|
||||||
const url = Songwhip.getWhipUrl(result);
|
|
||||||
clipboard.writeText(url);
|
clipboard.writeText(url);
|
||||||
new Notification({
|
new Notification({
|
||||||
title: `Successfully whipped: `,
|
title: `Universal link generated: `,
|
||||||
body: `URL copied to clipboard: ${url}`,
|
body: `URL copied to clipboard: ${url}`,
|
||||||
}).show();
|
}).show();
|
||||||
});
|
});
|
||||||
@ -550,7 +550,7 @@ setInterval(function () {
|
|||||||
const artistsArray = elements.getArtistsArray();
|
const artistsArray = elements.getArtistsArray();
|
||||||
const artistsString = elements.getArtistsString(artistsArray);
|
const artistsString = elements.getArtistsString(artistsArray);
|
||||||
const songDashArtistTitle = `${title} - ${artistsString}`;
|
const songDashArtistTitle = `${title} - ${artistsString}`;
|
||||||
const staticTitle = "TIDAL Hi-Fi"
|
const staticTitle = "TIDAL Hi-Fi";
|
||||||
const titleOrArtistsChanged = currentSong !== songDashArtistTitle;
|
const titleOrArtistsChanged = currentSong !== songDashArtistTitle;
|
||||||
const current = elements.getText("current");
|
const current = elements.getText("current");
|
||||||
const currentStatus = getCurrentlyPlayingStatus();
|
const currentStatus = getCurrentlyPlayingStatus();
|
||||||
@ -595,7 +595,9 @@ setInterval(function () {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// update title, url and play info with new info
|
// update title, url and play info with new info
|
||||||
settingsStore.get(settings.staticWindowTitle) ? setTitle(staticTitle) : setTitle(songDashArtistTitle);
|
settingsStore.get(settings.staticWindowTitle)
|
||||||
|
? setTitle(staticTitle)
|
||||||
|
: setTitle(songDashArtistTitle);
|
||||||
getTrackURL();
|
getTrackURL();
|
||||||
currentSong = songDashArtistTitle;
|
currentSong = songDashArtistTitle;
|
||||||
currentPlayStatus = currentStatus;
|
currentPlayStatus = currentStatus;
|
||||||
|
Loading…
Reference in New Issue
Block a user