forked from PreMiD/Presences
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(MusicBrainz Picard): add presence (PreMiD#6774)
- Loading branch information
Showing
3 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"$schema": "https://schemas.premid.app/metadata/1.7", | ||
"author": { | ||
"name": "theusaf", | ||
"id": "193714715631812608" | ||
}, | ||
"service": "MusicBrainz Picard", | ||
"description": { | ||
"en": "Picard is a cross-platform music tagger written in Python." | ||
}, | ||
"url": [ | ||
"picard.musicbrainz.org", | ||
"picard-docs.musicbrainz.org" | ||
], | ||
"version": "1.0.0", | ||
"logo": "https://i.imgur.com/hkrB6W8.png", | ||
"thumbnail": "https://i.imgur.com/Z9vaF29.png", | ||
"color": "#771b85", | ||
"category": "music", | ||
"tags": [ | ||
"tagger", | ||
"application", | ||
"lookup", | ||
"cd" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const presence = new Presence({ | ||
clientId: "1017593958546821160", | ||
}), | ||
browsingTimestamp = Math.floor(Date.now() / 1000); | ||
|
||
presence.on("UpdateData", () => { | ||
const presenseData: PresenceData = { | ||
largeImageKey: "https://i.imgur.com/hkrB6W8.png", | ||
startTimestamp: browsingTimestamp, | ||
}, | ||
{ hostname, pathname } = window.location; | ||
switch (hostname) { | ||
case "picard.musicbrainz.org": { | ||
presenseData.details = "Browsing..."; | ||
switch (pathname.split("/")[1]) { | ||
case "": { | ||
presenseData.state = "Home page"; | ||
break; | ||
} | ||
case "docs": { | ||
presenseData.details = "Browsing documentation"; | ||
presenseData.state = document.querySelector("h1").textContent; | ||
break; | ||
} | ||
default: { | ||
presenseData.state = document.title.match( | ||
/(.*?)( - MusicBrainz Picard$|$)/ | ||
)[1]; | ||
} | ||
} | ||
break; | ||
} | ||
case "picard-docs.musicbrainz.org": { | ||
presenseData.details = "Browsing documentation..."; | ||
if (pathname.match(/^(?:\/v[\d.]+)?\/[a-z]{2}\/(.*)/)[1] === "index.html") | ||
presenseData.state = "Home page"; | ||
else { | ||
const { textContent } = document.querySelector("h1"); | ||
presenseData.state = textContent.substring(0, textContent.length - 1); | ||
} | ||
break; | ||
} | ||
} | ||
presence.setActivity(presenseData); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": "../../../tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "./dist/" | ||
} | ||
} |