fix: fix bugs in MPRIS, and improve MPRIS (#1760)

Co-authored-by: JellyBrick <shlee1503@naver.com>
Co-authored-by: Totto <32566573+Totto16@users.noreply.github.com>
This commit is contained in:
JellyBrick
2024-02-20 20:50:55 +09:00
committed by GitHub
parent 8bd05f525d
commit d37cd2418c
15 changed files with 516 additions and 300 deletions

View File

@ -120,7 +120,9 @@ const handleData = async (
songInfo.mediaType = MediaType.PodcastEpisode;
// HACK: Podcast's participant is not the artist
if (!config.get('options.usePodcastParticipantAsArtist')) {
songInfo.artist = cleanupName(data.microformat.microformatDataRenderer.pageOwnerDetails.name);
songInfo.artist = cleanupName(
data.microformat.microformatDataRenderer.pageOwnerDetails.name,
);
}
break;
default:
@ -128,14 +130,13 @@ const handleData = async (
// HACK: This is a workaround for "podcast" types where "musicVideoType" doesn't exist. Google :facepalm:
if (
!config.get('options.usePodcastParticipantAsArtist') &&
(
data.responseContext.serviceTrackingParams
?.at(0)
?.params
?.find((it) => it.key === 'ipcc')?.value ?? '1'
) != '0'
(data.responseContext.serviceTrackingParams
?.at(0)
?.params?.find((it) => it.key === 'ipcc')?.value ?? '1') != '0'
) {
songInfo.artist = cleanupName(data.microformat.microformatDataRenderer.pageOwnerDetails.name);
songInfo.artist = cleanupName(
data.microformat.microformatDataRenderer.pageOwnerDetails.name,
);
}
break;
}
@ -165,10 +166,12 @@ const registerProvider = (win: BrowserWindow) => {
// This will be called when the song-info-front finds a new request with song data
ipcMain.on('ytmd:video-src-changed', async (_, data: GetPlayerResponse) => {
const tempSongInfo = await dataMutex.runExclusive<SongInfo | null>(async () => {
songInfo = await handleData(data, win);
return songInfo;
});
const tempSongInfo = await dataMutex.runExclusive<SongInfo | null>(
async () => {
songInfo = await handleData(data, win);
return songInfo;
},
);
if (tempSongInfo) {
for (const c of callbacks) {