mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-13 11:21:46 +00:00
feat(discord): add song & artist URLs to rich presence (#3737)
Co-authored-by: JellyBrick <shlee1503@naver.com>
This commit is contained in:
@ -30,6 +30,7 @@ export interface SongInfo {
|
||||
title: string;
|
||||
alternativeTitle?: string;
|
||||
artist: string;
|
||||
artistUrl?: string;
|
||||
views: number;
|
||||
uploadDate?: string;
|
||||
imageSrc?: string | null;
|
||||
@ -72,6 +73,7 @@ const handleData = async (
|
||||
title: '',
|
||||
alternativeTitle: '',
|
||||
artist: '',
|
||||
artistUrl: '',
|
||||
views: 0,
|
||||
uploadDate: '',
|
||||
imageSrc: '',
|
||||
@ -93,6 +95,9 @@ const handleData = async (
|
||||
songInfo.url = microformat.urlCanonical?.split('&')[0];
|
||||
songInfo.playlistId =
|
||||
new URL(microformat.urlCanonical).searchParams.get('list') ?? '';
|
||||
if (microformat.pageOwnerDetails?.externalChannelId) {
|
||||
songInfo.artistUrl = `https://music.youtube.com/channel/${microformat.pageOwnerDetails.externalChannelId}`;
|
||||
}
|
||||
// Used for options.resumeOnStart
|
||||
config.set('url', microformat.urlCanonical);
|
||||
songInfo.alternativeTitle = microformat.linkAlternates.find(
|
||||
@ -110,7 +115,7 @@ const handleData = async (
|
||||
songInfo.elapsedSeconds = videoDetails.elapsedSeconds;
|
||||
songInfo.isPaused = videoDetails.isPaused;
|
||||
songInfo.videoId = videoDetails.videoId;
|
||||
songInfo.album = data?.videoDetails?.album; // Will be undefined if video exist
|
||||
songInfo.album = videoDetails.album; // Will be undefined if video exist
|
||||
|
||||
switch (videoDetails?.musicVideoType) {
|
||||
case 'MUSIC_VIDEO_TYPE_ATV':
|
||||
|
||||
Reference in New Issue
Block a user