Skip to content

Commit

Permalink
feat(Holodex): add cover (#7479)
Browse files Browse the repository at this point in the history
* feat(Holodex): add cover

* chore(Holodex): format code
  • Loading branch information
Dark_Ville authored Jul 14, 2023
1 parent 30aa762 commit 552b3d3
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 13 deletions.
7 changes: 7 additions & 0 deletions websites/H/Holodex/iframe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ iframe.on("UpdateData", async () => {
iframe.send({
video: {
isPaused: video.paused,
thumbnail:
document
.querySelector('[class="ytp-title-channel-logo"]')
?.getAttribute("style")
?.match(/http(s)?:\/\/.*-rj/gm)?.[0]
?.replace(/w=s88/gm, "w=s512") ??
"https://cdn.rcd.gg/PreMiD/websites/H/Holodex/assets/logo.png",
},
});
}
Expand Down
10 changes: 8 additions & 2 deletions websites/H/Holodex/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"staging.holodex.net",
"holodex.net"
],
"version": "1.0.19",
"version": "1.0.20",
"logo": "https://cdn.rcd.gg/PreMiD/websites/H/Holodex/assets/logo.png",
"thumbnail": "https://cdn.rcd.gg/PreMiD/websites/H/Holodex/assets/thumbnail.png",
"color": "#64b5f6",
Expand All @@ -22,11 +22,17 @@
"hololive"
],
"iframe": true,
"iFrameRegExp": ".*",
"iFrameRegExp": "(.*[.])?(youtube)([.].*)",
"settings": [
{
"id": "lang",
"multiLanguage": "true"
},
{
"id": "cover",
"title": "Show Cover",
"icon": "fad fa-images",
"value": true
}
]
}
35 changes: 24 additions & 11 deletions websites/H/Holodex/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ const presence = new Presence({
pause: "general.paused",
});

let iFrameVideo: { isPaused: boolean };
let iFrameVideo: { isPaused: boolean; thumbnail: string };

presence.on("iFrameData", (data: { video: { isPaused: boolean } }) => {
iFrameVideo = data.video;
});
presence.on(
"iFrameData",
(data: { video: { isPaused: boolean; thumbnail: string } }) => {
iFrameVideo = data.video;
}
);

const getInfo = {
generic: () => {
Expand Down Expand Up @@ -356,13 +359,15 @@ presence.on("UpdateData", async () => {
dataUpdater.updateAll();

const presenceData: PresenceData = {
largeImageKey:
"https://cdn.rcd.gg/PreMiD/websites/H/Holodex/assets/logo.png",
smallImageKey: data.smallimage.image,
smallImageText: data.smallimage.hover,
details: data.details,
startTimestamp: data.startTime,
};
largeImageKey:
iFrameVideo.thumbnail ??
"https://cdn.rcd.gg/PreMiD/websites/H/Holodex/assets/logo.png",
smallImageKey: data.smallimage.image,
smallImageText: data.smallimage.hover,
details: data.details,
startTimestamp: data.startTime,
},
cover = await presence.getSetting<boolean>("cover");

if (data.state) presenceData.state = data.state;

Expand Down Expand Up @@ -393,6 +398,14 @@ presence.on("UpdateData", async () => {
}
}

if (
!cover &&
presenceData.largeImageKey !==
"https://cdn.rcd.gg/PreMiD/websites/H/Holodex/assets/logo.png"
) {
presenceData.largeImageKey =
"https://cdn.rcd.gg/PreMiD/websites/H/Holodex/assets/logo.png";
}
if (presenceData.details) presence.setActivity(presenceData);
else presence.setActivity();
});

0 comments on commit 552b3d3

Please sign in to comment.