-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Slowlife <[email protected]>
- Loading branch information
1 parent
5ec7b64
commit 2973204
Showing
2 changed files
with
162 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,48 @@ | ||
{ | ||
"$schema": "https://schemas.premid.app/metadata/1.12", | ||
"apiVersion": 1, | ||
"author": { | ||
"id": "374905512661221377", | ||
"name": "slowlife." | ||
}, | ||
"service": "SOOP", | ||
"altnames": [ | ||
"숲" | ||
], | ||
"description": { | ||
"en": "SOOP, a streaming platform created through participation and communication! Discover a variety of content at SOOP." | ||
}, | ||
"url": [ | ||
"www.sooplive.co.kr", | ||
"play.sooplive.co.kr", | ||
"vod.sooplive.co.kr" | ||
], | ||
"version": "1.0.0", | ||
"logo": "https://i.imgur.com/VbU4HLa.png", | ||
"thumbnail": "https://i.imgur.com/WDZMHwK.png", | ||
"color": "#0994ff", | ||
"category": "videos", | ||
"tags": [ | ||
"streaming", | ||
"gaming", | ||
"entertainment" | ||
], | ||
"settings": [ | ||
{ | ||
"id": "lang", | ||
"multiLanguage": true | ||
}, | ||
{ | ||
"id": "logo", | ||
"title": "Show Streamer Logo", | ||
"icon": "fad fa-images", | ||
"value": true | ||
}, | ||
{ | ||
"id": "time", | ||
"title": "Show Stream Elapsed Time", | ||
"icon": "fad fa-stopwatch", | ||
"value": false | ||
} | ||
] | ||
} |
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,114 @@ | ||
const presence = new Presence({ | ||
clientId: "1325035374430519392", | ||
}), | ||
getStrings = async () => { | ||
return presence.getStrings( | ||
{ | ||
play: "general.playing", | ||
pause: "general.paused", | ||
live: "general.live", | ||
browse: "general.browsing", | ||
watchStream: "general.buttonWatchStream", | ||
watchVideo: "general.buttonWatchVideo", | ||
}, | ||
oldLang | ||
); | ||
}, | ||
browsingTimestamp = Math.floor(Date.now() / 1000); | ||
|
||
const enum Assets { | ||
Logo = "https://i.imgur.com/VbU4HLa.png", | ||
} | ||
|
||
const enum SoopAssets { | ||
Browse = "https://i.imgur.com/MefUF9R.png", | ||
Live = "https://i.imgur.com/XNGUK9X.png", | ||
Play = "https://i.imgur.com/th6he6j.png", | ||
Pause = "https://i.imgur.com/WN5FaFU.png", | ||
} | ||
|
||
let oldLang: string, strings: Awaited<ReturnType<typeof getStrings>>; | ||
|
||
presence.on("UpdateData", async () => { | ||
const [newLang, showStreamerLogo, showElapsedTime] = await Promise.all([ | ||
presence.getSetting<string>("lang"), | ||
presence.getSetting<boolean>("logo"), | ||
presence.getSetting<boolean>("time"), | ||
]); | ||
|
||
if (oldLang !== newLang || !strings) { | ||
oldLang = newLang; | ||
strings = await getStrings(); | ||
} | ||
|
||
const presenceData: PresenceData = { | ||
details: strings.browse, | ||
largeImageKey: Assets.Logo, | ||
smallImageKey: SoopAssets.Browse, | ||
startTimestamp: browsingTimestamp, | ||
type: ActivityType.Watching, | ||
}, | ||
{ hostname, pathname, href } = document.location; | ||
|
||
switch (hostname.split(".")[0]) { | ||
case "play": { | ||
presenceData.details = | ||
document.querySelector("span#infoTitle").textContent; | ||
presenceData.state = document.querySelector("a#infoNickName").textContent; | ||
presenceData.largeImageKey = showStreamerLogo | ||
? document.querySelector<HTMLImageElement>("#bjThumbnail img").src | ||
: Assets.Logo; | ||
|
||
presenceData.smallImageKey = SoopAssets.Live; | ||
presenceData.smallImageText = strings.live; | ||
|
||
if (showElapsedTime) { | ||
presenceData.startTimestamp = | ||
Math.floor(Date.now() / 1000) - | ||
presence.timestampFromFormat( | ||
document.querySelector("span#time").textContent | ||
); | ||
} | ||
|
||
presenceData.buttons = [{ url: href, label: strings.watchStream }]; | ||
break; | ||
} | ||
case "vod": { | ||
const isCatch = pathname.includes("/catch"), | ||
video = document.querySelector("video"); | ||
|
||
if (video) { | ||
presenceData.details = document.querySelector( | ||
isCatch ? "h3.title" : "div.broadcast_title" | ||
).textContent; | ||
presenceData.state = document.querySelector( | ||
isCatch ? "button.nick.ictFunc" : "a.ictFunc" | ||
).textContent; | ||
presenceData.largeImageKey = showStreamerLogo | ||
? document.querySelector<HTMLImageElement>( | ||
isCatch ? "div.author_inner img" : "div.thumbnail_box img" | ||
).src | ||
: Assets.Logo; | ||
|
||
presenceData.smallImageKey = video.paused | ||
? SoopAssets.Pause | ||
: SoopAssets.Play; | ||
presenceData.smallImageText = video.paused | ||
? strings.pause | ||
: strings.play; | ||
|
||
presenceData.buttons = [{ url: href, label: strings.watchVideo }]; | ||
|
||
[presenceData.startTimestamp, presenceData.endTimestamp] = | ||
presence.getTimestampsfromMedia(video); | ||
|
||
if (video.paused) { | ||
delete presenceData.startTimestamp; | ||
delete presenceData.endTimestamp; | ||
} | ||
} | ||
} | ||
} | ||
|
||
presence.setActivity(presenceData); | ||
}); |