将 Spotify Link(或任何音乐流媒体服务链接)转换为另一个流媒体服务链接(例如 Apple Music、Amazon、Tidal、SoundCloud、Youtube)?
Posted
技术标签:
【中文标题】将 Spotify Link(或任何音乐流媒体服务链接)转换为另一个流媒体服务链接(例如 Apple Music、Amazon、Tidal、SoundCloud、Youtube)?【英文标题】:Converting Spotify Link (or any music streaming service link) to another streaming service link (ex. Apple Music, Amazon, Tidal, SoundCloud, Youtube)? 【发布时间】:2021-07-30 18:16:46 【问题描述】:我一直在试图弄清楚如何将音乐流媒体服务链接转换为所有其他给定的链接。在池中,我有 Spotify、Apple Music、Amazon、YouTube、SoundCloud、Tidal 和 YouTube Music。用户将输入来自任何流媒体服务的歌曲链接(例如https://open.spotify.com/track/4zfjkqJRJghGXUIq3Cosks?si=8f988d76f78941a6),然后算法会在我上面列出的其他平台上吐出指向完全相同歌曲的所有其他链接。这将是与SongWhip 完全相同的过程和结果。我一直在试图弄清楚如何用 ReactJS 来实现它。如果可以的话请帮忙!谢谢!
【问题讨论】:
【参考方案1】:您可以尝试使用Songlink's public API。它应该完全符合您的要求,并且包括您提到的所有主要流媒体服务。
使用您问题中的示例歌曲,您将提交一个 GET 请求:
curl -X GET "https://api.song.link/v1-alpha.1/links?url=open.spotify.com%2Ftrack%2F4zfjkqJRJghGXUIq3Cosks%3Fsi%3D8f988d76f78941a6"
而 Songlink 将返回一个 json 文件,其中包含其他流媒体平台中的所有匹配链接(如果存在):
"entityUniqueId": "SPOTIFY_SONG::4zfjkqJRJghGXUIq3Cosks",
"userCountry": "US",
"pageUrl": "https://song.link/s/4zfjkqJRJghGXUIq3Cosks",
"entitiesByUniqueId":
"DEEZER_SONG::1275807472":
"id": "1275807472",
"type": "song",
"title": "Inhaled",
"artistName": "Ahmad Anonimis",
"thumbnailUrl": "https://cdns-images.dzcdn.net/images/cover/48acc171cd7310d10047e6066d136586/500x500-000000-80-0-0.jpg",
"thumbnailWidth": 500,
"thumbnailHeight": 500,
"apiProvider": "deezer",
"platforms": [
"deezer"
]
,
"NAPSTER_SONG::tra.566238115":
"id": "tra.566238115",
"type": "song",
"title": "Inhaled",
"artistName": "Ahmad Anonimis",
"thumbnailUrl": "https://direct.rhapsody.com/imageserver/images/alb.566238114/385x385.jpeg",
"thumbnailWidth": 385,
"thumbnailHeight": 385,
"apiProvider": "napster",
"platforms": [
"napster"
]
,
"SOUNDCLOUD_SONG::1020531370":
"id": "1020531370",
"type": "song",
"title": "Inhaled (Prod. by Powers Pleasant)",
"artistName": "Ahmad Anonimis",
"thumbnailUrl": "https://i1.sndcdn.com/artworks-Mt2vlaVXZXzAosyy-1w1BOA-t500x500.jpg",
"thumbnailWidth": 500,
"thumbnailHeight": 500,
"apiProvider": "soundcloud",
"platforms": [
"soundcloud"
]
,
"SPOTIFY_SONG::4zfjkqJRJghGXUIq3Cosks":
"id": "4zfjkqJRJghGXUIq3Cosks",
"type": "song",
"title": "Inhaled",
"artistName": "Ahmad Anonimis",
"thumbnailUrl": "https://i.scdn.co/image/ab67616d0000b2733ec2a571fa840e8a0a449107",
"thumbnailWidth": 640,
"thumbnailHeight": 640,
"apiProvider": "spotify",
"platforms": [
"spotify"
]
,
"TIDAL_SONG::177197054":
"id": "177197054",
"type": "song",
"title": "Inhaled",
"artistName": "Ahmad Anonimis",
"thumbnailUrl": "https://resources.tidal.com/images/2fb4cbe7/b022/408e/b8d1/79a8bf7eefb5/640x640.jpg",
"thumbnailWidth": 640,
"thumbnailHeight": 640,
"apiProvider": "tidal",
"platforms": [
"tidal"
]
,
"YOUTUBE_VIDEO::3p4RJHoosg8":
"id": "3p4RJHoosg8",
"type": "song",
"title": "Ahmad Anonimis - Inhaled (Official Music Video)",
"artistName": "Ahmad Anonimis",
"thumbnailUrl": "https://i.ytimg.com/vi/3p4RJHoosg8/hqdefault.jpg",
"thumbnailWidth": 480,
"thumbnailHeight": 360,
"apiProvider": "youtube",
"platforms": [
"youtube",
"youtubeMusic"
]
,
"linksByPlatform":
"deezer":
"country": "US",
"url": "https://www.deezer.com/track/1275807472",
"entityUniqueId": "DEEZER_SONG::1275807472"
,
"napster":
"country": "US",
"url": "https://napster.com/track/tra.566238115",
"entityUniqueId": "NAPSTER_SONG::tra.566238115"
,
"soundcloud":
"country": "US",
"url": "https://soundcloud.com/ahmadanonimis-official/inhaled-prod-by-powers-pleasant",
"entityUniqueId": "SOUNDCLOUD_SONG::1020531370"
,
"spotify":
"country": "US",
"url": "https://open.spotify.com/track/4zfjkqJRJghGXUIq3Cosks",
"nativeAppUriDesktop": "spotify:track:4zfjkqJRJghGXUIq3Cosks",
"entityUniqueId": "SPOTIFY_SONG::4zfjkqJRJghGXUIq3Cosks"
,
"tidal":
"country": "US",
"url": "https://listen.tidal.com/track/177197054",
"entityUniqueId": "TIDAL_SONG::177197054"
,
"youtube":
"country": "US",
"url": "https://www.youtube.com/watch?v=3p4RJHoosg8",
"entityUniqueId": "YOUTUBE_VIDEO::3p4RJHoosg8"
,
"youtubeMusic":
"country": "US",
"url": "https://music.youtube.com/watch?v=3p4RJHoosg8",
"entityUniqueId": "YOUTUBE_VIDEO::3p4RJHoosg8"
这适用于歌曲和专辑。
【讨论】:
以上是关于将 Spotify Link(或任何音乐流媒体服务链接)转换为另一个流媒体服务链接(例如 Apple Music、Amazon、Tidal、SoundCloud、Youtube)?的主要内容,如果未能解决你的问题,请参考以下文章