Skip to content

Commit

Permalink
Merge pull request #56 from gnehs/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
gnehs authored Sep 9, 2018
2 parents c71a3a7 + 01012fd commit 88eb90c
Show file tree
Hide file tree
Showing 7 changed files with 229 additions and 144 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,4 @@ config.json
sessions/*
playlist.json
package-lock.json
dataModule/netease2Pin.json
27 changes: 2 additions & 25 deletions dataModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,6 @@ const session = require('express-session')({
expires: new Date(Date.now() + 60 * 60 * 1000 * 24 * 7)
}
});
const rp = require('request-promise');

const options = url => ({
method: 'GET',
uri: url,
headers: {
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "zh-TW,zh;q=0.9,en-US;q=0.8,en;q=0.7",
"Cache-Control": "max-age=0",
"DNT": 1,
"Host": "music.126.net",
"Upgrade-Insecure-Requests": 1,
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36"
},
rejectUnauthorized: false,
followAllRedirects: true
})

router.use(session);

Expand All @@ -53,10 +35,6 @@ fs.readdir(__dirname + "/dataModule", (err, files) => {
});
})

function pokaDecode(str) {
return Buffer.from(str, 'base64').toString('utf-8')
}

// 首頁
router.get('/', (req, res) => {
res.send('PokaPlayer API');
Expand Down Expand Up @@ -147,7 +125,7 @@ router.get('/folders/', async(req, res) => {
});
// 透過取得資料夾內檔案清單
router.get('/folderFiles/', async(req, res) => {
//http://localhost:3000/pokaapi/folderFiles/?moduleName=DSM&id=dir_194
//http://localhost:3000/pokaapi/folderFiles/?moduleName=DSM&id=dir_636
let moduleName = req.query.moduleName
let _module = moduleName in moduleList ? require(moduleList[moduleName].js) : null;
// 沒這東西
Expand Down Expand Up @@ -313,7 +291,7 @@ router.get('/song/', async(req, res) => {
let song = await _module.getSong(req, req.query.songRes, req.query.songId)
if (typeof song == 'string')
return res.redirect(song)
else if (moduleName == 'DSM')
else
return song.on('response', function(response) {
//針對 Audio 寫入 Header 避免 Chrome 時間軸不能跳
res.writeHead(206, {
Expand All @@ -323,7 +301,6 @@ router.get('/song/', async(req, res) => {
"Content-Type": response.headers['content-type'] ? response.headers['content-type'] : ''
})
}).pipe(res)
else return song.pipe(res)
});
//-----------------------------> 封面
// 取得封面
Expand Down
6 changes: 3 additions & 3 deletions dataModule/dsm.js
Original file line number Diff line number Diff line change
Expand Up @@ -497,9 +497,9 @@ async function getRandomSongs(id) {
}

async function getLyric(id) {
let
result = (await getAPI("AudioStation/lyrics.cgi", "SYNO.AudioStation.Lyrics", "getlyrics", [{ key: "id", "value": id }], 2)).data.lyrics
if (result.match(lyricRegex))
let result = (await getAPI("AudioStation/lyrics.cgi", "SYNO.AudioStation.Lyrics", "getlyrics", [{ key: "id", "value": id }], 2)).data
result = result && result.lyrics ? result.lyrics : false
if (result && result.match(lyricRegex))
return result
else
return false
Expand Down
Loading

0 comments on commit 88eb90c

Please sign in to comment.