mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-12 11:01:45 +00:00
feat(discord): add song & artist URLs to rich presence (#3737)
Co-authored-by: JellyBrick <shlee1503@naver.com>
This commit is contained in:
@ -99,7 +99,9 @@ export class DiscordService {
|
||||
const activityInfo: SetActivity = {
|
||||
type: ActivityType.Listening,
|
||||
details: truncateString(songInfo.title, 128), // Song title
|
||||
detailsUrl: songInfo.url,
|
||||
state: truncateString(songInfo.artist, 128), // Artist name
|
||||
stateUrl: songInfo.artistUrl,
|
||||
largeImageKey: songInfo.imageSrc ?? undefined,
|
||||
largeImageText: songInfo.album
|
||||
? truncateString(songInfo.album, 128)
|
||||
|
||||
@ -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