VocaDB / vocadb

VocaDB is a Vocaloid Database with translated artists, albums, music videos and more.
https://vocadb.net
Other
315 stars 39 forks source link

Song embeds from Netease Cloud Music #1322

Open AgFlore opened 2 years ago

AgFlore commented 2 years ago

Many artists publish their full songs/albums on NCM (https://music.163.com/), and NCM provides iframe-embedded players as well as querying APIs, so implementing is plausible, just follow what we have done with Bandcamp (#18 ).

Note that streaming on NCM are very commonly regionally-restricted. Songs published by commercial labels are most ususally mainland-PRC-only, while songs uploaded by individual producers are usually not that heavily restricted. Also i cannot confirm whether user's login status (to NCM) affects the playback's availability.

This issue may bring confusion to users, especially with respect to the media-unavailable label and when making entry reports. So we need to dig from the API a way to determine whether this song can be played embeddedly from some random location, and (if better) help lift the restrictions to the least of its type.

Embed example: <iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=330 height=86 src="//music.163.com/outchain/player?type=2&id=1310169941&auto=1&height=66"></iframe>

auto: autoplay or not type: 0 for playlist, 1 for album, 2 for song (Yeah you can embed a whole album like a playlist)

API example: $ curl "https://music.163.com/api/song/detail?ids=[1885752784]" -H "Referer: https://music.163.com/"

{"songs":[{"name":"フランケンX (煮ル果実×はるまきごはん)","id":1885752784,"position":0,"alias":[],"status":0,"fee":8,"copyrightId":1418220,"disc":"01","no":1,"artists":[{"name":"煮ル果実","id":31556032,"picId":0,"img1v1Id":0,"briefDesc":"","picUrl":"https://p2.music.126.net/6y-UleORITEDbvrOLV0Q8A==/5639395138885805.jpg","img1v1Url":"https://p2.music.126.net/6y-UleORITEDbvrOLV0Q8A==/5639395138885805.jpg","albumSize":0,"alias":[],"trans":"","musicSize":0,"topicPerson":0},{"name":"はるまきごはん","id":12175308,"picId":0,"img1v1Id":0,"briefDesc":"","picUrl":"https://p2.music.126.net/6y-UleORITEDbvrOLV0Q8A==/5639395138885805.jpg","img1v1Url":"https://p2.music.126.net/6y-UleORITEDbvrOLV0Q8A==/5639395138885805.jpg","albumSize":0,"alias":[],"trans":"","musicSize":0,"topicPerson":0}],"album":{"name":"キメラ","id":134545901,"type":"专辑","size":8,"picId":109951166506501967,"blurPicUrl":"https://p2.music.126.net/ZRU-zv4sZXEiUH1ObvcN3A==/109951166506501967.jpg","companyId":0,"pic":109951166506501967,"picUrl":"https://p2.music.126.net/ZRU-zv4sZXEiUH1ObvcN3A==/109951166506501967.jpg","publishTime":1634313600000,"description":"","tags":"","company":"CHIMERA Records","briefDesc":"","artist":{"name":"","id":0,"picId":0,"img1v1Id":0,"briefDesc":"","picUrl":"https://p2.music.126.net/6y-UleORITEDbvrOLV0Q8A==/5639395138885805.jpg","img1v1Url":"https://p2.music.126.net/6y-UleORITEDbvrOLV0Q8A==/5639395138885805.jpg","albumSize":0,"alias":[],"trans":"","musicSize":0,"topicPerson":0},"songs":[],"alias":[],"status":1,"copyrightId":1418220,"commentThreadId":"R_AL_3_134545901","artists":[{"name":"V.A.","id":21138,"picId":0,"img1v1Id":0,"briefDesc":"","picUrl":"https://p2.music.126.net/6y-UleORITEDbvrOLV0Q8A==/5639395138885805.jpg","img1v1Url":"https://p2.music.126.net/6y-UleORITEDbvrOLV0Q8A==/5639395138885805.jpg","albumSize":0,"alias":[],"trans":"","musicSize":0,"topicPerson":0}],"subType":"录音室版","transName":null,"onSale":false,"mark":0,"picId_str":"109951166506501967"},"starred":false,"popularity":100.0,"score":100,"starredNum":0,"duration":189473,"playedNum":0,"dayPlays":0,"hearTime":0,"ringtone":"","crbt":null,"audition":null,"copyFrom":"","commentThreadId":"R_SO_4_1885752784","rtUrl":null,"ftype":0,"rtUrls":[],"copyright":1,"transName":null,"sign":null,"mark":0,"originCoverType":0,"originSongSimpleData":null,"single":0,"noCopyrightRcmd":null,"mvid":0,"mMusic":{"name":null,"id":6899163559,"size":4548717,"extension":"mp3","sr":48000,"dfsId":0,"bitrate":192000,"playTime":189473,"volumeDelta":-69556.0},"lMusic":{"name":null,"id":6899163561,"size":3032493,"extension":"mp3","sr":48000,"dfsId":0,"bitrate":128000,"playTime":189473,"volumeDelta":-68389.0},"bMusic":{"name":null,"id":6899163561,"size":3032493,"extension":"mp3","sr":48000,"dfsId":0,"bitrate":128000,"playTime":189473,"volumeDelta":-68389.0},"hMusic":{"name":null,"id":6899163557,"size":7581165,"extension":"mp3","sr":48000,"dfsId":0,"bitrate":320000,"playTime":189473,"volumeDelta":-71939.0},"rtype":0,"rurl":null,"mp3Url":null}],"equalizers":{},"code":200}

Btw NCM provides HUGE many different apis overlaping each other (without public documentations like bilibili) and there's no promise whether the response is current or obsolete, or what each fields actually means. Luckily there're projects actively maintained that wrap them up into a documentated and friendly API system like https://github.com/Binaryify/NeteaseCloudMusicApi.

AgFlore commented 2 years ago

Need feedback about how much portion of songs on vocadb that has a NCM release can be streamed around the world without being geo-restricted (it really takes some effort find a not-your-own ip address and testload megabytes of MEDIA iframes).

Some typical datapoints like: 1885752790 (https://vocadb.net/S/349357), the CHIMERA track of Dance Robot Dance. (expect to be unstreamable from out of PRC?) 1885752789 (https://vocadb.net/S/349344), the first publicly released track of CHIMERA. 501547466 (https://vocadb.net/S/166101) individually uploaded by the artist in 2017 1809793061 (https://vocadb.net/S/308145) individually uploaded by the artist in 2021

(The point is, if the player availability were really low then we might as well not implement this?)