add myplaylist, banner clickable, add copyright filter, refactor music provider code, fix ali singer link error

This commit is contained in:
listen1 2016-05-13 10:20:57 +08:00
parent 4f4f81c267
commit ae4c473169
10 changed files with 509 additions and 189 deletions

View File

@ -1,4 +1,4 @@
Listen 1 (Chrome Extension) 最后更新于5月8日)
Listen 1 (Chrome Extension) 最后更新于5月13日)
==========
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE)
@ -28,6 +28,16 @@ Listen 1 (Chrome Extension) 最后更新于5月8日
更新日志
-------
`2016-05-13`
* 增加我的歌单功能,可以收藏现有歌单,并创建自己的歌单
* 点击Listen 1和图标可以回到首页
* 标记了部分因版权无法播放的歌曲,增加版权提示
* 重构了音乐平台代码,使用统一的接口规范
* 重构了歌单接口,合并歌手,专辑和歌单接口
* 修复了阿里云歌手链接点击错误的bug
`2016-05-08`
* 增加歌词显示
@ -43,7 +53,7 @@ Listen 1 (Chrome Extension) 最后更新于5月8日
TODO
----
加入我的歌单功能如迫不及待需要可以安装Listen 1非插件版
分页加载
License

View File

@ -76,6 +76,12 @@ a {
height: 50px;
width: 50px;
margin-right: 20px;
cursor: pointer;
}
.masthead .masthead-brand {
color: rgba(255,255,255, 1);
cursor: pointer;
}
.cover-container {
@ -428,7 +434,7 @@ em, i {
right: 0px;
bottom: 48px;
z-index: 10;
width: 79px;
width: 103px;
padding-left: 13px;
float: none;
}
@ -490,6 +496,10 @@ em, i {
text-indent: -9999px;
}
.m-playbar .icn-add {
margin-right: 5px;
}
.m-playbar .menu {
position: absolute;
bottom: 90px;
@ -717,7 +727,7 @@ li {
background-position: -256px -36px;
}
.playlist-detail .detail-head-title .delete {
.playlist-detail .detail-head-title .edit {
display: inline-block;
text-indent: -9999px;
width: 36px;
@ -725,12 +735,12 @@ li {
margin-right: 8px;
margin-top: 0;
background: url(../images/player_large.png) no-repeat 0 9999px;
background-position: -180px 0px;
background-position: -288px 0px;
}
.playlist-detail .detail-head-title .delete:hover {
.playlist-detail .detail-head-title .edit:hover {
background: url(../images/player_large.png) no-repeat 0 9999px;
background-position: -180px -36px;
background-position: -288px -36px;
}
.playlist-detail .detail-head-title .clone {
@ -789,6 +799,10 @@ li {
margin-left: 2%;
}
.detail-songlist .disabled {
color: #777777;
}
.detail-songlist .col-add {
float: left;
width: 75px;
@ -920,7 +934,18 @@ li {
}
.dialog-newplaylist .confirm-button {
margin-right: 64px;
margin-left: 76px;
margin-right: 96px;
}
.dialog-editplaylist .dialog-footer {
position: absolute;
bottom: 20px;
}
.dialog-editplaylist .confirm-button {
margin-right: 82px;
margin-left: 93px;
}
.source-list {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 7.7 KiB

169
js/app.js
View File

@ -68,6 +68,7 @@
$scope.dialog_title = '';
$scope.isDoubanLogin = false;
$scope.$on('isdoubanlogin:update', function(event, data) {
$scope.isDoubanLogin = data;
});
@ -104,7 +105,7 @@
$scope.playlist_title = data.info.title;
$scope.playlist_source_url = data.info.source_url;
$scope.list_id = data.info.id;
$scope.is_mine = data.is_mine;
$scope.is_mine = (data.info.id.slice(0,2) == 'my');
});
};
@ -124,9 +125,11 @@
var url = $scope.window_url_stack[$scope.window_url_stack.length-1];
loWeb.get(url).success(function(data) {
$scope.songs = data.tracks;
$scope.list_id = data.info.id;
$scope.cover_img_url = data.info.cover_img_url;
$scope.playlist_title = data.info.title;
$scope.playlist_source_url = data.info.source_url;
$scope.is_mine = (data.info.id.slice(0,2) == 'my');
});
}
};
@ -136,16 +139,6 @@
$scope.showWindow(url);
};
$scope.showArtist = function(artist_id) {
var url = '/artist?artist_id=' + artist_id;
$scope.showWindow(url);
};
$scope.showAlbum = function(album_id) {
var url = '/album?album_id=' + album_id;
$scope.showWindow(url);
};
$scope.directplaylist = function(list_id){
var url = '/playlist?list_id=' + list_id;
@ -182,7 +175,7 @@
$scope.dialog_title = '添加到歌单';
var url = '/show_myplaylist';
$scope.dialog_song = data;
$http.get(url).success(function(data) {
loWeb.get(url).success(function(data) {
$scope.myplaylist = data.result;
});
}
@ -191,25 +184,23 @@
$scope.dialog_title = '登录豆瓣';
$scope.dialog_type = 2;
}
if (dialog_type == 3) {
$scope.dialog_title = '修改歌单';
$scope.dialog_type = 3;
$scope.dialog_cover_img_url = data.cover_img_url;
$scope.dialog_playlist_title = data.playlist_title;
}
};
$scope.chooseDialogOption = function(option_id) {
var url = '/add_myplaylist';
$http({
loWeb.post({
url: url,
method: 'POST',
data: $httpParamSerializerJQLike({
list_id: option_id,
id: $scope.dialog_song.id,
title: $scope.dialog_song.title,
artist: $scope.dialog_song.artist,
url: $scope.dialog_song.url,
artist_id: $scope.dialog_song.artist_id,
album: $scope.dialog_song.album,
album_id: $scope.dialog_song.album_id,
source: $scope.dialog_song.source,
source_url: $scope.dialog_song.source_url
track: JSON.stringify($scope.dialog_song)
}),
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
@ -235,20 +226,12 @@
$scope.createAndAddPlaylist = function() {
var url = '/create_myplaylist';
$http({
loWeb.post({
url: url,
method: 'POST',
data: $httpParamSerializerJQLike({
list_title: $scope.newlist_title,
id: $scope.dialog_song.id,
title: $scope.dialog_song.title,
artist: $scope.dialog_song.artist,
url: $scope.dialog_song.url,
artist_id: $scope.dialog_song.artist_id,
album: $scope.dialog_song.album,
album_id: $scope.dialog_song.album_id,
source: $scope.dialog_song.source,
source_url: $scope.dialog_song.source_url
track: JSON.stringify($scope.dialog_song)
}),
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
@ -260,10 +243,33 @@
});
};
$scope.editMyPlaylist = function() {
var url = '/edit_myplaylist';
loWeb.post({
url: url,
method: 'POST',
data: $httpParamSerializerJQLike({
list_id: $scope.list_id,
title: $scope.dialog_playlist_title,
cover_img_url: $scope.dialog_cover_img_url
}),
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}).success(function() {
$rootScope.$broadcast('myplaylist:update');
$scope.playlist_title = $scope.dialog_playlist_title;
$scope.cover_img_url = $scope.dialog_cover_img_url;
Notification.success('修改歌单成功');
$scope.closeDialog();
});
};
$scope.removeSongFromPlaylist = function(song, list_id) {
var url = '/remove_track_from_myplaylist';
$http({
loWeb.post({
url: url,
method: 'POST',
data: $httpParamSerializerJQLike({
@ -318,6 +324,48 @@
}, 0);
};
$scope.copyrightNotice = function() {
Notification.info("版权原因无法播放,请搜索其他平台");
};
$scope.clonePlaylist = function(list_id){
var url = '/clone_playlist';
loWeb.post({
url: url,
method: 'POST',
data: $httpParamSerializerJQLike({
list_id: list_id,
}),
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}).success(function() {
$rootScope.$broadcast('myplaylist:update');
$scope.closeWindow();
Notification.success('收藏到我的歌单成功');
});
};
$scope.removeMyPlaylist = function(list_id){
var url = '/remove_myplaylist';
loWeb.post({
url: url,
method: 'POST',
data: $httpParamSerializerJQLike({
list_id: list_id,
}),
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}).success(function() {
$rootScope.$broadcast('myplaylist:update');
$scope.closeDialog();
$scope.closeWindow();
Notification.success('删除歌单成功');
});
};
}]);
app.controller('PlayController', ['$scope', '$timeout','$log',
@ -461,46 +509,6 @@
angularPlayer.mute();
}
$scope.removemylist = function(list_id){
var url = '/remove_myplaylist';
$http({
url: url,
method: 'POST',
data: $httpParamSerializerJQLike({
list_id: list_id,
}),
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}).success(function() {
$rootScope.$broadcast('myplaylist:update');
$scope.closeWindow();
Notification.success('删除成功');
});
};
$scope.clonelist = function(list_id){
var url = '/clone_playlist';
$http({
url: url,
method: 'POST',
data: $httpParamSerializerJQLike({
list_id: list_id,
}),
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}).success(function() {
$rootScope.$broadcast('myplaylist:update');
$scope.closeWindow();
Notification.success('收藏到我的歌单成功');
});
};
$scope.myProgress = 0;
$scope.changingProgress = false;
@ -607,6 +615,9 @@
}
loWeb.get(url).success(function(data) {
var lyric = data.lyric;
if (lyric == null) {
return;
}
$scope.lyricArray = parseLyric(lyric);
});
});
@ -627,7 +638,6 @@
var lineElement = $(".lyric p")[lastObject.lineNumber];
var windowHeight = 270;
var offset = lineElement.offsetTop - windowHeight/2;
//$(".lyric").scrollTop(offset);
$(".lyric").animate({ scrollTop: offset+"px" }, 500);
$scope.lyricLineNumber = lastObject.lineNumber;
}
@ -840,11 +850,12 @@
}]);
app.controller('MyPlayListController', ['$http','$scope', '$timeout',
'angularPlayer', function($http, $scope, $timeout, angularPlayer){
'angularPlayer', 'loWeb',
function($http, $scope, $timeout, angularPlayer, loWeb){
$scope.myplaylists = [];
$scope.loadMyPlaylist = function(){
$http.get('/show_myplaylist').success(function(data) {
loWeb.get('/show_myplaylist').success(function(data) {
$scope.myplaylists = data.result;
});
};
@ -876,10 +887,6 @@
loWeb.get('/show_playlist?source=' + getSourceName($scope.tab)).success(function(data) {
$scope.result = data.result;
});
// $http.get('/show_playlist?source=' + $scope.tab).success(function(data) {
// $scope.result = data.result;
// });
};
$scope.isActiveTab = function(tab){

View File

@ -23,6 +23,9 @@ function getProviderByItemId(itemId) {
if (prefix == 'qq') {
return qq;
}
if (prefix == 'my') {
return myplaylist;
}
}
ngloWebManager.factory('loWeb', ['$rootScope', '$log', '$http', '$httpParamSerializerJQLike',
@ -37,29 +40,88 @@ function($rootScope, $log, $http, $httpParamSerializerJQLike) {
if (url.search('/playlist') != -1) {
var list_id = getParameterByName('list_id', url);
var provider = getProviderByItemId(list_id);
return provider.get_playlist(url, $http);
return provider.get_playlist(url, $http, $httpParamSerializerJQLike);
}
if (url.search('/search') != -1) {
var source = getParameterByName('source', url);
var provider = getProviderByName(source);
return provider.search(url, $http, $httpParamSerializerJQLike);
}
if (url.search('/album') != -1) {
var album_id = getParameterByName('album_id', url);
var provider = getProviderByItemId(album_id);
return provider.album(url, $http, $httpParamSerializerJQLike);
}
if (url.search('/artist') != -1) {
var artist_id = getParameterByName('artist_id', url);
var provider = getProviderByItemId(artist_id);
return provider.artist(url, $http, $httpParamSerializerJQLike);
}
if (url.search('/lyric') != -1) {
var track_id = getParameterByName('track_id', url);
var provider = getProviderByItemId(track_id);
return provider.lyric(url, $http, $httpParamSerializerJQLike);
}
if (url.search('/show_myplaylist') != -1) {
return myplaylist.show_myplaylist();
}
},
post: function(request) {
if (request.url.search('/clone_playlist') != -1) {
var list_id = getParameterByName('list_id', url+'?'+request.data);
var provider = getProviderByItemId(list_id);
var url = '/playlist?list_id=' + list_id;
return {
success: function(fn) {
provider.get_playlist(url, $http).success(function(data){
myplaylist.save_myplaylist(data);
fn();
});
}
};
}
if (request.url.search('/remove_myplaylist') != -1) {
var list_id = getParameterByName('list_id', url+'?'+request.data);
myplaylist.remove_myplaylist(list_id);
return {
success: function(fn) {
fn();
}
};
}
if (request.url.search('/add_myplaylist') != -1) {
var list_id = getParameterByName('list_id', url+'?'+request.data);
var track_json = getParameterByName('track', url+'?'+request.data);
var track = JSON.parse(track_json);
myplaylist.add_myplaylist(list_id, track);
return {
success: function(fn) {
fn();
}
};
}
if (request.url.search('/remove_track_from_myplaylist') != -1) {
var list_id = getParameterByName('list_id', url+'?'+request.data);
var track_id = getParameterByName('track_id', url+'?'+request.data);
myplaylist.remove_from_myplaylist(list_id, track_id);
return {
success: function(fn) {
fn();
}
};
}
if (request.url.search('/create_myplaylist') != -1) {
var list_title = getParameterByName('list_title', url+'?'+request.data);
var track_json = getParameterByName('track', url+'?'+request.data);
var track = JSON.parse(track_json);
myplaylist.create_myplaylist(list_title, track);
return {
success: function(fn) {
fn();
}
};
}
if (request.url.search('/edit_myplaylist') != -1) {
var list_id = getParameterByName('list_id', url+'?'+request.data);
var title = getParameterByName('title', url+'?'+request.data);
var cover_img_url = getParameterByName('cover_img_url', url+'?'+request.data);
myplaylist.edit_myplaylist(list_id, title, cover_img_url);
return {
success: function(fn) {
fn();
}
};
}
},
bootstrapTrack: function(success, failure) {
return function(sound, track, callback){

138
js/myplaylist.js Normal file
View File

@ -0,0 +1,138 @@
var myplaylist = (function() {
'use strict';
var show_myplaylist = function() {
return {
success: function(fn){
var playlists = localStorage.getObject('playerlists');
if (playlists == null) {
playlists = [];
}
var result = [];
for (var i=0; i<playlists.length; i++) {
var playlist_id = playlists[i];
var playlist = localStorage.getObject(playlist_id);
if (playlist != null) {
result.push(playlist)
}
}
return fn({'result': result});
}
}
}
var my_get_playlist = function(url, hm, se) {
var list_id = getParameterByName('list_id', url);
return {
success: function(fn) {
var playlist = localStorage.getObject(list_id);
fn(playlist);
}
};
}
function guid() {
function s4() {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
}
return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
s4() + '-' + s4() + s4() + s4();
}
var save_myplaylist = function(playlist) {
var playlists = localStorage.getObject('playerlists');
if (playlists == null) {
playlists = [];
}
// update listid
var playlist_id = 'myplaylist_' + guid();
playlist.info.id = playlist_id;
playlist.is_mine = 1;
playlists.push(playlist_id);
localStorage.setObject('playerlists', playlists);
localStorage.setObject(playlist_id, playlist);
}
var remove_myplaylist = function(playlist_id) {
var playlists = localStorage.getObject('playerlists');
if (playlists == null) {
return;
}
var newplaylists = [];
for (var i=0; i<playlists.length; i++) {
if (playlists[i] == playlist_id) {
continue;
}
newplaylists.push(playlists[i]);
}
localStorage.removeItem(playlist_id);
localStorage.setObject('playerlists', newplaylists);
}
var add_myplaylist = function(playlist_id, track) {
var playlist = localStorage.getObject(playlist_id);
if (playlist == null) {
return;
}
playlist.tracks.push(track);
localStorage.setObject(playlist_id, playlist);
}
var remove_from_myplaylist = function(playlist_id, track_id) {
var playlist = localStorage.getObject(playlist_id);
if (playlist == null) {
return;
}
var newtracks = [];
for (var i=0; i<playlist.tracks.length; i++) {
if (playlist.tracks[i].id == track_id) {
continue;
}
newtracks.push(playlist.tracks[i]);
}
playlist.tracks = newtracks;
localStorage.setObject(playlist_id, playlist);
}
var create_myplaylist = function(playlist_title, track) {
var playlist = {};
var info = {};
var info = {
'cover_img_url' : '/images/mycover.jpg',
'title': playlist_title,
'id': '',
'source_url': ''
};
playlist.is_mine = 1;
playlist.info = info;
playlist.tracks = [track];
save_myplaylist(playlist);
}
var edit_myplaylist = function(playlist_id, title, cover_img_url) {
var playlist = localStorage.getObject(playlist_id);
if (playlist == null) {
return;
}
playlist.info.title = title;
playlist.info.cover_img_url = cover_img_url;
localStorage.setObject(playlist_id, playlist);
}
return {
show_myplaylist: show_myplaylist,
save_myplaylist: save_myplaylist,
get_playlist: my_get_playlist,
remove_myplaylist: remove_myplaylist,
add_myplaylist: add_myplaylist,
remove_from_myplaylist: remove_from_myplaylist,
create_myplaylist: create_myplaylist,
edit_myplaylist: edit_myplaylist
};
})();

View File

@ -13,14 +13,14 @@ var netease = (function() {
var default_playlist = {
'cover_img_url' : '',
'title': '',
'list_id': '',
'id': '',
'source_url': ''
};
default_playlist.cover_img_url = $(this).find('img')[0].src;
default_playlist.title = $(this).find('div a')[0].title;
var url = $(this).find('div a')[0].href;
var list_id = getParameterByName('id',url);
default_playlist.list_id = 'neplaylist_' + list_id;
default_playlist.id = 'neplaylist_' + list_id;
default_playlist.source_url = 'http://music.163.com/#/playlist?id=' + list_id;
result.push(default_playlist);
});
@ -30,7 +30,7 @@ var netease = (function() {
};
}
var ne_get_playlist = function(url, hm) {
var ne_get_playlist = function(url, hm, se) {
var list_id = getParameterByName('list_id', url).split('_').pop();
var target_url = 'http://music.163.com/playlist?id=' + list_id;
return {
@ -39,10 +39,10 @@ var netease = (function() {
data = $.parseHTML(data);
var dataObj = $(data);
var info = {
'list_id': list_id,
'id': 'neplaylist_' + list_id,
'cover_img_url': dataObj.find('.u-cover img').attr('src'),
'title': dataObj.find('.tit h2').text(),
'source_url': 'http://music.163.com/#/playlist?id=' + list_id
'source_url': 'http://music.163.com/#/playlist?id=' + list_id,
};
var tracks = [];
var json_string = dataObj.find('textarea').val();
@ -69,9 +69,10 @@ var netease = (function() {
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,'is_mine':'0'});
return fn({"info":info,"tracks":tracks});
});
}
};
@ -198,6 +199,11 @@ var netease = (function() {
});
}
function is_playable(song) {
return ((song.status >= 0) && (song.fee != 4));
}
var ne_search = function(url, hm, se) {
// use chrome extension to modify referer.
var target_url = 'http://music.163.com/api/search/pc';
@ -220,9 +226,6 @@ var netease = (function() {
}).success(function(data) {
var tracks = [];
$.each(data.result.songs, function(index, song_info) {
if (song_info.status == -1) {
return;
}
var default_track = {
'id': 'netrack_' + song_info.id,
'title': song_info.name,
@ -233,8 +236,14 @@ var netease = (function() {
'source': 'netease',
'source_url': 'http://music.163.com/#/song?id=' + song_info.id,
'img_url': song_info.album.picUrl,
'url': 'netrack_' + song_info.id
'url': 'netrack_' + song_info.id,
};
if (!is_playable(song_info)) {
default_track.disabled = true;
}
else {
default_track.disabled = false;
}
tracks.push(default_track);
});
return fn({"result":tracks});
@ -245,7 +254,7 @@ var netease = (function() {
var ne_album = function(url, hm, se) {
var album_id = getParameterByName('album_id', url).split('_').pop();
var album_id = getParameterByName('list_id', url).split('_').pop();
// use chrome extension to modify referer.
var target_url = 'http://music.163.com/api/album/' + album_id;
@ -276,16 +285,22 @@ var netease = (function() {
'img_url': song_info.album.picUrl,
'url': 'netrack_' + song_info.id
};
if (!is_playable(song_info)) {
default_track.disabled = true;
}
else {
default_track.disabled = false;
}
tracks.push(default_track);
});
return fn({"tracks":tracks, "info":info, "is_mine": 0});
return fn({"tracks":tracks, "info":info});
});
}
};
}
var ne_artist = function(url, hm, se) {
var artist_id = getParameterByName('artist_id', url).split('_').pop();
var artist_id = getParameterByName('list_id', url).split('_').pop();
// use chrome extension to modify referer.
var target_url = 'http://music.163.com/api/artist/' + artist_id;
@ -316,9 +331,15 @@ var netease = (function() {
'img_url': song_info.album.picUrl,
'url': 'netrack_' + song_info.id
};
if (!is_playable(song_info)) {
default_track.disabled = true;
}
else {
default_track.disabled = false;
}
tracks.push(default_track);
});
return fn({"tracks":tracks, "info":info, "is_mine": 0});
return fn({"tracks":tracks, "info":info});
});
}
};
@ -356,13 +377,24 @@ var netease = (function() {
};
}
var get_playlist = function(url, hm, se) {
var list_id = getParameterByName('list_id', url).split('_')[0];
if (list_id == 'neplaylist') {
return ne_get_playlist(url, hm, se);
}
if (list_id == 'nealbum') {
return ne_album(url, hm, se);
}
if (list_id == 'neartist') {
return ne_artist(url, hm, se);
}
}
return {
show_playlist: ne_show_playlist,
get_playlist: ne_get_playlist,
get_playlist: get_playlist,
bootstrap_track: ne_bootstrap_track,
search: ne_search,
album: ne_album,
artist: ne_artist,
lyric: ne_lyric,
};

View File

@ -29,7 +29,7 @@ var qq = (function() {
var d = {
'cover_img_url': item.imgurl,
'title': htmlDecode(item.dissname),
'list_id':'qqplaylist_' + item.dissid,
'id':'qqplaylist_' + item.dissid,
'source_url': 'http://y.qq.com/#type=taoge&id=' + item.dissid
};
@ -67,7 +67,8 @@ var qq = (function() {
'source': 'qq',
'source_url': 'http://y.qq.com/#type=song&mid=' +
song.songmid + '&tpl=yqq_song_detail',
'url': 'qqtrack_' + song.songmid
'url': 'qqtrack_' + song.songmid,
'disabled': !qq_is_playable(song)
}
return d
}
@ -83,7 +84,7 @@ var qq = (function() {
return ((play_flag == 1) || ((play_flag == 1) && (try_flag == 1)));
}
var qq_get_playlist = function(url, hm) {
var qq_get_playlist = function(url, hm, se) {
var list_id = getParameterByName('list_id', url).split('_').pop();
return {
@ -111,10 +112,8 @@ var qq = (function() {
var tracks = [];
$.each(data.cdlist[0].songlist, function(index, item){
if (qq_is_playable(item)) {
var track = qq_convert_song(item);
tracks.push(track);
}
var track = qq_convert_song(item);
tracks.push(track);
});
return fn({"tracks":tracks, "info":info});
});
@ -123,7 +122,7 @@ var qq = (function() {
}
var qq_album = function(url, hm) {
var album_id = getParameterByName('album_id', url).split('_').pop();
var album_id = getParameterByName('list_id', url).split('_').pop();
return {
success: function(fn) {
@ -150,10 +149,8 @@ var qq = (function() {
var tracks = [];
$.each(data.data.list, function(index, item){
if (qq_is_playable(item)) {
var track = qq_convert_song(item);
tracks.push(track);
}
var track = qq_convert_song(item);
tracks.push(track);
});
return fn({"tracks":tracks, "info":info});
});
@ -162,7 +159,7 @@ var qq = (function() {
}
var qq_artist = function(url, hm) {
var artist_id = getParameterByName('artist_id', url).split('_').pop();
var artist_id = getParameterByName('list_id', url).split('_').pop();
return {
success: function(fn) {
@ -190,10 +187,8 @@ var qq = (function() {
var tracks = [];
$.each(data.data.list, function(index, item){
if (qq_is_playable(item.musicData)) {
var track = qq_convert_song(item.musicData);
tracks.push(track);
}
var track = qq_convert_song(item.musicData);
tracks.push(track);
});
return fn({"tracks":tracks, "info":info});
});
@ -221,10 +216,8 @@ var qq = (function() {
data = JSON.parse(data);
var tracks = [];
$.each(data.data.song.list, function(index, item){
if (qq_is_playable(item)) {
var track = qq_convert_song(item);
tracks.push(track);
}
var track = qq_convert_song(item);
tracks.push(track);
});
return fn({"result":tracks});
});
@ -291,13 +284,25 @@ var qq = (function() {
};
}
var get_playlist = function(url, hm, se) {
var list_id = getParameterByName('list_id', url).split('_')[0];
if (list_id == 'qqplaylist') {
return qq_get_playlist(url, hm, se);
}
if (list_id == 'qqalbum') {
return qq_album(url, hm, se);
}
if (list_id == 'qqartist') {
return qq_artist(url, hm, se);
}
}
return {
show_playlist: qq_show_playlist,
get_playlist: qq_get_playlist,
get_playlist: get_playlist,
bootstrap_track: qq_bootstrap_track,
search: qq_search,
album: qq_album,
artist: qq_artist,
lyric: qq_lyric,
};

View File

@ -46,14 +46,14 @@ var xiami = (function() {
var default_playlist = {
'cover_img_url' : '',
'title': '',
'list_id': '',
'id': '',
'source_url': ''
};
default_playlist.cover_img_url = $(this).find('img')[0].src;
default_playlist.title = $(this).find('h3 a')[0].title;
var xiami_url = $(this).find('h3 a')[0].href;
var list_id = xiami_url.split('?')[0].split('/').pop()
default_playlist.list_id = 'xmplaylist_' + list_id;
default_playlist.id = 'xmplaylist_' + list_id;
default_playlist.source_url = 'http://www.xiami.com/collect/' + list_id;
result.push(default_playlist);
});
@ -63,7 +63,7 @@ var xiami = (function() {
};
}
var xm_get_playlist = function(url, hm) {
var xm_get_playlist = function(url, hm, se) {
var list_id = getParameterByName('list_id', url).split('_').pop();
return {
@ -101,6 +101,10 @@ var xiami = (function() {
var target_url = 'http://www.xiami.com/song/playlist/id/' + track.id.slice('xmtrack_'.length) +
'/object_name/default/object_id/0/cat/json';
hm.get(target_url).success(function(data) {
if (data.data.trackList == null) {
failure();
return;
}
var location = data.data.trackList[0].location;
sound.url = caesar(location);
track.img_url = data.data.trackList[0].pic;
@ -155,7 +159,7 @@ var xiami = (function() {
var xm_album = function(url, hm, se) {
return {
success: function(fn) {
var album_id = getParameterByName('album_id', url).split('_').pop();
var album_id = getParameterByName('list_id', url).split('_').pop();
var target_url = 'http://api.xiami.com/web?v=2.0&app_key=1&id=' + album_id +
'&page=1&limit=20&callback=jsonp217&r=album/detail';
hm({
@ -188,7 +192,7 @@ var xiami = (function() {
var xm_artist = function (url, hm, se) {
return {
success: function(fn) {
var artist_id = getParameterByName('artist_id', url).split('_').pop();
var artist_id = getParameterByName('list_id', url).split('_').pop();
var target_url = 'http://api.xiami.com/web?v=2.0&app_key=1&id=' + artist_id +
'&page=1&limit=20&_ksTS=1459931285956_216' +
@ -224,6 +228,7 @@ var xiami = (function() {
var tracks = [];
$.each(data.data, function(index, item){
var track = xm_convert_song(item, 'singers');
track.artist_id = 'xmartist_' + artist_id;
tracks.push(track);
});
return fn({"tracks":tracks,"info": info});
@ -249,13 +254,23 @@ var xiami = (function() {
};
}
var get_playlist = function(url, hm, se) {
var list_id = getParameterByName('list_id', url).split('_')[0];
if (list_id == 'xmplaylist') {
return xm_get_playlist(url, hm, se);
}
if (list_id == 'xmalbum') {
return xm_album(url, hm, se);
}
if (list_id == 'xmartist') {
return xm_artist(url, hm, se);
}
}
return {
show_playlist: xm_show_playlist,
get_playlist: xm_get_playlist,
get_playlist: get_playlist,
bootstrap_track: xm_bootstrap_track,
search: xm_search,
album: xm_album,
artist: xm_artist,
lyric: xm_lyric,
};

View File

@ -26,7 +26,8 @@
<script type="text/javascript" src="js/lowebutil.js"></script>
<script type="text/javascript" src="js/xiami.js"></script>
<script type="text/javascript" src="js/qq.js"></script>
<script type="text/javascript" src="js/netease.js"></script>
<script type="text/javascript" src="js/netease.js"></script>
<script type="text/javascript" src="js/myplaylist.js"></script>
<script type="text/javascript" src="js/loweb.js"></script>
<script type="text/javascript" src="js/app.js"></script>
@ -35,29 +36,29 @@
<body ng-app="listenone" ng-controller="NavigationController">
<!-- dialog -->
<!-- <div class="shadow" ng-hide="is_dialog_hidden==1"></div>
<div class="shadow" ng-hide="is_dialog_hidden==1"></div>
<div class="dialog" ng-hide="is_dialog_hidden==1" ng-style="myStyle">
<div class="dialog-header"> <span>{{ dialog_title }}</span> <span class="dialog-close" ng-click="closeDialog()">×</span></div>
<div class="dialog-body"> -->
<div class="dialog-body">
<!-- choose playlist dialog -->
<!-- <ul class="dialog-playlist" ng-show="dialog_type==0">
<ul class="dialog-playlist" ng-show="dialog_type==0">
<li class="detail-add" ng-click="newDialogOption()">
<img src="images/mycover.jpg" />
<h2> 新建歌单 </h2>
</li>
<li ng-repeat="playlist in myplaylist" ng-class-odd="'odd'" ng-class-even="'even'" ng-click="chooseDialogOption(playlist.list_id)">
<img ng-src="{{ playlist.cover_img_url }}" />
<h2> {{ playlist.title }} </h2>
<li ng-repeat="playlist in myplaylist" ng-class-odd="'odd'" ng-class-even="'even'" ng-click="chooseDialogOption(playlist.info.id)">
<img ng-src="{{ playlist.info.cover_img_url }}" />
<h2> {{ playlist.info.title }} </h2>
</li>
</ul> -->
</ul>
<!-- create new playlist dialog -->
<!-- <div ng-show="dialog_type==1" class="dialog-newplaylist">
<div ng-show="dialog_type==1" class="dialog-newplaylist">
<input type="text" class="form-control" placeholder="输入歌单名称" ng-model="newlist_title"/>
<button class="btn btn-primary confirm-button" ng-click="createAndAddPlaylist()">创建并添加</button>
<button class="btn btn-default" ng-click="cancelNewDialog()">取消</button>
</div> -->
</div>
<!-- login douban dialog -->
<!-- <div ng-show="dialog_type==2" class="dbimport" ng-controller="ImportController" ng-init="getLoginInfo()" >
@ -76,19 +77,37 @@
<button class="btn btn-lg btn-primary btn-block" ng-click="logoutDouban()" ng-show="isDoubanLogin">退出登录</button>
<p ng-show="isDoubanLogin">{{ status }}</p>
</div> -->
<!--
<!-- edit playlist dialog -->
<div ng-show="dialog_type==3" class="dialog-editplaylist">
<div class="form-group">
<label >标题</label>
<input type="text" class="form-control" placeholder="输入歌单名称" ng-model="dialog_playlist_title"/>
</div>
<div class="form-group">
<label >封面图片url</label>
<input type="text" class="form-control" placeholder="输入歌单名称" ng-model="dialog_cover_img_url"/>
</div>
<button class="btn btn-primary confirm-button" ng-click="editMyPlaylist(list_id)">修改歌单</button>
<button class="btn btn-default" ng-click="cancelNewDialog()">取消</button>
<div class='dialog-footer'>
<button class="btn btn-danger remove-button" ng-click="removeMyPlaylist(list_id)">删除歌单</button>
</div>
</div>
</div>
</div> -->
</div>
<!-- page header -->
<div class="masthead clearfix">
<div class="inner">
<img class="logo" src="images/logo.png" />
<h3 class="masthead-brand">Listen 1</h3>
<img class="logo" src="images/logo.png" ng-click="showTag(2)" />
<h3 class="masthead-brand" ng-click="showTag(2)">Listen 1</h3>
<nav>
<ul class="nav masthead-nav">
<!-- <li ng-class="{ 'active':current_tag==1 }"><a ng-click="showTag(1)">我的歌单</a></li> -->
<li ng-class="{ 'active':current_tag==2 }"><a ng-click="showTag(2)">精选歌单</a></li>
<li ng-class="{ 'active':current_tag==1 }"><a ng-click="showTag(1)">我的歌单</a></li>
<li ng-class="{ 'active':current_tag==3 }"><a ng-click="showTag(3)">快速搜索</a></li>
<li ng-class="{ 'active':current_tag==4 }"><a ng-click="showTag(4)">关于</a></li>
</ul>
@ -98,29 +117,29 @@
<!-- content page: 我的歌单 -->
<!-- <div class="site-wrapper" ng-show="current_tag==1" ng-controller="MyPlayListController">
<div class="site-wrapper" ng-show="current_tag==1" ng-controller="MyPlayListController">
<div class="site-wrapper-innerd" resize>
<div class="cover-container">
<div class="playlist" ng-init="loadMyPlaylist();">
<ul class="playlist-covers">
<li ng-repeat="i in myplaylists ">
<div class="u-cover">
<img ng-src="{{i.cover_img_url}}">
<a title="" class="mask" ng-click="showPlaylist(i.list_id)"></a>
<img ng-src="{{i.info.cover_img_url}}">
<a title="" class="mask" ng-click="showPlaylist(i.info.id)"></a>
<div class="bottom">
<span class="icon-headset"></span>
<a class="icon-play" ng-click="directplaylist(i.list_id)" title="播放"></a>
<a class="icon-play" ng-click="directplaylist(i.info.id)" title="播放"></a>
</div>
</div>
<p class="desc">
<a title="" ng-click="showPlaylist(i.list_id)">{{i.title}}</a>
<a title="" ng-click="showPlaylist(i.list_id)">{{i.info.title}}</a>
</p>
</li>
</ul>
</div>
</div>
</div>
</div> -->
</div>
<!-- content page: 精选歌单 -->
@ -138,9 +157,9 @@
<li ng-repeat="i in result ">
<div class="u-cover">
<img ng-src="{{i.cover_img_url}}">
<a title="" class="mask" ng-click="showPlaylist(i.list_id)"></a>
<a title="" class="mask" ng-click="showPlaylist(i.id)"></a>
<div class="bottom">
<a class="icon-play" title="播放" ng-click="directplaylist(i.list_id)"></a>
<a class="icon-play" title="播放" ng-click="directplaylist(i.id)"></a>
</div>
</div>
<p class="desc">
@ -172,13 +191,16 @@
<ul class="detail-songlist">
<li ng-repeat="song in result" ng-class-odd="'odd'" ng-class-even="'even'" ng-mouseenter="options=true" ng-mouseleave="options=false">
<div class="col2"><a add-and-play="song">{{ song.title }}</a></div>
<div class="col1 detail-artist"><a ng-click="showArtist(song.artist_id)">{{ song.artist }}</a></div>
<div class="col2"><a ng-click="showAlbum(song.album_id)">{{ song.album }}</a></div>
<div class="col2">
<a ng-if="song.disabled" class="disabled" ng-click="copyrightNotice()">{{ song.title }}</a>
<a ng-if="!song.disabled" add-and-play="song">{{ song.title }}</a>
</div>
<div class="col1 detail-artist"><a ng-click="showPlaylist(song.artist_id)">{{ song.artist }}</a></div>
<div class="col2"><a ng-click="showPlaylist(song.album_id)">{{ song.album }}</a></div>
<div class="detail-tools">
<a title="添加到当前播放" class="detail-add-button" add-without-play="song" ng-show="options"></a>
<!-- <a title="添加到歌单" class="detail-fav-button" ng-show="options" ng-click="showDialog(0, song)"></a> -->
<a title="添加到歌单" class="detail-fav-button" ng-show="options" ng-click="showDialog(0, song)"></a>
<a title="原始链接" class="source-button" open-url="song.source_url" ng-show="options"></a>
</div>
</li>
@ -202,7 +224,7 @@
<div class="settings-content">
<p> Listen 1 (Chrome Extension) 主页: <a href="https://github.com/listen1/listen1_chrome_extension" target="_blank"> https://github.com/listen1/listen1_chrome_extension </a> </p>
<p> Listen 1 邮箱: githublisten1@gmail.com </p>
<p> 当前版本 1.0 (本软件基于MIT协议开源免费)</p>
<p> 当前版本 1.1 (本软件基于MIT协议开源免费)</p>
</div>
</div>
</div>
@ -227,21 +249,25 @@
<h2>{{ playlist_title }}</h2>
<a title="播放歌单" class="play" ng-show="playlist_title!=''" ng-click="playMylist(list_id)">播放</a>
<a title="添加到当前播放" class="add" ng-show="playlist_title!=''" ng-click="addMylist(list_id)">添加到当前播放</a>
<a title="收藏歌单" class="clone" ng-show="playlist_title!='' && !is_mine" ng-click="clonePlaylist(list_id)">收藏</a>
<a title="编辑歌单" class="edit" ng-show="playlist_title!='' && is_mine" ng-click="showDialog(3, {list_id: list_id, playlist_title: playlist_title, cover_img_url: cover_img_url})">编辑</a>
<a title="原始链接" class="link" ng-show="playlist_title!=''" open-url="playlist_source_url">原始链接</a>
<!-- <a title="删除歌单" class="delete" ng-show="playlist_title!='' && is_mine=='1'" ng-click="removemylist(list_id)">删除</a>
<a title="收藏歌单" class="clone" ng-show="playlist_title!='' && is_mine=='0'" ng-click="clonelist(list_id)">收藏</a> -->
</div>
</div>
<ul class="detail-songlist">
<li ng-repeat="song in songs" ng-class-odd="'odd'" ng-class-even="'even'" ng-mouseenter="options=true" ng-mouseleave="options=false">
<div class="col2"><a add-and-play="song">{{ song.title }}</a></div>
<div class="col1 detail-artist"><a ng-click="showArtist(song.artist_id)">{{ song.artist }}</a></div>
<div class="col2"><a ng-click="showAlbum(song.album_id)">{{ song.album }}</a></div>
<div class="col2">
<a ng-if="song.disabled" class="disabled" ng-click="copyrightNotice()">{{ song.title }}</a>
<a ng-if="!song.disabled" add-and-play="song">{{ song.title }}</a>
</div>
<div class="col1 detail-artist"><a ng-click="showPlaylist(song.artist_id)">{{ song.artist }}</a></div>
<div class="col2"><a ng-click="showPlaylist(song.album_id)">{{ song.album }}</a></div>
<div class="detail-tools">
<a title="添加到当前播放" class="detail-add-button" add-without-play="song" ng-show="options"></a>
<!-- <a title="添加到歌单" class="detail-fav-button" ng-click="showDialog(0, song)" ng-show="options"></a> -->
<a title="添加到歌单" class="detail-fav-button" ng-click="showDialog(0, song)" ng-show="options"></a>
<a title="从歌单删除" class="detail-delete-button" ng-click="removeSongFromPlaylist(song, list_id)" ng-show="options && is_mine=='1' "></a>
<a title="原始链接" class="source-button" open-url="song.source_url" ng-show="options"></a>
<!-- <a title="从歌单删除" class="detail-delete-button" ng-click="removeSongFromPlaylist(song, list_id)" ng-show="options && is_mine=='1' "></a> -->
</div>
</li>
</ul>
@ -263,7 +289,7 @@
<div class="head">
<!-- <img ng-src="{{ currentPlaying.img_url }}" err-src="images/placeholder.png"> -->
<img ng-src="{{ currentPlaying.img_url }}">
<a ng-click="showAlbum(currentPlaying.album_id)" class="mask"></a>
<a ng-click="showPlaylist(currentPlaying.album_id)" class="mask"></a>
</div>
<div class="maininfo">
@ -271,7 +297,7 @@
<a class="overflowhide name notextdeco floatleft" title="{{currentPlaying.title}}">{{currentPlaying.title}}</a>
<span class="by overflowhide floatleft">
<span title="{{ currentPlaying.artist }}">
<a class="" ng-click="showArtist(currentPlaying.artist_id)">{{ currentPlaying.artist }}</a>
<a class="" ng-click="showPlaylist(currentPlaying.artist_id)">{{ currentPlaying.artist }}</a>
</span>
</span>
<a open-url="currentPlaying.source_url" class="src" title="原始链接"></a>
@ -293,7 +319,7 @@
</div>
<div class="ctrl">
<!-- <a class="icn icn-add" ng-click="showDialog(0, currentPlaying)" title="添加到歌单">添加到歌单</a> -->
<a class="icn icn-add" ng-click="showDialog(0, currentPlaying)" title="添加到歌单">添加到歌单</a>
<a class="icn" ng-class="{ 'icn-shuffle': settings.playmode == 1, 'icn-loop': settings.playmode == 0 }" title="{{ settings.playmode | playmode_title }}" ng-click="changePlaymode()"></a>
<a class="icn icn-list" title="列表" ng-click="togglePlaylist()"></a>
</div>
@ -319,7 +345,7 @@
<li id="song{{ song.id }}" ng-repeat="song in playlist" ng-class="{ playing: currentPlaying.id == song.id }" ng-mouseenter="playlist_highlight=true" ng-mouseleave="playlist_highlight=false">
<div class="title" play-from-playlist="song"><a>{{ song.title }}</a></div>
<a class="icn-remove" remove-from-playlist="song" data-index="{{$index}}" ng-show="playlist_highlight"></a>
<div class="singer" ng-click="showArtist(song.artist_id)">{{ song.artist }}</div>
<div class="singer" ng-click="showPlaylist(song.artist_id)">{{ song.artist }}</div>
</li>
</ul>
<div class="lyric">