Fixed Apple Music song embeds. (#9220)
* Fixed Apple Music song embeds when using a direct song link (vs playlist or album). * Fixed song embed test. * Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Jason Ericson <jasonmarkericson@gmail.com> Co-authored-by: Samuel Newman <mozzius@protonmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -378,6 +378,7 @@ describe('parseEmbedPlayerFromUrl', () => {
|
||||
'https://music.apple.com/us/playlist/playlistName/playlistId',
|
||||
'https://music.apple.com/us/album/albumName/albumId',
|
||||
'https://music.apple.com/us/album/albumName/albumId?i=songId',
|
||||
'https://music.apple.com/us/song/songName/songId',
|
||||
|
||||
'https://vimeo.com/videoId',
|
||||
'https://vimeo.com/videoId?autoplay=0',
|
||||
@@ -604,6 +605,11 @@ describe('parseEmbedPlayerFromUrl', () => {
|
||||
playerUri:
|
||||
'https://embed.music.apple.com/us/album/albumName/albumId?i=songId',
|
||||
},
|
||||
{
|
||||
type: 'apple_music_song',
|
||||
source: 'appleMusic',
|
||||
playerUri: 'https://embed.music.apple.com/us/song/songName/songId',
|
||||
},
|
||||
|
||||
{
|
||||
type: 'vimeo_video',
|
||||
|
||||
@@ -239,10 +239,13 @@ export function parseEmbedPlayerFromUrl(
|
||||
const type = pathParams[2]
|
||||
const songId = urlp.searchParams.get('i')
|
||||
|
||||
if (pathParams.length === 5 && (type === 'playlist' || type === 'album')) {
|
||||
if (
|
||||
pathParams.length === 5 &&
|
||||
(type === 'playlist' || type === 'album' || type === 'song')
|
||||
) {
|
||||
// We want to append the songId to the end of the url if it exists
|
||||
const embedUri = `https://embed.music.apple.com${urlp.pathname}${
|
||||
urlp.search ? '?i=' + songId : ''
|
||||
songId ? `?i=${songId}` : ''
|
||||
}`
|
||||
|
||||
if (type === 'playlist') {
|
||||
@@ -265,6 +268,12 @@ export function parseEmbedPlayerFromUrl(
|
||||
playerUri: embedUri,
|
||||
}
|
||||
}
|
||||
} else if (type === 'song') {
|
||||
return {
|
||||
type: 'apple_music_song',
|
||||
source: 'appleMusic',
|
||||
playerUri: embedUri,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user