mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-01-26 17:26:22 +00:00
option to use client name as name format
This commit is contained in:
parent
f702c4ffd5
commit
9b80d38f17
1 changed files with 16 additions and 5 deletions
|
@ -64,6 +64,7 @@ interface TrackData {
|
||||||
start: number;
|
start: number;
|
||||||
end: number;
|
end: number;
|
||||||
};
|
};
|
||||||
|
client?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// only relevant enum values
|
// only relevant enum values
|
||||||
|
@ -82,7 +83,8 @@ const enum NameFormat {
|
||||||
SongFirst = "song-first",
|
SongFirst = "song-first",
|
||||||
ArtistOnly = "artist",
|
ArtistOnly = "artist",
|
||||||
SongOnly = "song",
|
SongOnly = "song",
|
||||||
AlbumName = "album"
|
AlbumName = "album",
|
||||||
|
ClientName = "client"
|
||||||
}
|
}
|
||||||
|
|
||||||
const applicationId = "1108588077900898414";
|
const applicationId = "1108588077900898414";
|
||||||
|
@ -170,6 +172,10 @@ const settings = definePluginSettings({
|
||||||
{
|
{
|
||||||
label: "Use album name (falls back to custom status text if song has no album)",
|
label: "Use album name (falls back to custom status text if song has no album)",
|
||||||
value: NameFormat.AlbumName
|
value: NameFormat.AlbumName
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Use client name (either the streaming service or the music player, falls back to custom status text if song has no album)",
|
||||||
|
value: NameFormat.ClientName
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@ -303,8 +309,10 @@ export default definePlugin({
|
||||||
if (!trackData?.playing_now)
|
if (!trackData?.playing_now)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
let recordingMbid = trackData.track_metadata.additional_info.recording_mbid;
|
const trackAddInfo = trackData.track_metadata.additional_info;
|
||||||
let releaseMbid = trackData.track_metadata.additional_info.release_mbid;
|
|
||||||
|
let recordingMbid = trackAddInfo.recording_mbid;
|
||||||
|
let releaseMbid = trackAddInfo.release_mbid;
|
||||||
|
|
||||||
if (!recordingMbid || !releaseMbid) {
|
if (!recordingMbid || !releaseMbid) {
|
||||||
const metadata = await this.lookupListenBrainzMetadata(
|
const metadata = await this.lookupListenBrainzMetadata(
|
||||||
|
@ -321,10 +329,11 @@ export default definePlugin({
|
||||||
name: trackData.track_metadata.track_name,
|
name: trackData.track_metadata.track_name,
|
||||||
album: trackData.track_metadata.release_name,
|
album: trackData.track_metadata.release_name,
|
||||||
artist: trackData.track_metadata.artist_name,
|
artist: trackData.track_metadata.artist_name,
|
||||||
url: trackData.track_metadata.additional_info.origin_url ||
|
url: trackAddInfo.origin_url ||
|
||||||
recordingMbid && `https://musicbrainz.org/recording/${recordingMbid}`,
|
recordingMbid && `https://musicbrainz.org/recording/${recordingMbid}`,
|
||||||
imageUrl: releaseMbid && `https://coverartarchive.org/release/${releaseMbid}/front`,
|
imageUrl: releaseMbid && `https://coverartarchive.org/release/${releaseMbid}/front`,
|
||||||
timestamps: settings.store.sendTimestamps ? await this.getListenBrainzTimestamps(trackData) : undefined
|
timestamps: settings.store.sendTimestamps ? await this.getListenBrainzTimestamps(trackData) : undefined,
|
||||||
|
client: trackAddInfo?.music_service_name || trackAddInfo?.music_service || trackAddInfo?.media_player
|
||||||
};
|
};
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error("Failed to query ListenBrainz API", e);
|
logger.error("Failed to query ListenBrainz API", e);
|
||||||
|
@ -496,6 +505,8 @@ export default definePlugin({
|
||||||
return trackData.name;
|
return trackData.name;
|
||||||
case NameFormat.AlbumName:
|
case NameFormat.AlbumName:
|
||||||
return trackData.album || settings.store.statusName;
|
return trackData.album || settings.store.statusName;
|
||||||
|
case NameFormat.ClientName:
|
||||||
|
return trackData.client || settings.store.statusName;
|
||||||
default:
|
default:
|
||||||
return settings.store.statusName;
|
return settings.store.statusName;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue