node.js - 将 Spotify Link(或任何音乐流媒体服务链接)转换为另一个流媒体服务链接(例如 Apple Music、Amazon、Tidal、SoundCloud、Youtube)?
问题描述
我一直在试图弄清楚如何将音乐流媒体服务链接转换为所有其他给定的链接。在池中,我有 Spotify、Apple Music、Amazon、YouTube、SoundCloud、Tidal 和 YouTube Music。用户将输入来自任何流媒体服务的歌曲链接(例如https://open.spotify.com/track/4zfjkqJRJghGXUIq3Cosks?si=8f988d76f78941a6),然后算法将吐出所有其他链接到完全相同的歌曲在我上面列出的其他平台上。这将是与SongWhip完全相同的过程和结果。我一直在试图弄清楚如何用 ReactJS 来实现它。如果可以的话请帮忙!谢谢!
解决方案
您可以尝试使用Songlink 的公共 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"
}
}
}
这适用于歌曲和专辑。
推荐阅读
- opencv - 如何使用 cv2.aruco.estimatePoseSingleMarkers 函数(python)估计 aruco 标记的姿势?
- token - 错误:返回错误:处理事务时出现 VM 异常:恢复 SafeERC20:低级调用失败
- python - 无法理解 Python 电报机器人作业队列
- python - Python openCV 在复杂图像上查找轮廓
- docker - 无法在清漆 6.5.1 中使用 std vmod
- postscript - 使用 postscript 'clip' 命令打印文档中的多个字段的正确技术是什么?
- apache-kafka-streams - spring-cloud-stream、kafka 和 avro 的问题侦探
- node.js - Beanstalk Cloudwatch 日志的换行问题
- python - 使用 itertools 从某个点继续排列
- java - JAVA Socket:服务器一直在监听客户端的文件请求