fix netease playlist only show first item bug

This commit is contained in:
Listen 1 2017-11-27 11:01:24 +08:00
parent e3ee309b0e
commit 8f6c61f9d2
3 changed files with 69 additions and 46 deletions

View File

@ -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`
* 修复版权原因无法播放歌曲时自动暂停的问题

View File

@ -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 = '';

View File

@ -293,7 +293,7 @@
<div class="settings-content">
<p> Listen 1 主页: <a href="http://listen1.github.io/listen1/" target="_blank"> http://listen1.github.io/listen1/ </a> </p>
<p> Listen 1 邮箱: githublisten1@gmail.com </p>
<p> 当前版本 1.2.2 (本软件基于MIT协议开源免费)</p>
<p> 当前版本 1.2.3 (本软件基于MIT协议开源免费)</p>
</div>
</div>
</div>