Skip to content

Commit a1f88b2

Browse files
authored
Merge pull request #41 from NightVsKnight/copilot/link-now-playing-to-youtube
Link "Now Playing" track title to original YouTube video
2 parents 97ca884 + 11aff83 commit a1f88b2

1 file changed

Lines changed: 30 additions & 1 deletion

File tree

player.html

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,13 @@
144144
color: var(--text);
145145
font-weight: 600;
146146
}
147+
.now-title-link {
148+
color: var(--accent);
149+
text-decoration: none;
150+
}
151+
.now-title-link:hover {
152+
text-decoration: underline;
153+
}
147154

148155
.controls {
149156
display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
@@ -1601,6 +1608,14 @@ <h3 class="modal-section-title">OBS Metadata Export</h3>
16011608
const id = extractYouTubeIdFrom(entry.trackName, entry.relativePath);
16021609
return id ? `https://youtu.be/${id}` : null;
16031610
};
1611+
const resolveYouTubeUrlFromTrack = (track) => {
1612+
if (!track) return null;
1613+
const relativePath = track.path && track.path.length > 0 ? track.path.join('/') : '';
1614+
return resolveYouTubeUrl({
1615+
trackName: track.displayName || track.name,
1616+
relativePath: relativePath
1617+
});
1618+
};
16041619

16051620
const isRewoundPercent = (percent) => typeof percent === 'number' && percent > REWIND_RATIO_THRESHOLD;
16061621
const describeHistoryStatus = (entry) => {
@@ -2838,7 +2853,21 @@ <h3 class="modal-section-title">OBS Metadata Export</h3>
28382853
const tr = tracks[current];
28392854
const details = recordPendingAnnouncement(tr, { skipReason });
28402855
audio.src = tr.url;
2841-
if (nowTitleEl) nowTitleEl.textContent = tr.displayName;
2856+
if (nowTitleEl) {
2857+
const youtubeUrl = resolveYouTubeUrlFromTrack(tr);
2858+
if (youtubeUrl) {
2859+
nowTitleEl.innerHTML = '';
2860+
const link = document.createElement('a');
2861+
link.className = 'now-title-link';
2862+
link.href = youtubeUrl;
2863+
link.target = '_blank';
2864+
link.rel = 'noopener';
2865+
link.textContent = tr.displayName;
2866+
nowTitleEl.appendChild(link);
2867+
} else {
2868+
nowTitleEl.textContent = tr.displayName;
2869+
}
2870+
}
28422871
if (nowArtistEl) nowArtistEl.textContent = (details && details.artist) ? details.artist : '—';
28432872
if (nowTrackNumberEl) nowTrackNumberEl.textContent = fmtTrackNumber(current);
28442873
const key = trackKey(tr);

0 commit comments

Comments
 (0)