Skip to content

Commit

Permalink
feat(MusicBrainz Picard): add presence (PreMiD#6774)
Browse files Browse the repository at this point in the history
  • Loading branch information
theusaf authored Sep 11, 2022
1 parent 0bf296d commit 8603bbf
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
26 changes: 26 additions & 0 deletions websites/M/MusicBrainz Picard/dist/metadata.json
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"
]
}
45 changes: 45 additions & 0 deletions websites/M/MusicBrainz Picard/presence.ts
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);
});
6 changes: 6 additions & 0 deletions websites/M/MusicBrainz Picard/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist/"
}
}

0 comments on commit 8603bbf

Please sign in to comment.