Skip to content

Commit

Permalink
potential config with env
Browse files Browse the repository at this point in the history
  • Loading branch information
nondanee committed Feb 22, 2020
1 parent 6847e51 commit b65e92f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/provider/kuwo.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const search = info => {
const track = id => {
const url = (crypto.kuwoapi
? 'http://mobi.kuwo.cn/mobi.s?f=kuwo&q=' + crypto.kuwoapi.encryptQuery(
'corp=kuwo&p2p=1&type=convert_url2&sig=0&format=' + ['flac', 'mp3'].slice(1).join('|') + '&rid=' + id
'corp=kuwo&p2p=1&type=convert_url2&sig=0&format=' + ['flac', 'mp3'].slice(select.ENABLE_FLAC ? 0 : 1).join('|') + '&rid=' + id
)
: 'http://antiserver.kuwo.cn/anti.s?type=convert_url&format=mp3&response=url&rid=MUSIC_' + id // flac refuse
// : 'http://www.kuwo.cn/url?format=mp3&response=url&type=convert_url3&br=320kmp3&rid=' + id // flac refuse
Expand Down
2 changes: 1 addition & 1 deletion src/provider/migu.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const track = id => {
return request('GET', url, headers)
.then(response => response.json())
.then(jsonBody => {
const playInfo = ['sqPlayInfo', 'hqPlayInfo', 'bqPlayInfo'].slice(1).find(key => (key in jsonBody.data) && jsonBody.data[key].playUrl)
const playInfo = ['sqPlayInfo', 'hqPlayInfo', 'bqPlayInfo'].slice(select.ENABLE_FLAC ? 0 : 1).find(key => (key in jsonBody.data) && jsonBody.data[key].playUrl)
if (playInfo)
return encodeURI(jsonBody.data[playInfo].playUrl)
else
Expand Down
4 changes: 2 additions & 2 deletions src/provider/qq.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const request = require('../request')
const headers = {
'origin': 'http://y.qq.com/',
'referer': 'http://y.qq.com/',
'cookie': null // 'uin=; qm_keyst=',
'cookie': process.env.QQ_COOKIE || null // 'uin=; qm_keyst=',
}

const playable = song => {
Expand Down Expand Up @@ -104,7 +104,7 @@ const ticket = (id, format) => {
const track = id => {
id.key = id.file
return Promise.all(
[['F000', '.flac'], ['M800', '.mp3'], ['M500', '.mp3']].slice((headers.cookie || typeof(window) !== 'undefined') ? 1 : 2)
[['F000', '.flac'], ['M800', '.mp3'], ['M500', '.mp3']].slice((headers.cookie || typeof(window) !== 'undefined') ? (select.ENABLE_FLAC ? 0 : 1) : 2)
.map(format => ticket(id, format).catch(() => null).then(vkey => ({vkey, format})))
)
.then(result => {
Expand Down
4 changes: 3 additions & 1 deletion src/provider/select.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
module.exports = list => list[0]
module.exports = list => list[0]

module.exports.ENABLE_FLAC = (process.env.ENABLE_FLAC || '').toLowerCase() === 'true'
2 changes: 1 addition & 1 deletion src/provider/youtube.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const parse = query => (query || '').split('&').reduce((result, item) => (item =

// const proxy = require('url').parse('http://127.0.0.1:1080')
const proxy = undefined
const key = undefined // YouTube Data API v3
const key = process.env.YOUTUBE_KEY || null // YouTube Data API v3

const signature = (id = '-tKVN2mAKRI') => {
const url =
Expand Down

0 comments on commit b65e92f

Please sign in to comment.