新增:直接播放QQ音乐排行榜音乐
parent
43bc2b6b90
commit
bccadcf13d
16
CHANGELOG.md
16
CHANGELOG.md
|
@ -6,6 +6,22 @@ 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.1](https://github.com/lyswhut/lx-music-desktop/compare/v0.1.0...v0.1.1) - 2019-08-17
|
||||||
|
|
||||||
|
### 新增
|
||||||
|
|
||||||
|
- QQ音乐排行榜直接试听与下载(该接口貌似不太稳定,且用且珍惜!)
|
||||||
|
|
||||||
|
### 优化
|
||||||
|
|
||||||
|
- 优化http请求机制
|
||||||
|
- 更新关于本软件说明
|
||||||
|
|
||||||
|
### 修复
|
||||||
|
|
||||||
|
- 修复当上一个歌曲链接正在获取时切换歌曲请求不会取消的问题
|
||||||
|
- 修复切换歌曲时仍然播放上一首歌曲的问题
|
||||||
|
|
||||||
## [0.1.0] - 2019-8-16
|
## [0.1.0] - 2019-8-16
|
||||||
|
|
||||||
* 0.1.0版本发布
|
* 0.1.0版本发布
|
||||||
|
|
|
@ -3404,6 +3404,16 @@
|
||||||
"upper-case-first": "^1.1.0"
|
"upper-case-first": "^1.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"changelog-parser": {
|
||||||
|
"version": "2.8.0",
|
||||||
|
"resolved": "https://registry.npm.taobao.org/changelog-parser/download/changelog-parser-2.8.0.tgz",
|
||||||
|
"integrity": "sha1-wUKT4+j6t5eRPHIt6WVIAZhlAQg=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"line-reader": "^0.2.4",
|
||||||
|
"remove-markdown": "^0.2.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
"character-parser": {
|
"character-parser": {
|
||||||
"version": "2.2.0",
|
"version": "2.2.0",
|
||||||
"resolved": "https://registry.npm.taobao.org/character-parser/download/character-parser-2.2.0.tgz",
|
"resolved": "https://registry.npm.taobao.org/character-parser/download/character-parser-2.2.0.tgz",
|
||||||
|
@ -8487,6 +8497,12 @@
|
||||||
"type-check": "~0.3.2"
|
"type-check": "~0.3.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"line-reader": {
|
||||||
|
"version": "0.2.4",
|
||||||
|
"resolved": "https://registry.npm.taobao.org/line-reader/download/line-reader-0.2.4.tgz",
|
||||||
|
"integrity": "sha1-xDkrWH3qOFgMlnhXDm6OSfzlJiI=",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"linkify-it": {
|
"linkify-it": {
|
||||||
"version": "2.2.0",
|
"version": "2.2.0",
|
||||||
"resolved": "https://registry.npm.taobao.org/linkify-it/download/linkify-it-2.2.0.tgz",
|
"resolved": "https://registry.npm.taobao.org/linkify-it/download/linkify-it-2.2.0.tgz",
|
||||||
|
@ -11288,6 +11304,12 @@
|
||||||
"integrity": "sha1-VNvzd+UUQKypCkzSdGANP/LYiKk=",
|
"integrity": "sha1-VNvzd+UUQKypCkzSdGANP/LYiKk=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"remove-markdown": {
|
||||||
|
"version": "0.2.2",
|
||||||
|
"resolved": "https://registry.npm.taobao.org/remove-markdown/download/remove-markdown-0.2.2.tgz",
|
||||||
|
"integrity": "sha1-ZrDO66n7d8qWNrsbAwfOIaMqEqY=",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"remove-trailing-separator": {
|
"remove-trailing-separator": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npm.taobao.org/remove-trailing-separator/download/remove-trailing-separator-1.1.0.tgz",
|
"resolved": "https://registry.npm.taobao.org/remove-trailing-separator/download/remove-trailing-separator-1.1.0.tgz",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "lx-music-desktop",
|
"name": "lx-music-desktop",
|
||||||
"version": "0.1.0",
|
"version": "0.1.1",
|
||||||
"description": "一个免费的音乐下载助手",
|
"description": "一个免费的音乐下载助手",
|
||||||
"main": "./dist/electron/main.js",
|
"main": "./dist/electron/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -75,6 +75,7 @@
|
||||||
"babel-preset-minify": "^0.5.0",
|
"babel-preset-minify": "^0.5.0",
|
||||||
"cfonts": "^2.4.4",
|
"cfonts": "^2.4.4",
|
||||||
"chalk": "^2.4.2",
|
"chalk": "^2.4.2",
|
||||||
|
"changelog-parser": "^2.8.0",
|
||||||
"copy-webpack-plugin": "^5.0.4",
|
"copy-webpack-plugin": "^5.0.4",
|
||||||
"core-js": "^3.2.1",
|
"core-js": "^3.2.1",
|
||||||
"cos-nodejs-sdk-v5": "^2.5.11",
|
"cos-nodejs-sdk-v5": "^2.5.11",
|
||||||
|
|
|
@ -1 +1,13 @@
|
||||||
* 0.1.0版本发布
|
### 新增
|
||||||
|
|
||||||
|
- QQ音乐排行榜直接试听与下载(该接口貌似不太稳定,且用且珍惜!)
|
||||||
|
|
||||||
|
### 优化
|
||||||
|
|
||||||
|
- 优化http请求机制
|
||||||
|
- 更新关于本软件说明
|
||||||
|
|
||||||
|
### 修复
|
||||||
|
|
||||||
|
- 修复当上一个歌曲链接正在获取时切换歌曲请求不会取消的问题
|
||||||
|
- 修复切换歌曲时仍然播放上一首歌曲的问题
|
||||||
|
|
|
@ -2,11 +2,11 @@ const fs = require('fs')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const chalk = require('chalk')
|
const chalk = require('chalk')
|
||||||
const clearAssets = require('./utils/clearAssets')
|
const clearAssets = require('./utils/clearAssets')
|
||||||
const packAssets = require('./utils/packAssets')
|
// const packAssets = require('./utils/packAssets')
|
||||||
const compileAssets = require('./utils/compileAssets')
|
// const compileAssets = require('./utils/compileAssets')
|
||||||
const updateVersionFile = require('./utils/updateChangeLog')
|
const updateVersionFile = require('./utils/updateChangeLog')
|
||||||
const copyFile = require('./utils/copyFile')
|
// const copyFile = require('./utils/copyFile')
|
||||||
const githubRelease = require('./utils/githubRelease')
|
// const githubRelease = require('./utils/githubRelease')
|
||||||
const { parseArgv } = require('./utils')
|
const { parseArgv } = require('./utils')
|
||||||
|
|
||||||
const run = async() => {
|
const run = async() => {
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
|
{
|
||||||
|
"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",
|
||||||
|
"history": [
|
||||||
{
|
{
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"desc": "0.1.0版本发布",
|
"desc": "0.1.0版本发布"
|
||||||
"history": []
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,6 +98,8 @@ export default {
|
||||||
watch: {
|
watch: {
|
||||||
changePlay(n) {
|
changePlay(n) {
|
||||||
if (!n) return
|
if (!n) return
|
||||||
|
// console.log('changePlay')
|
||||||
|
this.handleRemoveMusic()
|
||||||
this.resetChangePlay()
|
this.resetChangePlay()
|
||||||
if (this.playIndex < 0) return
|
if (this.playIndex < 0) return
|
||||||
this.stopPlay()
|
this.stopPlay()
|
||||||
|
@ -112,7 +114,7 @@ export default {
|
||||||
? n.findIndex(s => s.musicInfo.songmid === this.musicInfo.songmid)
|
? n.findIndex(s => s.musicInfo.songmid === this.musicInfo.songmid)
|
||||||
: n.findIndex(s => s.songmid === this.musicInfo.songmid)
|
: n.findIndex(s => s.songmid === this.musicInfo.songmid)
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
this.handleRemoveMusic()
|
this.fixPlayIndex(this.playIndex - 1)
|
||||||
if (n.length) this.handleNext()
|
if (n.length) this.handleNext()
|
||||||
} else {
|
} else {
|
||||||
this.fixPlayIndex(index)
|
this.fixPlayIndex(index)
|
||||||
|
@ -362,7 +364,6 @@ export default {
|
||||||
this.musicInfo.url = null
|
this.musicInfo.url = null
|
||||||
this.nowPlayTime = 0
|
this.nowPlayTime = 0
|
||||||
this.maxPlayTime = 0
|
this.maxPlayTime = 0
|
||||||
this.fixPlayIndex(this.playIndex - 1)
|
|
||||||
},
|
},
|
||||||
sendProgressEvent(status, mode) {
|
sendProgressEvent(status, mode) {
|
||||||
// console.log(status)
|
// console.log(status)
|
||||||
|
|
|
@ -41,7 +41,7 @@ const getExt = type => {
|
||||||
const checkList = (list, musicInfo, type) => list.some(s => s.musicInfo.songmid === musicInfo.songmid && s.type === type)
|
const checkList = (list, musicInfo, type) => list.some(s => s.musicInfo.songmid === musicInfo.songmid && s.type === type)
|
||||||
|
|
||||||
const refreshUrl = downloadInfo => {
|
const refreshUrl = downloadInfo => {
|
||||||
return music[downloadInfo.musicInfo.source].getMusicUrl(downloadInfo.musicInfo, downloadInfo.type)
|
return music[downloadInfo.musicInfo.source].getMusicUrl(downloadInfo.musicInfo, downloadInfo.type).promise
|
||||||
}
|
}
|
||||||
|
|
||||||
// actions
|
// actions
|
||||||
|
|
|
@ -19,7 +19,14 @@ const getters = {
|
||||||
// actions
|
// actions
|
||||||
const actions = {
|
const actions = {
|
||||||
getUrl({ commit, state }, { musicInfo, type }) {
|
getUrl({ commit, state }, { musicInfo, type }) {
|
||||||
return music[musicInfo.source].getMusicUrl(musicInfo, type).then(result => commit('setUrl', { musicInfo, url: result.url, type }))
|
if (state.cancelFn) state.cancelFn()
|
||||||
|
const { promise, cancelHttp } = music[musicInfo.source].getMusicUrl(musicInfo, type)
|
||||||
|
state.cancelFn = cancelHttp
|
||||||
|
return promise.then(result => {
|
||||||
|
return commit('setUrl', { musicInfo, url: result.url, type })
|
||||||
|
}).finally(() => {
|
||||||
|
state.cancelFn = null
|
||||||
|
})
|
||||||
},
|
},
|
||||||
getPic({ commit, state }, musicInfo) {
|
getPic({ commit, state }, musicInfo) {
|
||||||
return music[musicInfo.source].getPic(musicInfo).then(url => commit('getPic', { musicInfo, url }))
|
return music[musicInfo.source].getPic(musicInfo).then(url => commit('getPic', { musicInfo, url }))
|
||||||
|
|
|
@ -68,17 +68,17 @@ export default {
|
||||||
limit: /pagesize: '(\d+)',/,
|
limit: /pagesize: '(\d+)',/,
|
||||||
listData: /global\.features = (\[.+\]);/,
|
listData: /global\.features = (\[.+\]);/,
|
||||||
},
|
},
|
||||||
_cancelIndex: null,
|
_requestObj: null,
|
||||||
_cancelPromiseCancelFn: null,
|
_cancelPromiseCancelFn: null,
|
||||||
getData(url) {
|
getData(url) {
|
||||||
if (this._cancelIndex != null) {
|
if (this._requestObj != null) {
|
||||||
cancelHttp(this._cancelIndex)
|
cancelHttp(this._requestObj)
|
||||||
this._cancelPromiseCancelFn(new Error('取消http请求'))
|
this._cancelPromiseCancelFn(new Error('取消http请求'))
|
||||||
}
|
}
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this._cancelPromiseCancelFn = reject
|
this._cancelPromiseCancelFn = reject
|
||||||
this._cancelIndex = httpGet(url, (err, resp, body) => {
|
this._requestObj = httpGet(url, (err, resp, body) => {
|
||||||
this._cancelIndex = null
|
this._requestObj = null
|
||||||
this._cancelPromiseCancelFn = null
|
this._cancelPromiseCancelFn = null
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
|
|
|
@ -6,9 +6,9 @@ import leaderboard from './leaderboard'
|
||||||
import lyric from './lyric'
|
import lyric from './lyric'
|
||||||
|
|
||||||
const kw = {
|
const kw = {
|
||||||
_musicInfoIndex: null,
|
_musicInfoRequestObj: null,
|
||||||
_musicInfoPromiseCancelFn: null,
|
_musicInfoPromiseCancelFn: null,
|
||||||
_musicPicIndex: null,
|
_musicPicRequestObj: null,
|
||||||
_musicPicPromiseCancelFn: null,
|
_musicPicPromiseCancelFn: null,
|
||||||
// context: null,
|
// context: null,
|
||||||
|
|
||||||
|
@ -52,26 +52,45 @@ const kw = {
|
||||||
},
|
},
|
||||||
|
|
||||||
getMusicUrl(songInfo, type) {
|
getMusicUrl(songInfo, type) {
|
||||||
return new Promise((resolve, reject) => {
|
let requestObj
|
||||||
httpGet(`https://v1.itooi.cn/kuwo/url?id=${songInfo.songmid}&quality=${type.replace(/k$/, '')}&isRedirect=0`, (err, resp, body) => {
|
let cancelFn
|
||||||
|
const p = new Promise((resolve, reject) => {
|
||||||
|
cancelFn = reject
|
||||||
|
requestObj = httpGet(`https://v1.itooi.cn/kuwo/url?id=${songInfo.songmid}&quality=${type.replace(/k$/, '')}&isRedirect=0`, (err, resp, body) => {
|
||||||
|
requestObj = null
|
||||||
|
cancelFn = null
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
return this.getMusicUrl(songInfo, type)
|
const { promise, cancelHttp } = this.getMusicUrl(songInfo, type)
|
||||||
|
obj.cancelHttp = cancelHttp
|
||||||
|
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))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
const obj = {
|
||||||
|
promise: p,
|
||||||
|
cancelHttp() {
|
||||||
|
console.log('cancel')
|
||||||
|
if (!requestObj) return
|
||||||
|
cancelHttp(requestObj)
|
||||||
|
cancelFn(new Error('取消http请求'))
|
||||||
|
requestObj = null
|
||||||
|
cancelFn = null
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return obj
|
||||||
},
|
},
|
||||||
|
|
||||||
getMusicInfo(songInfo) {
|
getMusicInfo(songInfo) {
|
||||||
if (this._musicInfoIndex != null) {
|
if (this._musicInfoRequestObj != null) {
|
||||||
cancelHttp(this._musicInfoIndex)
|
cancelHttp(this._musicInfoRequestObj)
|
||||||
this._musicInfoPromiseCancelFn(new Error('取消http请求'))
|
this._musicInfoPromiseCancelFn(new Error('取消http请求'))
|
||||||
}
|
}
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this._musicInfoPromiseCancelFn = reject
|
this._musicInfoPromiseCancelFn = reject
|
||||||
this._musicInfoIndex = httpGet(`http://www.kuwo.cn/api/www/music/musicInfo?mid=${songInfo.songmid}`, (err, resp, body) => {
|
this._musicInfoRequestObj = httpGet(`http://www.kuwo.cn/api/www/music/musicInfo?mid=${songInfo.songmid}`, (err, resp, body) => {
|
||||||
this._musicInfoIndex = null
|
this._musicInfoRequestObj = null
|
||||||
this._musicInfoPromiseCancelFn = null
|
this._musicInfoPromiseCancelFn = null
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
|
@ -86,7 +105,7 @@ const kw = {
|
||||||
let tasks = []
|
let tasks = []
|
||||||
let songId = musicInfo.songmid
|
let songId = musicInfo.songmid
|
||||||
musicInfo.types.forEach(type => {
|
musicInfo.types.forEach(type => {
|
||||||
tasks.push(kw.getMusicUrl(songId, type.type))
|
tasks.push(kw.getMusicUrl(songId, type.type).promise)
|
||||||
})
|
})
|
||||||
Promise.all(tasks).then(urlInfo => {
|
Promise.all(tasks).then(urlInfo => {
|
||||||
let typeUrl = {}
|
let typeUrl = {}
|
||||||
|
@ -98,20 +117,19 @@ const kw = {
|
||||||
},
|
},
|
||||||
|
|
||||||
getPic(songInfo) {
|
getPic(songInfo) {
|
||||||
if (this._musicPicIndex != null) {
|
if (this._musicPicRequestObj != null) {
|
||||||
cancelHttp(this._musicPicIndex)
|
cancelHttp(this._musicPicRequestObj)
|
||||||
this._musicPicPromiseCancelFn(new Error('取消http请求'))
|
this._musicPicPromiseCancelFn(new Error('取消http请求'))
|
||||||
}
|
}
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this._musicPicPromiseCancelFn = reject
|
this._musicPicPromiseCancelFn = reject
|
||||||
this._musicPicIndex = 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._musicPicIndex = null
|
this._musicPicRequestObj = null
|
||||||
this._musicPicPromiseCancelFn = null
|
this._musicPicPromiseCancelFn = null
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
reject(err)
|
reject(err)
|
||||||
}
|
}
|
||||||
console.log(body)
|
|
||||||
body.code === 200 ? resolve(body.data) : reject(new Error(body.msg))
|
body.code === 200 ? resolve(body.data) : reject(new Error(body.msg))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -65,19 +65,19 @@ export default {
|
||||||
|
|
||||||
},
|
},
|
||||||
limit: 30,
|
limit: 30,
|
||||||
_cancelIndex: null,
|
_cancelRequestObj: null,
|
||||||
_cancelPromiseCancelFn: null,
|
_cancelPromiseCancelFn: null,
|
||||||
_cancelIndex2: null,
|
_cancelRequestObj2: null,
|
||||||
_cancelPromiseCancelFn2: null,
|
_cancelPromiseCancelFn2: null,
|
||||||
getData(url) {
|
getData(url) {
|
||||||
if (this._cancelIndex != null) {
|
if (this._cancelRequestObj != null) {
|
||||||
cancelHttp(this._cancelIndex)
|
cancelHttp(this._cancelRequestObj)
|
||||||
this._cancelPromiseCancelFn(new Error('取消http请求'))
|
this._cancelPromiseCancelFn(new Error('取消http请求'))
|
||||||
}
|
}
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this._cancelPromiseCancelFn = reject
|
this._cancelPromiseCancelFn = reject
|
||||||
this._cancelIndex = httpGet(url, (err, resp, body) => {
|
this._cancelRequestObj = httpGet(url, (err, resp, body) => {
|
||||||
this._cancelIndex = null
|
this._cancelRequestObj = null
|
||||||
this._cancelPromiseCancelFn = null
|
this._cancelPromiseCancelFn = null
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
|
@ -88,14 +88,14 @@ export default {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
getData2(url) {
|
getData2(url) {
|
||||||
if (this._cancelIndex2 != null) {
|
if (this._cancelRequestObj2 != null) {
|
||||||
cancelHttp(this._cancelIndex2)
|
cancelHttp(this._cancelRequestObj2)
|
||||||
this._cancelPromiseCancelFn2(new Error('取消http请求'))
|
this._cancelPromiseCancelFn2(new Error('取消http请求'))
|
||||||
}
|
}
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this._cancelPromiseCancelFn2 = reject
|
this._cancelPromiseCancelFn2 = reject
|
||||||
this._cancelIndex2 = httpGet(url, (err, resp, body) => {
|
this._cancelRequestObj2 = httpGet(url, (err, resp, body) => {
|
||||||
this._cancelIndex2 = null
|
this._cancelRequestObj2 = null
|
||||||
this._cancelPromiseCancelFn2 = null
|
this._cancelPromiseCancelFn2 = null
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { httpGet, cancelHttp } from '../../request'
|
import { httpGet, cancelHttp } from '../../request'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
_musicLrcIndex: null,
|
_musicLrcRequestObj: null,
|
||||||
_musicLrcPromiseCancelFn: null,
|
_musicLrcPromiseCancelFn: null,
|
||||||
formatTime(time) {
|
formatTime(time) {
|
||||||
let m = parseInt(time / 60)
|
let m = parseInt(time / 60)
|
||||||
|
@ -9,14 +9,14 @@ export default {
|
||||||
return (m < 10 ? '0' + m : m) + ':' + (s < 10 ? '0' + s : s)
|
return (m < 10 ? '0' + m : m) + ':' + (s < 10 ? '0' + s : s)
|
||||||
},
|
},
|
||||||
getLyric(songId) {
|
getLyric(songId) {
|
||||||
if (this._musicLrcIndex != null) {
|
if (this._musicLrcRequestObj != null) {
|
||||||
cancelHttp(this._musicLrcIndex)
|
cancelHttp(this._musicLrcRequestObj)
|
||||||
this._musicLrcPromiseCancelFn(new Error('取消http请求'))
|
this._musicLrcPromiseCancelFn(new Error('取消http请求'))
|
||||||
}
|
}
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this._musicLrcPromiseCancelFn = reject
|
this._musicLrcPromiseCancelFn = reject
|
||||||
this._musicLrcIndex = 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._musicLrcIndex = null
|
this._musicLrcRequestObj = null
|
||||||
this._musicLrcPromiseCancelFn = null
|
this._musicLrcPromiseCancelFn = null
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
|
|
|
@ -9,7 +9,7 @@ export default {
|
||||||
regExps: {
|
regExps: {
|
||||||
mInfo: /bitrate:(\d+),format:(\w+),size:([\w.]+)/,
|
mInfo: /bitrate:(\d+),format:(\w+),size:([\w.]+)/,
|
||||||
},
|
},
|
||||||
_musicSearchIndex: null,
|
_musicSearchRequestObj: null,
|
||||||
_musicSearchPromiseCancelFn: null,
|
_musicSearchPromiseCancelFn: null,
|
||||||
limit: 30,
|
limit: 30,
|
||||||
total: 0,
|
total: 0,
|
||||||
|
@ -17,14 +17,14 @@ export default {
|
||||||
allPage: 1,
|
allPage: 1,
|
||||||
// cancelFn: null,
|
// cancelFn: null,
|
||||||
musicSearch(str, page) {
|
musicSearch(str, page) {
|
||||||
if (this._musicSearchIndex != null) {
|
if (this._musicSearchRequestObj != null) {
|
||||||
cancelHttp(this._musicSearchIndex)
|
cancelHttp(this._musicSearchRequestObj)
|
||||||
this._musicSearchPromiseCancelFn(new Error('取消http请求'))
|
this._musicSearchPromiseCancelFn(new Error('取消http请求'))
|
||||||
}
|
}
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this._musicSearchPromiseCancelFn = reject
|
this._musicSearchPromiseCancelFn = reject
|
||||||
this._musicSearchIndex = httpGet(`http://search.kuwo.cn/r.s?client=kt&all=${encodeURIComponent(str)}&pn=${page - 1}&rn=${this.limit}&uid=794762570&ver=kwplayer_ar_9.2.2.1&vipver=1&show_copyright_off=1&newver=1&ft=music&cluster=0&strategy=2012&encoding=utf8&rformat=json&vermerge=1&mobi=1&issubtitle=1`, (err, resp, body) => {
|
this._musicSearchRequestObj = httpGet(`http://search.kuwo.cn/r.s?client=kt&all=${encodeURIComponent(str)}&pn=${page - 1}&rn=${this.limit}&uid=794762570&ver=kwplayer_ar_9.2.2.1&vipver=1&show_copyright_off=1&newver=1&ft=music&cluster=0&strategy=2012&encoding=utf8&rformat=json&vermerge=1&mobi=1&issubtitle=1`, (err, resp, body) => {
|
||||||
this._musicSearchIndex = null
|
this._musicSearchRequestObj = null
|
||||||
this._musicSearchPromiseCancelFn = null
|
this._musicSearchPromiseCancelFn = null
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
|
|
|
@ -5,17 +5,17 @@ export default {
|
||||||
regExps: {
|
regExps: {
|
||||||
relWord: /RELWORD=(.+)/,
|
relWord: /RELWORD=(.+)/,
|
||||||
},
|
},
|
||||||
_musicTempSearchIndex: null,
|
_musicTempSearchRequestObj: null,
|
||||||
_musicTempSearchPromiseCancelFn: null,
|
_musicTempSearchPromiseCancelFn: null,
|
||||||
tempSearch(str) {
|
tempSearch(str) {
|
||||||
if (this._musicTempSearchIndex != null) {
|
if (this._musicTempSearchRequestObj != null) {
|
||||||
cancelHttp(this._musicTempSearchIndex)
|
cancelHttp(this._musicTempSearchRequestObj)
|
||||||
this._musicTempSearchPromiseCancelFn(new Error('取消http请求'))
|
this._musicTempSearchPromiseCancelFn(new Error('取消http请求'))
|
||||||
}
|
}
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this._musicTempSearchPromiseCancelFn = reject
|
this._musicTempSearchPromiseCancelFn = reject
|
||||||
this._musicTempSearchIndex = httpGet(`http://www.kuwo.cn/api/www/search/searchKey?key=${encodeURIComponent(str)}`, (err, resp, body) => {
|
this._musicTempSearchRequestObj = httpGet(`http://www.kuwo.cn/api/www/search/searchKey?key=${encodeURIComponent(str)}`, (err, resp, body) => {
|
||||||
this._musicTempSearchIndex = null
|
this._musicTempSearchRequestObj = null
|
||||||
this._musicTempSearchPromiseCancelFn = null
|
this._musicTempSearchPromiseCancelFn = null
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
|
@ -32,8 +32,8 @@ export default {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
cancelTempSearch() {
|
cancelTempSearch() {
|
||||||
if (this._musicTempSearchIndex != null) {
|
if (this._musicTempSearchRequestObj != null) {
|
||||||
cancelHttp(this._musicTempSearchIndex)
|
cancelHttp(this._musicTempSearchRequestObj)
|
||||||
this._musicTempSearchPromiseCancelFn(new Error('取消http请求'))
|
this._musicTempSearchPromiseCancelFn(new Error('取消http请求'))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,7 +1,47 @@
|
||||||
|
import { httpGet, cancelHttp } from '../../request'
|
||||||
import leaderboard from './leaderboard'
|
import leaderboard from './leaderboard'
|
||||||
|
import lyric from './lyric'
|
||||||
|
|
||||||
const tx = {
|
const tx = {
|
||||||
leaderboard,
|
leaderboard,
|
||||||
|
|
||||||
|
getMusicUrl(songInfo, type) {
|
||||||
|
let requestObj
|
||||||
|
let cancelFn
|
||||||
|
const p = new Promise((resolve, reject) => {
|
||||||
|
cancelFn = reject
|
||||||
|
requestObj = httpGet(`https://v1.itooi.cn/tencent/url?id=${songInfo.strMediaMid}&quality=${type.replace(/k$/, '')}&isRedirect=0`, (err, resp, body) => {
|
||||||
|
requestObj = null
|
||||||
|
cancelFn = null
|
||||||
|
if (err) {
|
||||||
|
console.log(err)
|
||||||
|
const { promise, cancelHttp } = this.getMusicUrl(songInfo, type)
|
||||||
|
obj.cancelHttp = cancelHttp
|
||||||
|
return promise
|
||||||
|
}
|
||||||
|
body.code === 200 ? resolve({ type, url: body.data }) : reject(new Error(body.msg))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
const obj = {
|
||||||
|
promise: p,
|
||||||
|
cancelHttp() {
|
||||||
|
console.log('cancel')
|
||||||
|
if (!requestObj) return
|
||||||
|
cancelHttp(requestObj)
|
||||||
|
cancelFn(new Error('取消http请求'))
|
||||||
|
requestObj = null
|
||||||
|
cancelFn = null
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return obj
|
||||||
|
},
|
||||||
|
getLyric(songInfo) {
|
||||||
|
// let singer = songInfo.singer.indexOf('、') > -1 ? songInfo.singer.split('、')[0] : songInfo.singer
|
||||||
|
return lyric.getLyric(songInfo.songmid)
|
||||||
|
},
|
||||||
|
getPic(songInfo) {
|
||||||
|
return Promise.resolve(`https://y.gtimg.cn/music/photo_new/T002R500x500M000${songInfo.albumId}.jpg`)
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export default tx
|
export default tx
|
||||||
|
|
|
@ -83,17 +83,17 @@ export default {
|
||||||
},
|
},
|
||||||
periods: {},
|
periods: {},
|
||||||
periodUrl: 'https://c.y.qq.com/node/pc/wk_v15/top.html',
|
periodUrl: 'https://c.y.qq.com/node/pc/wk_v15/top.html',
|
||||||
_cancelIndex: null,
|
_cancelRequestObj: null,
|
||||||
_cancelPromiseCancelFn: null,
|
_cancelPromiseCancelFn: null,
|
||||||
getData(url) {
|
getData(url) {
|
||||||
if (this._cancelIndex != null) {
|
if (this._cancelRequestObj != null) {
|
||||||
cancelHttp(this._cancelIndex)
|
cancelHttp(this._cancelRequestObj)
|
||||||
this._cancelPromiseCancelFn(new Error('取消http请求'))
|
this._cancelPromiseCancelFn(new Error('取消http请求'))
|
||||||
}
|
}
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this._cancelPromiseCancelFn = reject
|
this._cancelPromiseCancelFn = reject
|
||||||
this._cancelIndex = httpGet(url, (err, resp, body) => {
|
this._cancelRequestObj = httpGet(url, (err, resp, body) => {
|
||||||
this._cancelIndex = null
|
this._cancelRequestObj = null
|
||||||
this._cancelPromiseCancelFn = null
|
this._cancelPromiseCancelFn = null
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
|
@ -143,7 +143,7 @@ export default {
|
||||||
size,
|
size,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
types.reverse()
|
// types.reverse()
|
||||||
return {
|
return {
|
||||||
singer: this.getSinger(item.singer),
|
singer: this.getSinger(item.singer),
|
||||||
name: item.title,
|
name: item.title,
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
import { httpGet, cancelHttp } from '../../request'
|
||||||
|
import { b64DecodeUnicode } from '../../index'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
_musicLrcRequestObj: null,
|
||||||
|
_musicLrcPromiseCancelFn: null,
|
||||||
|
regexps: {
|
||||||
|
matchLrc: /.+"lyric":"([\w=+/]*)".+/,
|
||||||
|
},
|
||||||
|
getLyric(songmid) {
|
||||||
|
if (this._musicLrcRequestObj != null) {
|
||||||
|
cancelHttp(this._musicLrcRequestObj)
|
||||||
|
this._musicLrcPromiseCancelFn(new Error('取消http请求'))
|
||||||
|
}
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
this._musicLrcPromiseCancelFn = reject
|
||||||
|
this._musicLrcRequestObj = httpGet(`https://c.y.qq.com/lyric/fcgi-bin/fcg_query_lyric_new.fcg?songmid=${songmid}&g_tk=2001461048&loginUin=0&hostUin=0&format=jsonp&inCharset=utf8&outCharset=utf-8&platform=yqq`, {
|
||||||
|
headers: {
|
||||||
|
Referer: 'https://y.qq.com/portal/player.html',
|
||||||
|
},
|
||||||
|
}, (err, resp, body) => {
|
||||||
|
this._musicLrcRequestObj = null
|
||||||
|
this._musicLrcPromiseCancelFn = null
|
||||||
|
if (err) {
|
||||||
|
console.log(err)
|
||||||
|
reject(err)
|
||||||
|
}
|
||||||
|
resolve(b64DecodeUnicode(body.replace(this.regexps.matchLrc, '$1')))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}
|
|
@ -61,17 +61,17 @@ export default {
|
||||||
regExps: {
|
regExps: {
|
||||||
list: /<textarea id="song-list-pre-data" style="display:none;">(.+?)<\/textarea>/,
|
list: /<textarea id="song-list-pre-data" style="display:none;">(.+?)<\/textarea>/,
|
||||||
},
|
},
|
||||||
_cancelIndex: null,
|
_cancelRequestObj: null,
|
||||||
_cancelPromiseCancelFn: null,
|
_cancelPromiseCancelFn: null,
|
||||||
getData(url) {
|
getData(url) {
|
||||||
if (this._cancelIndex != null) {
|
if (this._cancelRequestObj != null) {
|
||||||
cancelHttp(this._cancelIndex)
|
cancelHttp(this._cancelRequestObj)
|
||||||
this._cancelPromiseCancelFn(new Error('取消http请求'))
|
this._cancelPromiseCancelFn(new Error('取消http请求'))
|
||||||
}
|
}
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this._cancelPromiseCancelFn = reject
|
this._cancelPromiseCancelFn = reject
|
||||||
this._cancelIndex = httpGet(url, (err, resp, body) => {
|
this._cancelRequestObj = httpGet(url, (err, resp, body) => {
|
||||||
this._cancelIndex = null
|
this._cancelRequestObj = null
|
||||||
this._cancelPromiseCancelFn = null
|
this._cancelPromiseCancelFn = null
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
|
|
|
@ -3,46 +3,25 @@ import request from 'request'
|
||||||
import { debugRequest } from './env'
|
import { debugRequest } from './env'
|
||||||
// import fs from 'fs'
|
// import fs from 'fs'
|
||||||
|
|
||||||
const tasks = []
|
const fatchData = (url, method, options, callback) => request(url, {
|
||||||
|
|
||||||
const fatchData = (url, method, options, callback) => {
|
|
||||||
let index = pushTask(tasks, request(url, {
|
|
||||||
method,
|
method,
|
||||||
headers: options.headers,
|
headers: options.headers,
|
||||||
Origin: options.origin,
|
Origin: options.origin,
|
||||||
data: options.data,
|
data: options.data,
|
||||||
json: options.format === undefined || options.format === 'json',
|
json: options.format === undefined || options.format === 'json',
|
||||||
}, (err, resp, body) => {
|
}, (err, resp, body) => {
|
||||||
tasks[index] = null
|
|
||||||
if (err) return callback(err, null)
|
if (err) return callback(err, null)
|
||||||
callback(null, resp, body)
|
callback(null, resp, body)
|
||||||
}))
|
})
|
||||||
return index
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 取消请求
|
* 取消请求
|
||||||
* @param {*} index
|
* @param {*} index
|
||||||
*/
|
*/
|
||||||
export const cancelHttp = index => {
|
export const cancelHttp = requestObj => {
|
||||||
if (index == null) return
|
if (!requestObj) return
|
||||||
console.log('cancel: ', index)
|
console.log('cancel:', requestObj.href)
|
||||||
let r = tasks[index]
|
requestObj.abort()
|
||||||
if (r == null) return
|
|
||||||
r.abort()
|
|
||||||
tasks[index] = null
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const pushTask = (tasks, newTask) => {
|
|
||||||
for (const [index, task] of tasks.entries()) {
|
|
||||||
if (task == null) {
|
|
||||||
tasks[index] = newTask
|
|
||||||
return index
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tasks.push(newTask)
|
|
||||||
return tasks.length - 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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'" :download-btn="item.source == 'kw'" :remove-btn="false" @btn-click="handleBtnClick")
|
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")
|
||||||
//- 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.testPlay(index) : this.handleSearch(index)
|
(this.source == 'kw' || this.source == 'tx') ? this.testPlay(index) : this.handleSearch(index)
|
||||||
this.clickTime = 0
|
this.clickTime = 0
|
||||||
this.clickIndex = -1
|
this.clickIndex = -1
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue