add open playlist url feature, fix origin field in http header
This commit is contained in:
parent
b588f400f0
commit
f9305900ad
@ -1,4 +1,4 @@
|
||||
Listen 1 (Chrome Extension) (最后更新于2017年10月16日)
|
||||
Listen 1 (Chrome Extension) (最后更新于2017年11月17日)
|
||||
==========
|
||||
|
||||
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE)
|
||||
@ -36,6 +36,11 @@ Firefox打包安装
|
||||
更新日志
|
||||
-------
|
||||
|
||||
`2017-11-17`
|
||||
|
||||
* 在我的歌单页面增加“打开歌单”功能,可打开支持网页的歌单链接地址。这样就可以导入你喜欢的歌单了。
|
||||
* HTTP请求头部的Origin字段设置为正常网址
|
||||
|
||||
`2017-10-16`
|
||||
|
||||
* 修复QQ音乐歌单翻页显示重复的问题(感谢@Moobusy的提交)
|
||||
|
@ -971,7 +971,7 @@ li {
|
||||
bottom: 20px;
|
||||
}
|
||||
|
||||
.dialog-editplaylist .confirm-button {
|
||||
.dialog-editplaylist .confirm-button, .dialog-open-url .confirm-button {
|
||||
margin-right: 82px;
|
||||
margin-left: 93px;
|
||||
}
|
||||
@ -1028,7 +1028,9 @@ li {
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
|
||||
.source-list .open-url-button {
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.settings-title {
|
||||
font-size: 20px;
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 44 KiB |
25
js/app.js
25
js/app.js
@ -233,6 +233,10 @@
|
||||
$scope.dialog_title = '连接到Last.fm';
|
||||
$scope.dialog_type = 4;
|
||||
}
|
||||
if (dialog_type == 5) {
|
||||
$scope.dialog_title = '打开歌单';
|
||||
$scope.dialog_type = 5;
|
||||
}
|
||||
};
|
||||
|
||||
$scope.chooseDialogOption = function(option_id) {
|
||||
@ -480,7 +484,26 @@
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$scope.openUrl = function(url) {
|
||||
loWeb.post({
|
||||
url: '/parse_url',
|
||||
method: 'POST',
|
||||
data: $httpParamSerializerJQLike({
|
||||
url: url
|
||||
}),
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
}
|
||||
}).success(function(data) {
|
||||
var result = data.result;
|
||||
if (result !== undefined) {
|
||||
$scope.showPlaylist(result.id);
|
||||
}
|
||||
else {
|
||||
Notification.info('未能打开输入的歌单地址');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}]);
|
||||
|
||||
|
@ -23,6 +23,7 @@ function hack_referer_header(details) {
|
||||
}
|
||||
|
||||
var isRefererSet = false;
|
||||
var isOriginSet = false;
|
||||
var headers = details.requestHeaders,
|
||||
blockingResponse = {};
|
||||
|
||||
@ -30,7 +31,10 @@ function hack_referer_header(details) {
|
||||
if ((headers[i].name == 'Referer') && (referer_value != '')) {
|
||||
headers[i].value = referer_value;
|
||||
isRefererSet = true;
|
||||
break;
|
||||
}
|
||||
if ((headers[i].name == 'Origin') && (referer_value != '')) {
|
||||
headers[i].value = referer_value;
|
||||
isOriginSet = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,6 +45,13 @@ function hack_referer_header(details) {
|
||||
});
|
||||
}
|
||||
|
||||
if ((!isOriginSet) && (referer_value != '')) {
|
||||
headers.push({
|
||||
name: "Origin",
|
||||
value: referer_value
|
||||
});
|
||||
}
|
||||
|
||||
blockingResponse.requestHeaders = headers;
|
||||
return blockingResponse;
|
||||
};
|
||||
|
21
js/loweb.js
21
js/loweb.js
@ -12,6 +12,10 @@ function getProviderByName(sourceName) {
|
||||
}
|
||||
}
|
||||
|
||||
function getAllProviders(){
|
||||
return [netease, xiami, qq];
|
||||
}
|
||||
|
||||
function getProviderByItemId(itemId) {
|
||||
var prefix = itemId.slice(0,2);
|
||||
if (prefix == 'ne') {
|
||||
@ -122,6 +126,23 @@ function($rootScope, $log, $http, $httpParamSerializerJQLike) {
|
||||
}
|
||||
};
|
||||
}
|
||||
if (request.url.search('/parse_url') != -1) {
|
||||
var url = getParameterByName('url', url+'?'+request.data);
|
||||
var providers = getAllProviders();
|
||||
var result = undefined;
|
||||
for(var i=0; i<providers.length; i++) {
|
||||
var r = providers[i].parse_url(url);
|
||||
if (r !== undefined) {
|
||||
result = r;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return {
|
||||
success: function(fn){
|
||||
return fn({'result': result});
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
bootstrapTrack: function(success, failure) {
|
||||
return function(sound, track, callback){
|
||||
|
@ -381,6 +381,14 @@ var netease = (function() {
|
||||
};
|
||||
}
|
||||
|
||||
var ne_parse_url = function(url) {
|
||||
var result = undefined;
|
||||
if (url.search('//music.163.com/#/m/playlist') != -1 || url.search('//music.163.com/#/playlist') != -1) {
|
||||
result = {'type': 'playlist', 'id': 'neplaylist_' + getParameterByName('id', url)};
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
var get_playlist = function(url, hm, se) {
|
||||
var list_id = getParameterByName('list_id', url).split('_')[0];
|
||||
if (list_id == 'neplaylist') {
|
||||
@ -397,6 +405,7 @@ var get_playlist = function(url, hm, se) {
|
||||
return {
|
||||
show_playlist: ne_show_playlist,
|
||||
get_playlist: get_playlist,
|
||||
parse_url: ne_parse_url,
|
||||
bootstrap_track: ne_bootstrap_track,
|
||||
search: ne_search,
|
||||
lyric: ne_lyric,
|
||||
|
@ -289,6 +289,16 @@ var qq = (function() {
|
||||
};
|
||||
}
|
||||
|
||||
var qq_parse_url = function(url) {
|
||||
var result = undefined;
|
||||
var match = /\/\/y.qq.com\/n\/yqq\/playlist\/([0-9]+)/.exec(url);
|
||||
if (match != null) {
|
||||
var playlist_id = match[1];
|
||||
result = {'type': 'playlist', 'id': 'qqplaylist_' + playlist_id};
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
var get_playlist = function(url, hm, se) {
|
||||
var list_id = getParameterByName('list_id', url).split('_')[0];
|
||||
@ -306,6 +316,7 @@ var get_playlist = function(url, hm, se) {
|
||||
return {
|
||||
show_playlist: qq_show_playlist,
|
||||
get_playlist: get_playlist,
|
||||
parse_url: qq_parse_url,
|
||||
bootstrap_track: qq_bootstrap_track,
|
||||
search: qq_search,
|
||||
lyric: qq_lyric,
|
||||
|
@ -257,6 +257,16 @@ var xiami = (function() {
|
||||
};
|
||||
}
|
||||
|
||||
var xm_parse_url = function(url) {
|
||||
var result = undefined;
|
||||
var match = /\/\/www.xiami.com\/collect\/([0-9]+)/.exec(url);
|
||||
if (match != null) {
|
||||
var playlist_id = match[1];
|
||||
result = {'type': 'playlist', 'id': 'xmplaylist_' + playlist_id};
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
var get_playlist = function(url, hm, se) {
|
||||
var list_id = getParameterByName('list_id', url).split('_')[0];
|
||||
if (list_id == 'xmplaylist') {
|
||||
@ -272,6 +282,7 @@ var get_playlist = function(url, hm, se) {
|
||||
return {
|
||||
show_playlist: xm_show_playlist,
|
||||
get_playlist: get_playlist,
|
||||
parse_url: xm_parse_url,
|
||||
bootstrap_track: xm_bootstrap_track,
|
||||
search: xm_search,
|
||||
lyric: xm_lyric,
|
||||
|
17
listen1.html
17
listen1.html
@ -112,6 +112,17 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- open playlist dialog -->
|
||||
<div ng-show="dialog_type==5" class="dialog-open-url">
|
||||
<div class="form-group">
|
||||
<label >歌单链接</label>
|
||||
<input type="text" class="form-control" placeholder="例如http://www.xiami.com/collect/198267231" ng-model="dialog_url"/>
|
||||
</div>
|
||||
|
||||
<button class="btn btn-primary confirm-button" ng-click="openUrl(dialog_url);closeDialog();">打开歌单</button>
|
||||
<button class="btn btn-default" ng-click="closeDialog()">取消</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -134,6 +145,12 @@
|
||||
|
||||
<!-- content page: 我的歌单 -->
|
||||
<div class="site-wrapper" ng-show="current_tag==1" ng-controller="MyPlayListController">
|
||||
<div class="cover-container container-placeholder">
|
||||
<!-- make empty placeholder div to position sidebar -->
|
||||
<div class="source-list" ng-show="is_window_hidden==1">
|
||||
<div class="open-url-button" ng-click="showDialog(5)">打开歌单</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="site-wrapper-innerd" resize>
|
||||
<div class="cover-container">
|
||||
<div class="playlist" ng-init="loadMyPlaylist();">
|
||||
|
Loading…
Reference in New Issue
Block a user