Skip to content

Commit 6e07719

Browse files
committed
原接口已挂,暂时切换到临时接口
1 parent 214745a commit 6e07719

9 files changed

Lines changed: 113 additions & 37 deletions

File tree

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@ Project versioning adheres to [Semantic Versioning](http://semver.org/).
66
Commit convention is based on [Conventional Commits](http://conventionalcommits.org).
77
Change log format is based on [Keep a Changelog](http://keepachangelog.com/).
88

9+
## [0.1.3](https://github.com/lyswhut/lx-music-desktop/compare/v0.1.2...v0.1.3) - 2019-08-17
10+
11+
### 新增
12+
13+
- 新增win32应用构建
14+
15+
### 修复
16+
17+
- 修复安装包许可协议乱码问题
18+
- **messoer 提供的接口已挂**,暂时切换到临时接口!
19+
20+
### 移除
21+
22+
- 由于messoer接口无法使用,QQ音乐排行榜直接播放/下载功能暂时关闭
23+
924
## [0.1.2](https://github.com/lyswhut/lx-music-desktop/compare/v0.1.1...v0.1.2) - 2019-08-17
1025

1126
### 修复

package.json

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lx-music-desktop",
3-
"version": "0.1.2",
3+
"version": "0.1.3",
44
"description": "一个免费的音乐下载助手",
55
"main": "./dist/electron/main.js",
66
"scripts": {
@@ -39,7 +39,10 @@
3939
"legalTrademarks": "lyswhut",
4040
"target": [
4141
{
42-
"arch": ["ia32", "x64"],
42+
"arch": [
43+
"ia32",
44+
"x64"
45+
],
4346
"target": "nsis"
4447
}
4548
]
@@ -48,14 +51,21 @@
4851
"target": [
4952
{
5053
"target": "AppImage",
51-
"arch": ["x64"]
54+
"arch": [
55+
"x64"
56+
]
5257
},
5358
{
54-
"arch": ["ia32", "x64"],
59+
"arch": [
60+
"ia32",
61+
"x64"
62+
],
5563
"target": "deb"
5664
},
5765
{
58-
"arch": ["x64"],
66+
"arch": [
67+
"x64"
68+
],
5969
"target": "snap"
6070
}
6171
],

publish/changeLog.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
### 修复
2-
3-
- 修复安装包许可协议乱码问题

publish/version.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
{
2-
"version": "0.1.2",
3-
"desc": "<h3>修复</h3>\n<ul>\n<li>修复更新弹窗的内容显示问题</li>\n</ul>\n",
2+
"version": "0.1.3",
3+
"desc": "<h3>新增</h3>\n<ul>\n<li>新增win32应用构建</li>\n</ul>\n<h3>修复</h3>\n<ul>\n<li>修复安装包许可协议乱码问题</li>\n<li><strong>messoer 提供的接口已挂</strong>,暂时切换到临时接口!</li>\n</ul>\n<h3>移除</h3>\n<ul>\n<li>由于messoer接口无法使用,QQ音乐排行榜直接播放/下载功能暂时关闭</li>\n</ul>\n",
44
"history": [
5+
{
6+
"version": "0.1.2",
7+
"desc": "<h3>修复</h3>\n<ul>\n<li>修复更新弹窗的内容显示问题</li>\n</ul>\n"
8+
},
59
{
610
"version": "0.1.1",
711
"desc": "<h3>新增</h3>\n<ul>\n<li>QQ音乐排行榜直接试听与下载(该接口貌似不太稳定,且用且珍惜!)</li>\n</ul>\n<h3>优化</h3>\n<ul>\n<li>优化http请求机制</li>\n<li>更新关于本软件说明</li>\n</ul>\n<h3>修复</h3>\n<ul>\n<li>修复当上一个歌曲链接正在获取时切换歌曲请求不会取消的问题</li>\n<li>修复切换歌曲时仍然播放上一首歌曲的问题</li>\n</ul>\n"

src/renderer/store/modules/player.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ const state = {
88
changePlay: false,
99
}
1010

11+
let request
12+
1113
// getters
1214
const getters = {
1315
list: state => state.list || [],
@@ -19,13 +21,12 @@ const getters = {
1921
// actions
2022
const actions = {
2123
getUrl({ commit, state }, { musicInfo, type }) {
22-
if (state.cancelFn) state.cancelFn()
23-
const { promise, cancelHttp } = music[musicInfo.source].getMusicUrl(musicInfo, type)
24-
state.cancelFn = cancelHttp
25-
return promise.then(result => {
26-
return commit('setUrl', { musicInfo, url: result.url, type })
24+
if (request && request.cancelHttp) request.cancelHttp()
25+
request = music[musicInfo.source].getMusicUrl(musicInfo, type)
26+
return request.promise.then(result => {
27+
commit('setUrl', { musicInfo, url: result.url, type })
2728
}).finally(() => {
28-
state.cancelFn = null
29+
request = null
2930
})
3031
},
3132
getPic({ commit, state }, musicInfo) {

src/renderer/utils/music/kw/index.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,18 @@ const kw = {
5656
let cancelFn
5757
const p = new Promise((resolve, reject) => {
5858
cancelFn = reject
59-
requestObj = httpGet(`https://v1.itooi.cn/kuwo/url?id=${songInfo.songmid}&quality=${type.replace(/k$/, '')}&isRedirect=0`, (err, resp, body) => {
59+
// requestObj = httpGet(`https://v1.itooi.cn/kuwo/url?id=${songInfo.songmid}&quality=${type.replace(/k$/, '')}&isRedirect=0`, (err, resp, body) => {
60+
requestObj = httpGet(`https://www.stsky.cn/api/temp/getMusicUrl.php?id=${songInfo.songmid}&type=${type}`, (err, resp, body) => {
6061
requestObj = null
6162
cancelFn = null
6263
if (err) {
63-
console.log(err)
64+
if (err.message === 'socket hang up') return reject(new Error('接口挂了'))
6465
const { promise, cancelHttp } = this.getMusicUrl(songInfo, type)
6566
obj.cancelHttp = cancelHttp
6667
return promise
6768
}
68-
body.code === 200 ? resolve({ type, url: body.data }) : reject(new Error(body.msg))
69+
// body.code === 200 ? resolve({ type, url: body.data }) : reject(new Error(body.msg))
70+
body.code === 0 ? resolve({ type, url: body.data }) : reject(new Error(body.msg))
6971
})
7072
})
7173
const obj = {
@@ -123,14 +125,16 @@ const kw = {
123125
}
124126
return new Promise((resolve, reject) => {
125127
this._musicPicPromiseCancelFn = reject
126-
this._musicPicRequestObj = httpGet(`https://v1.itooi.cn/kuwo/pic?id=${songInfo.songmid}&isRedirect=0`, (err, resp, body) => {
128+
// this._musicPicRequestObj = httpGet(`https://v1.itooi.cn/kuwo/pic?id=${songInfo.songmid}&isRedirect=0`, (err, resp, body) => {
129+
this._musicPicRequestObj = httpGet(`https://www.stsky.cn/api/temp/getPic.php?size=320&songmid=${songInfo.songmid}`, (err, resp, body) => {
127130
this._musicPicRequestObj = null
128131
this._musicPicPromiseCancelFn = null
129132
if (err) {
130133
console.log(err)
131134
reject(err)
132135
}
133-
body.code === 200 ? resolve(body.data) : reject(new Error(body.msg))
136+
// body.code === 200 ? resolve(body.data) : reject(new Error(body.msg))
137+
body.code === 0 ? resolve(body.data) : reject(new Error(body.msg))
134138
})
135139
})
136140
},

src/renderer/utils/music/kw/lyric.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,26 @@ export default {
88
let s = (time % 60).toFixed(2)
99
return (m < 10 ? '0' + m : m) + ':' + (s < 10 ? '0' + s : s)
1010
},
11+
transformLrc({ songinfo, lrclist }) {
12+
return `[ti:${songinfo.songName}]\n[ar:${songinfo.artist}]\n[al:${songinfo.album}]\n[by:]\n[offset:0]\n${lrclist ? lrclist.map(l => `[${this.formatTime(l.time)}]${l.lineLyric}\n`).join('') : '暂无歌词'}`
13+
},
1114
getLyric(songId) {
1215
if (this._musicLrcRequestObj != null) {
1316
cancelHttp(this._musicLrcRequestObj)
1417
this._musicLrcPromiseCancelFn(new Error('取消http请求'))
1518
}
1619
return new Promise((resolve, reject) => {
1720
this._musicLrcPromiseCancelFn = reject
18-
this._musicLrcRequestObj = httpGet(`https://v1.itooi.cn/kuwo/lrc?id=${songId}`, (err, resp, body) => {
21+
// this._musicLrcRequestObj = httpGet(`https://v1.itooi.cn/kuwo/lrc?id=${songId}`, (err, resp, body) => {
22+
this._musicLrcRequestObj = httpGet(`http://m.kuwo.cn/newh5/singles/songinfoandlrc?musicId=${songId}`, (err, resp, body) => {
1923
this._musicLrcRequestObj = null
2024
this._musicLrcPromiseCancelFn = null
2125
if (err) {
2226
console.log(err)
2327
reject(err)
2428
}
25-
// console.log(body.data)
26-
// console.log(this.transformLrc(body.data))
27-
resolve(body)
29+
// resolve(body)
30+
resolve(this.transformLrc(body.data))
2831
})
2932
})
3033
},

src/renderer/utils/request.js

Lines changed: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,58 @@ import request from 'request'
33
import { debugRequest } from './env'
44
// import fs from 'fs'
55

6-
const fatchData = (url, method, options, callback) => request(url, {
7-
method,
8-
headers: options.headers,
9-
Origin: options.origin,
10-
data: options.data,
11-
json: options.format === undefined || options.format === 'json',
12-
}, (err, resp, body) => {
13-
if (err) return callback(err, null)
14-
callback(null, resp, body)
15-
})
6+
const fatchData = (url, method, options, callback) => {
7+
console.log('---start---', url)
8+
return request(url, {
9+
method,
10+
headers: options.headers,
11+
Origin: options.origin,
12+
data: options.data,
13+
// timeout: 5000,
14+
json: options.format === undefined || options.format === 'json',
15+
}, (err, resp, body) => {
16+
if (err) return callback(err, null)
17+
console.log('---end---', url)
18+
callback(null, resp, body)
19+
})
20+
}
21+
22+
export const httpFatch = (url, options = { method: 'get' }) => {
23+
let requestObj
24+
let cancelFn
25+
const p = new Promise((resolve, reject) => {
26+
cancelFn = reject
27+
debugRequest && console.log(`\n---send request------${url}------------`)
28+
requestObj = fatchData(url, options.method, options, (err, resp, body) => {
29+
// options.isShowProgress && window.api.hideProgress()
30+
debugRequest && console.log(`\n---response------${url}------------`)
31+
debugRequest && console.log(JSON.stringify(body))
32+
requestObj = null
33+
cancelFn = null
34+
if (err) {
35+
console.log(err)
36+
if (err.code === 'ETIMEDOUT') {
37+
const { promise, cancelHttp } = httpFatch(url, options)
38+
obj.cancelHttp = cancelHttp
39+
return promise
40+
}
41+
}
42+
resolve(resp)
43+
})
44+
})
45+
const obj = {
46+
promise: p,
47+
cancelHttp() {
48+
console.log('cancel')
49+
if (!requestObj) return
50+
cancelHttp(requestObj)
51+
cancelFn(new Error('取消http请求'))
52+
requestObj = null
53+
cancelFn = null
54+
},
55+
}
56+
return obj
57+
}
1658

1759
/**
1860
* 取消请求

src/renderer/views/Leaderboard.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
td.break(style="width: 20%;") {{item.singer}}
2626
td.break(style="width: 25%;") {{item.albumName}}
2727
td(style="width: 18%;")
28-
material-list-buttons(:index="index" :search-btn="true" :play-btn="item.source == 'kw' || item.source == 'tx'" :download-btn="item.source == 'kw' || item.source == 'tx'" :remove-btn="false" @btn-click="handleBtnClick")
28+
material-list-buttons(:index="index" :search-btn="true" :play-btn="item.source == 'kw'" :download-btn="item.source == 'kw'" :remove-btn="false" @btn-click="handleBtnClick")
2929
//- button.btn-info(type='button' v-if="item._types['128k'] || item._types['192k'] || item._types['320k'] || item._types.flac" @click.stop='openDownloadModal(index)') 下载
3030
//- button.btn-secondary(type='button' v-if="item._types['128k'] || item._types['192k'] || item._types['320k']" @click.stop='testPlay(index)') 试听
3131
//- button.btn-success(type='button' v-if="(item._types['128k'] || item._types['192k'] || item._types['320k']) && userInfo" @click.stop='showListModal(index)') +
@@ -94,7 +94,7 @@ export default {
9494
this.clickIndex = index
9595
return
9696
}
97-
(this.source == 'kw' || this.source == 'tx') ? this.testPlay(index) : this.handleSearch(index)
97+
(this.source == 'kw') ? this.testPlay(index) : this.handleSearch(index)
9898
this.clickTime = 0
9999
this.clickIndex = -1
100100
},

0 commit comments

Comments
 (0)