From 8f6c61f9d28c6fcfb71a66cd242726f637ab38ac Mon Sep 17 00:00:00 2001 From: Listen 1 Date: Mon, 27 Nov 2017 11:01:24 +0800 Subject: [PATCH] fix netease playlist only show first item bug --- README.md | 6 ++- js/provider/netease.js | 107 ++++++++++++++++++++++++----------------- listen1.html | 2 +- 3 files changed, 69 insertions(+), 46 deletions(-) diff --git a/README.md b/README.md index 039186f..ee72cb4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Listen 1 (Chrome Extension) (最后更新于2017年11月17日) +Listen 1 (Chrome Extension) (最后更新于2017年11月27日) ========== [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE) @@ -36,6 +36,10 @@ Firefox打包安装 更新日志 ------- +`2017-11-27` + +* 修复网易云音乐歌单只显示第一首歌的Bug(感谢[@Binaryify/NeteaseCloudMusicApi](https://github.com/Binaryify/NeteaseCloudMusicApi)提供接口实现) + `2017-11-18` * 修复版权原因无法播放歌曲时自动暂停的问题 diff --git a/js/provider/netease.js b/js/provider/netease.js index ff674f7..81d266e 100644 --- a/js/provider/netease.js +++ b/js/provider/netease.js @@ -38,50 +38,6 @@ var netease = (function() { }; } - var ne_get_playlist = function(url, hm, se) { - var list_id = getParameterByName('list_id', url).split('_').pop(); - var target_url = 'http://music.163.com/api/playlist/detail?id=' + list_id; - return { - success: function (fn) { - hm.get(target_url).success(function (data) { - var info = { - 'id': 'neplaylist_' + list_id, - 'cover_img_url': data.result.coverImgUrl, - 'title': data.result.name, - 'source_url': 'http://music.163.com/#/playlist?id=' + list_id - }; - var tracks = []; - $.each(data.result.tracks, function(index, track_json){ - var default_track = { - 'id': '0', - 'title': '', - 'artist': '', - 'artist_id': 'neartist_0', - 'album': '', - 'album_id': 'nealbum_0', - 'source': 'netease', - 'source_url': 'http://www.xiami.com/song/0', - 'img_url': '', - 'url': '' - }; - default_track.id = 'netrack_' + track_json.id; - default_track.title = track_json.name; - default_track.artist = track_json.artists[0].name; - default_track.artist_id = 'neartist_' + track_json.artists[0].id; - default_track.album = track_json.album.name; - default_track.album_id = 'nealbum_' + track_json.album.id; - default_track.source_url = 'http://music.163.com/#/song?id=' + track_json.id; - default_track.img_url = track_json.album.picUrl; - default_track.url = default_track.id; - - tracks.push(default_track); - }); - return fn({"info":info,"tracks":tracks}); - }); - } - }; - } - function _create_secret_key(size) { var result = []; var choice = '012345679abcdef'.split(''); @@ -171,6 +127,69 @@ var netease = (function() { return data; } + var ne_get_playlist = function(url, hm, se) { + // special thanks for @Binaryify + // https://github.com/Binaryify/NeteaseCloudMusicApi + return { + success: function (fn) { + var list_id = getParameterByName('list_id', url).split('_').pop(); + var target_url = 'http://music.163.com/weapi/v3/playlist/detail'; + var d = { + id: list_id, + offset: 0, + total: true, + limit: 1000, + n: 1000, + csrf_token: '' + }; + var data = _encrypted_request(d); + + hm({ + url: target_url, + method: 'POST', + data: se(data), + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + } + }).success(function(data) { + var info = { + 'id': 'neplaylist_' + list_id, + 'cover_img_url': data.playlist.coverImgUrl, + 'title': data.playlist.name, + 'source_url': 'http://music.163.com/#/playlist?id=' + list_id + }; + var tracks = []; + $.each(data.playlist.tracks, function(index, track_json){ + var default_track = { + 'id': '0', + 'title': '', + 'artist': '', + 'artist_id': 'neartist_0', + 'album': '', + 'album_id': 'nealbum_0', + 'source': 'netease', + 'source_url': 'http://www.xiami.com/song/0', + 'img_url': '', + 'url': '' + }; + default_track.id = 'netrack_' + track_json.id; + default_track.title = track_json.name; + default_track.artist = track_json.ar[0].name; + default_track.artist_id = 'neartist_' + track_json.ar[0].id; + default_track.album = track_json.al.name; + default_track.album_id = 'nealbum_' + track_json.al.id; + default_track.source_url = 'http://music.163.com/#/song?id=' + track_json.id; + default_track.img_url = track_json.al.picUrl; + default_track.url = default_track.id; + + tracks.push(default_track); + }); + return fn({"info":info,"tracks":tracks}); + }); + } + }; + } + var ne_bootstrap_track = function(sound, track, success, failure, hm, se) { var target_url = 'http://music.163.com/weapi/song/enhance/player/url?csrf_token='; var csrf = ''; diff --git a/listen1.html b/listen1.html index b2c67f6..aaa78aa 100644 --- a/listen1.html +++ b/listen1.html @@ -293,7 +293,7 @@

Listen 1 主页: http://listen1.github.io/listen1/

Listen 1 邮箱: githublisten1@gmail.com

-

当前版本 1.2.2 (本软件基于MIT协议开源免费)

+

当前版本 1.2.3 (本软件基于MIT协议开源免费)