原接口已挂,暂时切换到临时接口

pull/96/head v0.1.3
lyswhut 2019-08-17 21:43:53 +08:00
parent 214745ae87
commit 6e07719c2c
9 changed files with 113 additions and 37 deletions

View File

@ -6,6 +6,21 @@ Project versioning adheres to [Semantic Versioning](http://semver.org/).
Commit convention is based on [Conventional Commits](http://conventionalcommits.org). Commit convention is based on [Conventional Commits](http://conventionalcommits.org).
Change log format is based on [Keep a Changelog](http://keepachangelog.com/). Change log format is based on [Keep a Changelog](http://keepachangelog.com/).
## [0.1.3](https://github.com/lyswhut/lx-music-desktop/compare/v0.1.2...v0.1.3) - 2019-08-17
### 新增
- 新增win32应用构建
### 修复
- 修复安装包许可协议乱码问题
- **messoer 提供的接口已挂**,暂时切换到临时接口!
### 移除
- 由于messoer接口无法使用QQ音乐排行榜直接播放/下载功能暂时关闭
## [0.1.2](https://github.com/lyswhut/lx-music-desktop/compare/v0.1.1...v0.1.2) - 2019-08-17 ## [0.1.2](https://github.com/lyswhut/lx-music-desktop/compare/v0.1.1...v0.1.2) - 2019-08-17
### 修复 ### 修复

View File

@ -1,6 +1,6 @@
{ {
"name": "lx-music-desktop", "name": "lx-music-desktop",
"version": "0.1.2", "version": "0.1.3",
"description": "一个免费的音乐下载助手", "description": "一个免费的音乐下载助手",
"main": "./dist/electron/main.js", "main": "./dist/electron/main.js",
"scripts": { "scripts": {
@ -39,7 +39,10 @@
"legalTrademarks": "lyswhut", "legalTrademarks": "lyswhut",
"target": [ "target": [
{ {
"arch": ["ia32", "x64"], "arch": [
"ia32",
"x64"
],
"target": "nsis" "target": "nsis"
} }
] ]
@ -48,14 +51,21 @@
"target": [ "target": [
{ {
"target": "AppImage", "target": "AppImage",
"arch": ["x64"] "arch": [
"x64"
]
}, },
{ {
"arch": ["ia32", "x64"], "arch": [
"ia32",
"x64"
],
"target": "deb" "target": "deb"
}, },
{ {
"arch": ["x64"], "arch": [
"x64"
],
"target": "snap" "target": "snap"
} }
], ],

View File

@ -1,3 +0,0 @@
### 修复
- 修复安装包许可协议乱码问题

View File

@ -1,7 +1,11 @@
{ {
"version": "0.1.2", "version": "0.1.3",
"desc": "<h3>修复</h3>\n<ul>\n<li>修复更新弹窗的内容显示问题</li>\n</ul>\n", "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",
"history": [ "history": [
{
"version": "0.1.2",
"desc": "<h3>修复</h3>\n<ul>\n<li>修复更新弹窗的内容显示问题</li>\n</ul>\n"
},
{ {
"version": "0.1.1", "version": "0.1.1",
"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" "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"

View File

@ -8,6 +8,8 @@ const state = {
changePlay: false, changePlay: false,
} }
let request
// getters // getters
const getters = { const getters = {
list: state => state.list || [], list: state => state.list || [],
@ -19,13 +21,12 @@ const getters = {
// actions // actions
const actions = { const actions = {
getUrl({ commit, state }, { musicInfo, type }) { getUrl({ commit, state }, { musicInfo, type }) {
if (state.cancelFn) state.cancelFn() if (request && request.cancelHttp) request.cancelHttp()
const { promise, cancelHttp } = music[musicInfo.source].getMusicUrl(musicInfo, type) request = music[musicInfo.source].getMusicUrl(musicInfo, type)
state.cancelFn = cancelHttp return request.promise.then(result => {
return promise.then(result => { commit('setUrl', { musicInfo, url: result.url, type })
return commit('setUrl', { musicInfo, url: result.url, type })
}).finally(() => { }).finally(() => {
state.cancelFn = null request = null
}) })
}, },
getPic({ commit, state }, musicInfo) { getPic({ commit, state }, musicInfo) {

View File

@ -56,16 +56,18 @@ const kw = {
let cancelFn let cancelFn
const p = new Promise((resolve, reject) => { const p = new Promise((resolve, reject) => {
cancelFn = reject cancelFn = reject
requestObj = httpGet(`https://v1.itooi.cn/kuwo/url?id=${songInfo.songmid}&quality=${type.replace(/k$/, '')}&isRedirect=0`, (err, resp, body) => { // requestObj = httpGet(`https://v1.itooi.cn/kuwo/url?id=${songInfo.songmid}&quality=${type.replace(/k$/, '')}&isRedirect=0`, (err, resp, body) => {
requestObj = httpGet(`https://www.stsky.cn/api/temp/getMusicUrl.php?id=${songInfo.songmid}&type=${type}`, (err, resp, body) => {
requestObj = null requestObj = null
cancelFn = null cancelFn = null
if (err) { if (err) {
console.log(err) if (err.message === 'socket hang up') return reject(new Error('接口挂了'))
const { promise, cancelHttp } = this.getMusicUrl(songInfo, type) const { promise, cancelHttp } = this.getMusicUrl(songInfo, type)
obj.cancelHttp = cancelHttp obj.cancelHttp = cancelHttp
return promise return promise
} }
body.code === 200 ? resolve({ type, url: body.data }) : reject(new Error(body.msg)) // body.code === 200 ? resolve({ type, url: body.data }) : reject(new Error(body.msg))
body.code === 0 ? resolve({ type, url: body.data }) : reject(new Error(body.msg))
}) })
}) })
const obj = { const obj = {
@ -123,14 +125,16 @@ const kw = {
} }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this._musicPicPromiseCancelFn = reject this._musicPicPromiseCancelFn = reject
this._musicPicRequestObj = httpGet(`https://v1.itooi.cn/kuwo/pic?id=${songInfo.songmid}&isRedirect=0`, (err, resp, body) => { // this._musicPicRequestObj = httpGet(`https://v1.itooi.cn/kuwo/pic?id=${songInfo.songmid}&isRedirect=0`, (err, resp, body) => {
this._musicPicRequestObj = httpGet(`https://www.stsky.cn/api/temp/getPic.php?size=320&songmid=${songInfo.songmid}`, (err, resp, body) => {
this._musicPicRequestObj = null this._musicPicRequestObj = null
this._musicPicPromiseCancelFn = null this._musicPicPromiseCancelFn = null
if (err) { if (err) {
console.log(err) console.log(err)
reject(err) reject(err)
} }
body.code === 200 ? resolve(body.data) : reject(new Error(body.msg)) // body.code === 200 ? resolve(body.data) : reject(new Error(body.msg))
body.code === 0 ? resolve(body.data) : reject(new Error(body.msg))
}) })
}) })
}, },

View File

@ -8,6 +8,9 @@ export default {
let s = (time % 60).toFixed(2) let s = (time % 60).toFixed(2)
return (m < 10 ? '0' + m : m) + ':' + (s < 10 ? '0' + s : s) return (m < 10 ? '0' + m : m) + ':' + (s < 10 ? '0' + s : s)
}, },
transformLrc({ songinfo, lrclist }) {
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('') : '暂无歌词'}`
},
getLyric(songId) { getLyric(songId) {
if (this._musicLrcRequestObj != null) { if (this._musicLrcRequestObj != null) {
cancelHttp(this._musicLrcRequestObj) cancelHttp(this._musicLrcRequestObj)
@ -15,16 +18,16 @@ export default {
} }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this._musicLrcPromiseCancelFn = reject this._musicLrcPromiseCancelFn = reject
this._musicLrcRequestObj = httpGet(`https://v1.itooi.cn/kuwo/lrc?id=${songId}`, (err, resp, body) => { // this._musicLrcRequestObj = httpGet(`https://v1.itooi.cn/kuwo/lrc?id=${songId}`, (err, resp, body) => {
this._musicLrcRequestObj = httpGet(`http://m.kuwo.cn/newh5/singles/songinfoandlrc?musicId=${songId}`, (err, resp, body) => {
this._musicLrcRequestObj = null this._musicLrcRequestObj = null
this._musicLrcPromiseCancelFn = null this._musicLrcPromiseCancelFn = null
if (err) { if (err) {
console.log(err) console.log(err)
reject(err) reject(err)
} }
// console.log(body.data) // resolve(body)
// console.log(this.transformLrc(body.data)) resolve(this.transformLrc(body.data))
resolve(body)
}) })
}) })
}, },

View File

@ -3,16 +3,58 @@ import request from 'request'
import { debugRequest } from './env' import { debugRequest } from './env'
// import fs from 'fs' // import fs from 'fs'
const fatchData = (url, method, options, callback) => request(url, { const fatchData = (url, method, options, callback) => {
method, console.log('---start---', url)
headers: options.headers, return request(url, {
Origin: options.origin, method,
data: options.data, headers: options.headers,
json: options.format === undefined || options.format === 'json', Origin: options.origin,
}, (err, resp, body) => { data: options.data,
if (err) return callback(err, null) // timeout: 5000,
callback(null, resp, body) json: options.format === undefined || options.format === 'json',
}) }, (err, resp, body) => {
if (err) return callback(err, null)
console.log('---end---', url)
callback(null, resp, body)
})
}
export const httpFatch = (url, options = { method: 'get' }) => {
let requestObj
let cancelFn
const p = new Promise((resolve, reject) => {
cancelFn = reject
debugRequest && console.log(`\n---send request------${url}------------`)
requestObj = fatchData(url, options.method, options, (err, resp, body) => {
// options.isShowProgress && window.api.hideProgress()
debugRequest && console.log(`\n---response------${url}------------`)
debugRequest && console.log(JSON.stringify(body))
requestObj = null
cancelFn = null
if (err) {
console.log(err)
if (err.code === 'ETIMEDOUT') {
const { promise, cancelHttp } = httpFatch(url, options)
obj.cancelHttp = cancelHttp
return promise
}
}
resolve(resp)
})
})
const obj = {
promise: p,
cancelHttp() {
console.log('cancel')
if (!requestObj) return
cancelHttp(requestObj)
cancelFn(new Error('取消http请求'))
requestObj = null
cancelFn = null
},
}
return obj
}
/** /**
* 取消请求 * 取消请求

View File

@ -25,7 +25,7 @@
td.break(style="width: 20%;") {{item.singer}} td.break(style="width: 20%;") {{item.singer}}
td.break(style="width: 25%;") {{item.albumName}} td.break(style="width: 25%;") {{item.albumName}}
td(style="width: 18%;") td(style="width: 18%;")
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") material-list-buttons(:index="index" :search-btn="true" :play-btn="item.source == 'kw'" :download-btn="item.source == 'kw'" :remove-btn="false" @btn-click="handleBtnClick")
//- button.btn-info(type='button' v-if="item._types['128k'] || item._types['192k'] || item._types['320k'] || item._types.flac" @click.stop='openDownloadModal(index)') //- button.btn-info(type='button' v-if="item._types['128k'] || item._types['192k'] || item._types['320k'] || item._types.flac" @click.stop='openDownloadModal(index)')
//- button.btn-secondary(type='button' v-if="item._types['128k'] || item._types['192k'] || item._types['320k']" @click.stop='testPlay(index)') //- button.btn-secondary(type='button' v-if="item._types['128k'] || item._types['192k'] || item._types['320k']" @click.stop='testPlay(index)')
//- button.btn-success(type='button' v-if="(item._types['128k'] || item._types['192k'] || item._types['320k']) && userInfo" @click.stop='showListModal(index)') //- 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 {
this.clickIndex = index this.clickIndex = index
return return
} }
(this.source == 'kw' || this.source == 'tx') ? this.testPlay(index) : this.handleSearch(index) (this.source == 'kw') ? this.testPlay(index) : this.handleSearch(index)
this.clickTime = 0 this.clickTime = 0
this.clickIndex = -1 this.clickIndex = -1
}, },