mirror of
https://github.com/Mastermindzh/tidal-hifi.git
synced 2024-11-23 05:52:53 +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",
|
||||
"scrobble",
|
||||
"scrobbling",
|
||||
"Songwhip",
|
||||
"trackid",
|
||||
"tracklist",
|
||||
"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)
|
||||
- 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]
|
||||
|
||||
|
@ -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))
|
||||
- Custom [integrations](#integrations)
|
||||
- [ListenBrainz](https://listenbrainz.org/?redirect=false) integration
|
||||
- Songwhip.com integration (hotkey `ctrl + w`)
|
||||
- Discord RPC integration (showing "now listening", "Browsing", etc)
|
||||
- Flatpak version only works if both Discord and Tidal-HiFi are flatpaks
|
||||
- MPRIS integration
|
||||
|
@ -18,6 +18,7 @@
|
||||
repeat: '*[data-test="repeat"]',
|
||||
account: '*[data-test^="profile-image-button"]',
|
||||
settings: '*[data-test^="sidebar-menu-button"]',
|
||||
openSettings: '*[data-test^="open-settings"]',
|
||||
media: '*[data-test="current-media-imagery"]',
|
||||
image: "img",
|
||||
current: '*[data-test="current-time"]',
|
||||
|
@ -10,7 +10,7 @@ export const globalEvents = {
|
||||
showSettings: "showSettings",
|
||||
storeChanged: "storeChanged",
|
||||
error: "error",
|
||||
whip: "whip",
|
||||
getUniversalLink: "getUniversalLink",
|
||||
log: "log",
|
||||
toggleFavorite: "toggleFavorite",
|
||||
toggleShuffle: "toggleShuffle",
|
||||
|
@ -2,7 +2,7 @@
|
||||
"openapi": "3.1.0",
|
||||
"info": {
|
||||
"title": "TIDAL Hi-Fi API",
|
||||
"version": "5.16.0",
|
||||
"version": "5.17.0",
|
||||
"description": "",
|
||||
"license": {
|
||||
"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,
|
||||
} from "./features/idleInhibitor/idleInhibitor";
|
||||
import { Logger } from "./features/logger";
|
||||
import { Songwhip } from "./features/songwhip/songwhip";
|
||||
import { SharingService } from "./features/sharingService/sharingService";
|
||||
import { MediaInfo } from "./models/mediaInfo";
|
||||
import { MediaStatus } from "./models/mediaStatus";
|
||||
import { initRPC, rpc, unRPC } from "./scripts/discord";
|
||||
@ -250,8 +250,8 @@ ipcMain.on(globalEvents.error, (event) => {
|
||||
console.log(event);
|
||||
});
|
||||
|
||||
ipcMain.handle(globalEvents.whip, async (event, url) => {
|
||||
return Songwhip.whip(url);
|
||||
ipcMain.handle(globalEvents.getUniversalLink, async (event, url) => {
|
||||
return SharingService.getUniversalLink(url);
|
||||
});
|
||||
|
||||
Logger.watch(ipcMain);
|
||||
|
@ -10,7 +10,7 @@ import {
|
||||
} from "./features/listenbrainz/listenbrainz";
|
||||
import { StoreData } from "./features/listenbrainz/models/storeData";
|
||||
import { Logger } from "./features/logger";
|
||||
import { Songwhip } from "./features/songwhip/songwhip";
|
||||
import { SharingService } from "./features/sharingService/sharingService";
|
||||
import { addCustomCss } from "./features/theming/theming";
|
||||
import { convertDurationToSeconds } from "./features/time/parse";
|
||||
import { MediaInfo } from "./models/mediaInfo";
|
||||
@ -50,6 +50,7 @@ const elements = {
|
||||
repeat: '*[data-test="repeat"]',
|
||||
account: '*[data-test^="profile-image-button"]',
|
||||
settings: '*[data-test^="sidebar-menu-button"]',
|
||||
openSettings: '*[data-test^="open-settings"]',
|
||||
media: '*[data-test="current-media-imagery"]',
|
||||
image: "img",
|
||||
current: '*[data-test="current-time"]',
|
||||
@ -220,9 +221,9 @@ ListenBrainzStore.clear();
|
||||
function addHotKeys() {
|
||||
if (settingsStore.get(settings.enableCustomHotkeys)) {
|
||||
addHotkey("Control+p", function () {
|
||||
elements.click("account");
|
||||
setTimeout(() => {
|
||||
elements.click("settings");
|
||||
setTimeout(() => {
|
||||
elements.click("openSettings");
|
||||
}, 100);
|
||||
});
|
||||
addHotkey("Control+l", function () {
|
||||
@ -254,11 +255,10 @@ function addHotKeys() {
|
||||
elements.click("repeat");
|
||||
});
|
||||
addHotkey("control+w", async function () {
|
||||
const result = await ipcRenderer.invoke(globalEvents.whip, getTrackURL());
|
||||
const url = Songwhip.getWhipUrl(result);
|
||||
const url = SharingService.getUniversalLink(getTrackURL());
|
||||
clipboard.writeText(url);
|
||||
new Notification({
|
||||
title: `Successfully whipped: `,
|
||||
title: `Universal link generated: `,
|
||||
body: `URL copied to clipboard: ${url}`,
|
||||
}).show();
|
||||
});
|
||||
@ -550,7 +550,7 @@ setInterval(function () {
|
||||
const artistsArray = elements.getArtistsArray();
|
||||
const artistsString = elements.getArtistsString(artistsArray);
|
||||
const songDashArtistTitle = `${title} - ${artistsString}`;
|
||||
const staticTitle = "TIDAL Hi-Fi"
|
||||
const staticTitle = "TIDAL Hi-Fi";
|
||||
const titleOrArtistsChanged = currentSong !== songDashArtistTitle;
|
||||
const current = elements.getText("current");
|
||||
const currentStatus = getCurrentlyPlayingStatus();
|
||||
@ -595,7 +595,9 @@ setInterval(function () {
|
||||
};
|
||||
|
||||
// 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();
|
||||
currentSong = songDashArtistTitle;
|
||||
currentPlayStatus = currentStatus;
|
||||
|
Loading…
Reference in New Issue
Block a user