From 7c3473167a5ef98bc90f31b72497f254b52956e5 Mon Sep 17 00:00:00 2001 From: gnehs Date: Sun, 14 Oct 2018 12:17:33 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E5=BA=95=E9=83=A8=E6=92=AD=E6=94=BE?= =?UTF-8?q?=E5=99=A8=E6=B5=AE=E8=B5=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/css/style.css | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/public/css/style.css b/public/css/style.css index 171088bb..2021312b 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -522,7 +522,7 @@ header.mdui-appbar.mdui-appbar-fixed { width: 100vw; height: 67px; position: fixed; - bottom: 0; + bottom: 5px; right: 0; left: 0; z-index: 1999; @@ -531,9 +531,9 @@ header.mdui-appbar.mdui-appbar-fixed { width: 100%; box-sizing: border-box; align-items: center; - border-radius: 10px 10px 0 0; + border-radius: 10px 10px; overflow: hidden; - box-shadow: 0 0 10px #0000004d; + box-shadow: 0 3px 10px #0000004d; background-position: left bottom; background-repeat: no-repeat; background-size: 100% 3px; @@ -548,7 +548,7 @@ header.mdui-appbar.mdui-appbar-fixed { } #player.hide { - transform: translateY(67px); + transform: translateY(80px); box-shadow: none } @@ -624,6 +624,7 @@ header.mdui-appbar.mdui-appbar-fixed { @media screen and (max-width: 767px) { #player { border-radius: 0; + bottom: 0; } #player .timer { font-size: 12px; From 6423895ad68390e5779fef9f82e909baf73557ed Mon Sep 17 00:00:00 2001 From: gnehs Date: Sun, 14 Oct 2018 12:26:37 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E5=BA=95=E9=83=A8=E6=92=AD=E6=94=BE?= =?UTF-8?q?=E5=99=A8=E5=BD=88=E8=B5=B7=E5=8B=95=E7=95=AB=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/css/style.css | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/public/css/style.css b/public/css/style.css index 2021312b..9aee800c 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -531,14 +531,14 @@ header.mdui-appbar.mdui-appbar-fixed { width: 100%; box-sizing: border-box; align-items: center; - border-radius: 10px 10px; + border-radius: 10px; overflow: hidden; box-shadow: 0 3px 10px #0000004d; background-position: left bottom; background-repeat: no-repeat; background-size: 100% 3px; transform: translateY(0); - transition: transform .3s ease, width .3s ease, border-radius .3s ease, box-shadow .3s ease; + transition: transform .3s cubic-bezier(0.42, 0, 0.58, 1.79), width .3s ease, border-radius .3s ease, box-shadow .3s ease, opacity .5s linear; margin: 0 auto; padding-bottom: 3px; } @@ -549,7 +549,8 @@ header.mdui-appbar.mdui-appbar-fixed { #player.hide { transform: translateY(80px); - box-shadow: none + box-shadow: none; + opacity: 0; } #player .mdui-btn { From 069b26394d5dd8cafcf74e98b97021db923f93f3 Mon Sep 17 00:00:00 2001 From: gnehs Date: Wed, 17 Oct 2018 18:12:05 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=B0=8D=20http=20header?= =?UTF-8?q?s=20=E5=BF=AB=E5=8F=96=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dataModule.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dataModule.js b/dataModule.js index 8deb47cd..89eaf66f 100644 --- a/dataModule.js +++ b/dataModule.js @@ -46,7 +46,12 @@ router.get("/", (req, res) => { router.use((req, res, next) => { if (req.session.pass != config.PokaPlayer.password && config.PokaPlayer.passwordSwitch) res.status(403).send("Permission Denied Desu"); - else next(); + else { + if (req.method.toUpperCase() === "GET") { + res.header("Cache-Control", "max-age=7200") //快取 2hr + } + next(); + } }); //-----------------------------> 首頁 // 取得想推薦的東西(? From 38c4ea6e3dc896651be7f82e8af6bef6640932f8 Mon Sep 17 00:00:00 2001 From: gnehs Date: Wed, 17 Oct 2018 18:12:25 +0800 Subject: [PATCH 4/7] =?UTF-8?q?NeteaseCloudMusicApi=20=E6=94=AF=E6=8F=B4?= =?UTF-8?q?=203.0.0=E3=80=81=E5=BF=AB=E5=8F=96=E9=99=90=E5=AE=9A=E6=96=BC?= =?UTF-8?q?=E9=9D=9E=20debug=20=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dataModule.js | 2 +- dataModule/netease2.js | 177 +++++++++++++++++++---------------------- 2 files changed, 84 insertions(+), 95 deletions(-) diff --git a/dataModule.js b/dataModule.js index 89eaf66f..85c1055e 100644 --- a/dataModule.js +++ b/dataModule.js @@ -47,7 +47,7 @@ router.use((req, res, next) => { if (req.session.pass != config.PokaPlayer.password && config.PokaPlayer.passwordSwitch) res.status(403).send("Permission Denied Desu"); else { - if (req.method.toUpperCase() === "GET") { + if (req.method.toUpperCase() === "GET" && config.PokaPlayer.debug) { res.header("Cache-Control", "max-age=7200") //快取 2hr } next(); diff --git a/dataModule/netease2.js b/dataModule/netease2.js index 970a9586..6691be60 100644 --- a/dataModule/netease2.js +++ b/dataModule/netease2.js @@ -128,7 +128,7 @@ function isIdName(id) { var isLoggedin; -const normalOptions = async (url, req = {}) => { +const normalOptions = async(url, req = {}) => { async function m10() { return (await m10s)[Math.floor(Math.random() * (await m10s).length)]; } @@ -136,16 +136,14 @@ const normalOptions = async (url, req = {}) => { method: "GET", uri: url.replace("m10.music.126.net", `${await m10()}/m10.music.126.net`), headers: { - Accept: - "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", + Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", "Accept-Encoding": "gzip, deflate", "Accept-Language": "zh-TW,zh;q=0.9,en-US;q=0.8,en;q=0.7", Connection: "keep-alive", "Cache-Control": "max-age=0", DNT: 1, "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", + "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", Range: req.headers && req.headers.range ? req.headers.range : "", Accept: req.headers && req.headers.accept ? req.headers.accept : "" }, @@ -206,12 +204,12 @@ function migrate(org, t, offset = 10 ** -3) { const strip = (x, precision = 12) => +parseFloat(x.toPrecision(precision)); // 數字精確化 const tagToTime = tag => - isDigit(tag[0]) - ? tag - .split(":") - .reverse() - .reduce((acc, cur, index) => plus(acc, Number(cur) * 60 ** index), 0) - : tag; + isDigit(tag[0]) ? + tag + .split(":") + .reverse() + .reduce((acc, cur, index) => plus(acc, Number(cur) * 60 ** index), 0) : + tag; const parse = (x, isTranslated = false) => { let pLyricLines = x .split("\n") @@ -282,7 +280,9 @@ function migrate(org, t, offset = 10 ** -3) { i += 1; } } else { - parsedLyricPairs.push([parsedLyrics[i][0], [parsedLyrics[i][1], parsedLyrics[i][1]]]); + parsedLyricPairs.push([parsedLyrics[i][0], + [parsedLyrics[i][1], parsedLyrics[i][1]] + ]); i += 1; } } @@ -335,7 +335,7 @@ async function login(config) { async function onLoaded() { if (!config.enabled) return false; console.log("[DataModules][Netease2] 正在登入..."); - return await fs.ensureFile(pin).then(async () => { + return await fs.ensureFile(pin).then(async() => { if ( config && config.login && @@ -388,7 +388,7 @@ function genReq(link) { async function parseSongs(songs, br = 999000) { return await Promise.all( - (await songs).map(async (song, index) => { + (await songs).map(async(song, index) => { song = await song; return { name: song.name, @@ -410,7 +410,10 @@ async function getSong(req, songRes, id) { let isArray = Array.isArray(id); id = isArray ? id : [id]; let result = await Promise.all( - (await getSongsUrl(id, br)).map(async x => request(await normalOptions(x.url, req))) + (await getSongsUrl(id, br)).map(async x => { + let url = x.url ? x.url : `http://music.163.com/song/media/outer/url?id=${x.id}.mp3` + return request(await normalOptions(url, req)) + }) ); return isArray ? result : result[0]; } @@ -437,7 +440,7 @@ async function getAlbum(id) { async function getSongsUrl(songs, br = 999000) { let isArray = Array.isArray(songs); songs = isArray ? songs : [songs]; - let result = await rp(options(`${server}music/url?br=${br}&id=${songs.join()}`)); + let result = await rp(options(`${server}song/url?br=${br}&id=${songs.join()}`)); return isArray ? result.data : result.data[0]; } @@ -503,13 +506,13 @@ async function search(keywords, limit = 30) { album: 10, artist: 100, playlist: 1000 - // user: 1002, - // mv: 1004, - // lyric: 1006, - // radio: 1009 + // user: 1002, + // mv: 1004, + // lyric: 1006, + // radio: 1009 }; - let result = await Object.keys(typeNums).reduce(async (results, type) => { + let result = await Object.keys(typeNums).reduce(async(results, type) => { let types = type + "s"; let typeNum = typeNums[type]; let result; @@ -567,15 +570,14 @@ async function resolveTopPlaylistStack(topPlaylistStack) { (await Promise.all(topPlaylistStack)).map(x => (x[0] ? x[0].playlists : x.playlists)) ).map( x => - x - ? { - name: x.name, - source: "Netease2", - id: x.id, - image: imageUrl(x.coverImgUrl || x.picUrl), - from: "topPlaylistStack" - } - : false + x ? { + name: x.name, + source: "Netease2", + id: x.id, + image: imageUrl(x.coverImgUrl || x.picUrl), + from: "topPlaylistStack" + } : + false ); return [].concat(...playlists); } @@ -584,22 +586,19 @@ async function resolvePlaylistStack(playlistStack) { if (playlistStack.length === 0) return playlistStack; return (await Promise.all(playlistStack)).map( x => - Array.isArray(x) - ? { - name: x[1].name || x[0].playlist.name, - source: "Netease2", - id: x[0].playlist.id, - image: - x[1].image || imageUrl(x[0].playlist.coverImgUrl || x[0].playlist.picUrl), - from: "playlistStack" - } - : { - name: x.playlist.name, - source: "Netease2", - id: x.playlist.id, - image: imageUrl(x.playlist.coverImgUrl || x.playlist.picUrl), - from: "playlistStack" - } + Array.isArray(x) ? { + name: x[1].name || x[0].playlist.name, + source: "Netease2", + id: x[0].playlist.id, + image: x[1].image || imageUrl(x[0].playlist.coverImgUrl || x[0].playlist.picUrl), + from: "playlistStack" + } : { + name: x.playlist.name, + source: "Netease2", + id: x.playlist.id, + image: imageUrl(x.playlist.coverImgUrl || x.playlist.picUrl), + from: "playlistStack" + } ); } @@ -613,21 +612,19 @@ async function resolvedailyRecommendStack(dailyRecommendStack) { ) ).map( x => - Array.isArray(x) - ? { - name: x[1].name, - id: x[1].id, - image: x[0] || imageUrl(x.coverImgUrl || x.picUrl), - source: "Netease2", - from: "dailyRecommendStack" - } - : { - name: x.name, - id: x.id, - image: imageUrl(x.coverImgUrl || x.picUrl), - source: "Netease2", - from: "dailyRecommendStack" - } + Array.isArray(x) ? { + name: x[1].name, + id: x[1].id, + image: x[0] || imageUrl(x.coverImgUrl || x.picUrl), + source: "Netease2", + from: "dailyRecommendStack" + } : { + name: x.name, + id: x.id, + image: imageUrl(x.coverImgUrl || x.picUrl), + source: "Netease2", + from: "dailyRecommendStack" + } ) ); } @@ -832,7 +829,7 @@ async function getPlaylists(playlists) { async function getPlaylistSongs(id, br = 999000) { let name; - if (isIdName(id)) [id, name] = decomposeIdName(id); + if (isIdName(id))[id, name] = decomposeIdName(id); if (id == "dailyRecommendSongs") { let result = await rp(options(`${server}recommend/songs`)); if (result.code == 200) { @@ -848,13 +845,11 @@ async function getPlaylistSongs(id, br = 999000) { })); return { songs: r, - playlists: [ - { - name: "每日推薦歌曲", - source: "Netease2", - id - } - ] + playlists: [{ + name: "每日推薦歌曲", + source: "Netease2", + id + }] }; } else { console.error(`[DataModules][Netease2] 無法獲取每日推薦歌單。(${result.code})`); @@ -865,13 +860,11 @@ async function getPlaylistSongs(id, br = 999000) { if (result.code == 200) { return { songs: await parseSongs(result.data.map(x => x.simpleSong)), - playlists: [ - { - name: "網易雲音樂雲盤", - source: "Netease2", - id: "yunPan" - } - ] + playlists: [{ + name: "網易雲音樂雲盤", + source: "Netease2", + id: "yunPan" + }] }; } else { console.error(`[DataModules][Netease2] 無法獲取網易雲音樂雲盤。(${result.code})`); @@ -882,14 +875,12 @@ async function getPlaylistSongs(id, br = 999000) { if (result.code == 200) { return { songs: await parseSongs(result.playlist.tracks), - playlists: [ - { - name: name ? name : result.playlist.name, - source: "Netease2", - id: id, - image: imageUrl(result.playlist.coverImgUrl || result.playlist.picUrl) - } - ] + playlists: [{ + name: name ? name : result.playlist.name, + source: "Netease2", + id: id, + image: imageUrl(result.playlist.coverImgUrl || result.playlist.picUrl) + }] }; } else { console.error(`[DataModules][Netease2] 無法獲取歌單 ${id}。(${result.code})`); @@ -1015,12 +1006,12 @@ async function getHome() { topPlaylistStack.push( new Promise((resolve, reject) => { rp( - options( - `${server}top/playlist?limit=${c.limit}&order=${ + options( + `${server}top/playlist?limit=${c.limit}&order=${ c.order in ["hot", "new"] ? c.order : "hot" }&cat=${c.category}` + ) ) - ) .then(data => resolve([data, { image: config.topPlaylist.image || defaultImage }]) ) @@ -1121,24 +1112,22 @@ async function getHome() { function playlistOperation(operation) { switch (operation) { case "add": - return async (songIds, playlistId) => { + return async(songIds, playlistId) => { if (Array.isArray(songIds)) songIds = songIds.join(","); let response = await rp( options( - `${server}playlist/tracks?op=add&pid=${playlistId}&tracks=${songIds}`, - {}, + `${server}playlist/tracks?op=add&pid=${playlistId}&tracks=${songIds}`, {}, true ) ); return response.code < 300 && code >= 200 ? response.body || true : false; }; case "del": - return async (songIds, playlistId) => { + return async(songIds, playlistId) => { if (Array.isArray(songIds)) songIds = songIds.join(","); let response = await rp( options( - `${server}playlist/tracks?op=del&pid=${playlistId}&tracks=${songIds}`, - {}, + `${server}playlist/tracks?op=del&pid=${playlistId}&tracks=${songIds}`, {}, true ) ); @@ -1202,4 +1191,4 @@ module.exports = { req, getUserPlaylists, playlistOperation -}; +}; \ No newline at end of file From 3c34b1782a34a86c3e9cdc6cc0e0ac243ad24d6f Mon Sep 17 00:00:00 2001 From: gnehs Date: Wed, 17 Oct 2018 18:14:45 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BD=88=E8=B5=B7?= =?UTF-8?q?=E5=8B=95=E7=95=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/css/style.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/css/style.css b/public/css/style.css index 9aee800c..e978df7d 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -538,7 +538,7 @@ header.mdui-appbar.mdui-appbar-fixed { background-repeat: no-repeat; background-size: 100% 3px; transform: translateY(0); - transition: transform .3s cubic-bezier(0.42, 0, 0.58, 1.79), width .3s ease, border-radius .3s ease, box-shadow .3s ease, opacity .5s linear; + transition: transform .3s cubic-bezier(0.42, 0, 0.58, 1.79), width .3s ease, border-radius .3s ease, box-shadow .3s ease, opacity .35s linear; margin: 0 auto; padding-bottom: 3px; } From 8e8c363f3a1d0c13e5865bd19217b0007e181034 Mon Sep 17 00:00:00 2001 From: gnehs Date: Wed, 17 Oct 2018 18:47:46 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E6=BA=96=E5=82=99=E7=99=BC=E5=B8=83=200.13?= =?UTF-8?q?.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 967cc8cf..abd990c8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "pokaplayer", - "version": "0.12.7", + "version": "0.13.0", "lockfileVersion": 1, "requires": true, "dependencies": { From aa035f79ca24b4b44966c6e87b764a30e44cc9af Mon Sep 17 00:00:00 2001 From: gnehs Date: Wed, 17 Oct 2018 18:48:56 +0800 Subject: [PATCH 7/7] 0.13.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b094645b..bb119e5e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pokaplayer", - "version": "0.12.7", + "version": "0.13.0", "description": "", "main": "index.js", "scripts": {