mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-12 19:01:47 +00:00
fix(discord-rpc, scrobbler): Align artist and title with the last.fm's de facto standard
- Display only the main artist. - Display the title in its original language without romanization. - fix #3358 - fix #3641
This commit is contained in:
@ -23,13 +23,3 @@ export enum TimerKey {
|
||||
UpdateTimeout = 'updateTimeout', // Timer for throttled activity updates
|
||||
DiscordConnectRetry = 'discordConnectRetry', // Timer for Discord connection retries
|
||||
}
|
||||
|
||||
/**
|
||||
* An enum for Discord's activity.status_display_type field, governing which field of the activity should be used after
|
||||
* "Listening to..." in the user's Discord status.
|
||||
*/
|
||||
export const DiscordStatusDisplayType = {
|
||||
YOUTUBE_MUSIC: 0,
|
||||
ARTIST: 1,
|
||||
TITLE: 2,
|
||||
} as const;
|
||||
|
||||
@ -99,9 +99,9 @@ export class DiscordService {
|
||||
const activityInfo: SetActivity = {
|
||||
type: ActivityType.Listening,
|
||||
statusDisplayType: config.statusDisplayType,
|
||||
details: truncateString(songInfo.title, 128), // Song title
|
||||
details: truncateString(songInfo.alternativeTitle ?? songInfo.title, 128), // Song title
|
||||
detailsUrl: songInfo.url ?? undefined,
|
||||
state: truncateString(songInfo.artist, 128), // Artist name
|
||||
state: truncateString(songInfo.tags?.at(0) ?? songInfo.artist, 128), // Artist name
|
||||
stateUrl: songInfo.artistUrl,
|
||||
largeImageKey: songInfo.imageSrc ?? undefined,
|
||||
largeImageText: songInfo.album
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
import { StatusDisplayType } from 'discord-api-types/v10';
|
||||
|
||||
import { createPlugin } from '@/utils';
|
||||
import { backend } from './main';
|
||||
import { onMenu } from './menu';
|
||||
import { t } from '@/i18n';
|
||||
import { DiscordStatusDisplayType } from './constants';
|
||||
|
||||
export type DiscordPluginConfig = {
|
||||
enabled: boolean;
|
||||
@ -37,7 +38,7 @@ export type DiscordPluginConfig = {
|
||||
/**
|
||||
* Controls which field is displayed in the Discord status text
|
||||
*/
|
||||
statusDisplayType: (typeof DiscordStatusDisplayType)[keyof typeof DiscordStatusDisplayType];
|
||||
statusDisplayType: (typeof StatusDisplayType)[keyof typeof StatusDisplayType];
|
||||
};
|
||||
|
||||
export default createPlugin({
|
||||
@ -52,7 +53,7 @@ export default createPlugin({
|
||||
playOnYouTubeMusic: true,
|
||||
hideGitHubButton: false,
|
||||
hideDurationLeft: false,
|
||||
statusDisplayType: DiscordStatusDisplayType.ARTIST,
|
||||
statusDisplayType: StatusDisplayType.Details,
|
||||
} as DiscordPluginConfig,
|
||||
menu: onMenu,
|
||||
backend,
|
||||
|
||||
@ -1,30 +1,27 @@
|
||||
import prompt from 'custom-electron-prompt';
|
||||
|
||||
import { discordService } from './main';
|
||||
import { StatusDisplayType } from 'discord-api-types/v10';
|
||||
|
||||
import { discordService } from './main';
|
||||
import { singleton } from '@/providers/decorators';
|
||||
import promptOptions from '@/providers/prompt-options';
|
||||
import { setMenuOptions } from '@/config/plugins';
|
||||
|
||||
import { t } from '@/i18n';
|
||||
|
||||
import { DiscordStatusDisplayType } from './constants';
|
||||
|
||||
import type { MenuContext } from '@/types/contexts';
|
||||
import type { DiscordPluginConfig } from './index';
|
||||
|
||||
import type { MenuTemplate } from '@/menu';
|
||||
|
||||
const registerRefreshOnce = singleton((refreshMenu: () => void) => {
|
||||
discordService?.registerRefreshCallback(refreshMenu);
|
||||
});
|
||||
|
||||
const DiscordStatusDisplayTypeLabels = {
|
||||
[DiscordStatusDisplayType.YOUTUBE_MUSIC]:
|
||||
const DiscordStatusDisplayTypeLabels: Record<StatusDisplayType, string> = {
|
||||
[StatusDisplayType.Name]:
|
||||
'plugins.discord.menu.set-status-display-type.submenu.youtube-music',
|
||||
[DiscordStatusDisplayType.ARTIST]:
|
||||
[StatusDisplayType.State]:
|
||||
'plugins.discord.menu.set-status-display-type.submenu.artist',
|
||||
[DiscordStatusDisplayType.TITLE]:
|
||||
[StatusDisplayType.Details]:
|
||||
'plugins.discord.menu.set-status-display-type.submenu.title',
|
||||
};
|
||||
|
||||
@ -105,18 +102,24 @@ export const onMenu = async ({
|
||||
},
|
||||
{
|
||||
label: t('plugins.discord.menu.set-status-display-type.label'),
|
||||
submenu: Object.values(DiscordStatusDisplayType).map(
|
||||
(statusDisplayType) => ({
|
||||
label: t(DiscordStatusDisplayTypeLabels[statusDisplayType]),
|
||||
submenu: Object.values(StatusDisplayType)
|
||||
.filter(
|
||||
(v) => typeof StatusDisplayType[v as StatusDisplayType] !== 'number',
|
||||
)
|
||||
.map((statusDisplayType) => ({
|
||||
label: t(
|
||||
DiscordStatusDisplayTypeLabels[
|
||||
statusDisplayType as StatusDisplayType
|
||||
],
|
||||
),
|
||||
type: 'radio',
|
||||
checked: config.statusDisplayType == statusDisplayType,
|
||||
checked: config.statusDisplayType === statusDisplayType,
|
||||
click() {
|
||||
setConfig({
|
||||
statusDisplayType,
|
||||
statusDisplayType: statusDisplayType as StatusDisplayType,
|
||||
});
|
||||
},
|
||||
}),
|
||||
),
|
||||
})),
|
||||
},
|
||||
];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user