Skip to content

Commit

Permalink
feat(youtube): add playlist title & queue as replaceable string (#7495)
Browse files Browse the repository at this point in the history
* feat: add playlist title & queue as replaceable string

* fix(YouTube) : Lint issue styling and variable

Signed-off-by: Amardito <[email protected]>

* style(YouTube): formating document with prettier

* fix(YouTube): bump version

* feat(YouTube): add replaceable string to state

* fix(YouTube): object HtmlElement instead textContent

* feat(YouTube): update metadata placeholder Details

---------

Signed-off-by: Amardito <[email protected]>
  • Loading branch information
amardito authored Jul 20, 2023
1 parent 86baf6e commit 3f3abd9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
6 changes: 3 additions & 3 deletions websites/Y/YouTube/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"www.youtube.com",
"studio.youtube.com"
],
"version": "5.4.6",
"version": "5.4.7",
"logo": "https://cdn.rcd.gg/PreMiD/websites/Y/YouTube/assets/logo.png",
"thumbnail": "https://cdn.rcd.gg/PreMiD/websites/Y/YouTube/assets/thumbnail.jpg",
"color": "#E40813",
Expand Down Expand Up @@ -101,7 +101,7 @@
"title": "Video Details row1",
"icon": "fas fa-comment-alt-edit",
"value": "%title%",
"placeholder": "Use %title% or %uploader%"
"placeholder": "Use %title%, %uploader%, %playlistTitle%, %playlistQueue%"
},
{
"id": "vidState",
Expand All @@ -111,7 +111,7 @@
"title": "Video Details row2",
"icon": "fas fa-comment-alt-edit",
"value": "%uploader%",
"placeholder": "Use %title%, %uploader% or {0} to delete the row completely"
"placeholder": "same like row1 or use {0} to delete the row completely"
},
{
"id": "channelPic",
Expand Down
20 changes: 18 additions & 2 deletions websites/Y/YouTube/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,18 @@ presence.on("UpdateData", async () => {
!title || title.textContent.replace(/\s+/g, "") === ""
? document.querySelector("div.ytp-title-text > a").textContent
: title.textContent;
const finalPlaylistTitle = document.querySelector(
"#header-description > h3:nth-child(1) > yt-formatted-string > a"
).textContent,
finalPlaylistQueue = `${
document.querySelector(
"#publisher-container > div > yt-formatted-string > span:nth-child(1)"
).textContent
} / ${
document.querySelector(
"#publisher-container > div > yt-formatted-string > span:nth-child(3)"
).textContent
}`;

//* YouTube Movies
if (
Expand Down Expand Up @@ -336,10 +348,14 @@ presence.on("UpdateData", async () => {
presenceData: PresenceData = {
details: vidDetail
.replace("%title%", finalTitle.trim())
.replace("%uploader%", finalUploader.trim()),
.replace("%uploader%", finalUploader.trim())
.replace("%playlistTitle%", finalPlaylistTitle.trim())
.replace("%playlistQueue%", finalPlaylistQueue.trim()),
state: vidState
.replace("%title%", finalTitle.trim())
.replace("%uploader%", finalUploader.trim()),
.replace("%uploader%", finalUploader.trim())
.replace("%playlistTitle%", finalPlaylistTitle.trim())
.replace("%playlistQueue%", finalPlaylistQueue.trim()),
largeImageKey:
unlistedVideo || logo === 0 || pfp === ""
? Assets.Logo
Expand Down

0 comments on commit 3f3abd9

Please sign in to comment.