Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save tianshuo/957c0e1421ce1d2eeda7ced065b205a5 to your computer and use it in GitHub Desktop.
Save tianshuo/957c0e1421ce1d2eeda7ced065b205a5 to your computer and use it in GitHub Desktop.
导出网易云音乐歌单到 AppleMusic / Spotify 等平台
/**
* 使用方法:
* 1. 用 Chrome 打开歌单的 web 页面(可以通过分享拿到链接,链接类似这样:http://music.163.com/playlist?id=xxx&userid=yyy)
* 2. 然后右键“检查”(如果有左上角有 device 选项,需要选择 Laptop 开头的,可以在 Edit/编辑 里添加)
* 3. 在 console 里输入下面脚本,即可输出 “歌曲名 - 歌手名” 格式的内容:
Springsteen - Eric Church
Chattahoochee - Alan Jackson
Baby Now That I Found You - Alison Krauss
Check Yes or No - George Strait
Meanwhile Back At Mama's (feat. Faith Hill) - Tim McGraw/Faith Hill
。。
* 4.通过 https://www.tunemymusic.com/zh-cn 导出到 Apple Music 或者 Spotify 等音乐平台
*/
(function () {
$$(".soil").map(x=>x.innerText="") // 干死所有干扰项
let result=$$(".m-table tr")
.map(x=>$$("td",x)
.map(y=>y.textContent))
.map(x=>x.length>0 ? ( x[3] + " - " + x[1].replace(/-.*|MV$/, "")) : "")
.join("\n")
console.log(result);
})();
@hellodk34
Copy link

感谢分享,我在另一个作者的 gist 下分享了片段

(function () {

    function getSinger(trNode) {
        return trNode.getElementsByClassName("text")[0].title;
    }

    function getSongName(trNode) {
        return trNode.getElementsByTagName("b")[0].title;
    }

    let allSongsTRNode = document.querySelectorAll('table.m-table  > tbody > tr')

    var songsStr = "";
    allSongsTRNode.forEach(songTR => {
        songsStr += (getSongName(songTR) + " - " + getSinger(songTR));
        songsStr += "\n";
    });
    console.log(songsStr);
})();

分享我的这篇文章 我的听歌软件 Spotify 和网易云的故事 | 导出网易云的歌单再导入到 Spotify

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment