Skip to content

Commit

Permalink
Merge pull request #58 from gnehs/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
gnehs authored Sep 22, 2018
2 parents 1072b86 + bdd6802 commit f08ef24
Show file tree
Hide file tree
Showing 6 changed files with 208 additions and 82 deletions.
49 changes: 25 additions & 24 deletions dataModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ router.use((req, res, next) => {
});
//-----------------------------> 首頁
// 取得想推薦的東西(?
router.get('/home/', async (req, res) => {
router.get('/home/', async(req, res) => {
//http://localhost:3000/pokaapi/home
let resData = { folders: [], songs: [], albums: [], songs: [], artists: [], composers: [], playlists: [] }
for (var i in Object.keys(moduleList)) {
Expand All @@ -74,7 +74,8 @@ router.get('/home/', async (req, res) => {
}
return res.json(resData)
});
router.get('/addPin/', async (req, res) => {
//-----------------------------> 釘選好朋油
router.post('/addPin/', async(req, res) => {
//http://localhost:3000/pokaapi/addPin/?moduleName=DSM&type=album&id={%22album%22:%22%E4%B8%96%E7%95%8C%E3%81%AE%E6%9E%9C%E3%81%A6%E3%81%AB%E5%90%9B%E3%81%8C%E3%81%84%E3%81%A6%E3%82%82%22,%22album_artist%22:%22%E5%96%9C%E5%A4%9A%E4%BF%AE%E5%B9%B3%22}&name=%E4%B8%96%E7%95%8C%E3%81%AE%E6%9E%9C%E3%81%A6%E3%81%AB%E5%90%9B%E3%81%8C%E3%81%84%E3%81%A6%E3%82%82
//[{"type":"album","criteria":{"album":"世界の果てに君がいても","album_artist":"喜多修平"},"name":"世界の果てに君がいても"}]
let moduleName = req.query.moduleName
Expand All @@ -84,7 +85,7 @@ router.get('/addPin/', async (req, res) => {

res.json(await _module.addPin(req.query.type, req.query.id, req.query.name))
});
router.get('/unPin/', async (req, res) => {
router.post('/unPin/', async(req, res) => {
//http://localhost:3000/pokaapi/unPin/?moduleName=DSM&type=album&id={%22album%22:%22%E4%B8%96%E7%95%8C%E3%81%AE%E6%9E%9C%E3%81%A6%E3%81%AB%E5%90%9B%E3%81%8C%E3%81%84%E3%81%A6%E3%82%82%22,%22album_artist%22:%22%E5%96%9C%E5%A4%9A%E4%BF%AE%E5%B9%B3%22}&name=%E4%B8%96%E7%95%8C%E3%81%AE%E6%9E%9C%E3%81%A6%E3%81%AB%E5%90%9B%E3%81%8C%E3%81%84%E3%81%A6%E3%82%82
//[{"type":"album","criteria":{"album":"世界の果てに君がいても","album_artist":"喜多修平"},"name":"世界の果てに君がいても"}]
let moduleName = req.query.moduleName
Expand All @@ -94,7 +95,7 @@ router.get('/unPin/', async (req, res) => {

res.json(await _module.unPin(req.query.type, req.query.id, req.query.name))
});
router.get('/isPinned/', async (req, res) => {
router.post('/isPinned/', async(req, res) => {
//http://localhost:3000/pokaapi/isPinned/?moduleName=DSM&type=album&id={%22album%22:%22%E4%B8%96%E7%95%8C%E3%81%AE%E6%9E%9C%E3%81%A6%E3%81%AB%E5%90%9B%E3%81%8C%E3%81%84%E3%81%A6%E3%82%82%22,%22album_artist%22:%22%E5%96%9C%E5%A4%9A%E4%BF%AE%E5%B9%B3%22}&name=%E4%B8%96%E7%95%8C%E3%81%AE%E6%9E%9C%E3%81%A6%E3%81%AB%E5%90%9B%E3%81%8C%E3%81%84%E3%81%A6%E3%82%82
//[{"type":"album","criteria":{"album":"世界の果てに君がいても","album_artist":"喜多修平"},"name":"世界の果てに君がいても"}]
let moduleName = req.query.moduleName
Expand All @@ -107,7 +108,7 @@ router.get('/isPinned/', async (req, res) => {

//-----------------------------> 資料夾
// 取得資料夾清單(根目錄)
router.get('/folders/', async (req, res) => {
router.get('/folders/', async(req, res) => {
//http://localhost:3000/pokaapi/folders
let folders = { folders: [], songs: [] }
for (var i in Object.keys(moduleList)) {
Expand All @@ -124,7 +125,7 @@ router.get('/folders/', async (req, res) => {
res.json(folders);
});
// 透過取得資料夾內檔案清單
router.get('/folderFiles/', async (req, res) => {
router.get('/folderFiles/', async(req, res) => {
//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 All @@ -140,7 +141,7 @@ router.get('/folderFiles/', async (req, res) => {

//-----------------------------> 搜尋
// 搜尋
router.get('/search/', async (req, res) => {
router.get('/search/', async(req, res) => {
//http://localhost:3000/pokaapi/search/?keyword=a
let resData = { folders: [], songs: [], albums: [], songs: [], artists: [], composers: [], playlists: [] }
for (var i in Object.keys(moduleList)) {
Expand Down Expand Up @@ -168,7 +169,7 @@ router.get('/search/', async (req, res) => {
});
//-----------------------------> 專輯
// 取得專輯清單
router.get('/albums/', async (req, res) => {
router.get('/albums/', async(req, res) => {
//http://localhost:3000/pokaapi/albums
let albums = { albums: [] }
for (var i in Object.keys(moduleList)) {
Expand All @@ -184,7 +185,7 @@ router.get('/albums/', async (req, res) => {
res.json(albums);
});
// 取得專輯歌曲
router.get('/albumSongs/', async (req, res) => {
router.get('/albumSongs/', async(req, res) => {
let moduleName = req.query.moduleName
let _module = moduleName in moduleList ? require(moduleList[moduleName].js) : null;
// 沒這東西
Expand All @@ -196,7 +197,7 @@ router.get('/albumSongs/', async (req, res) => {
return res.json(albumSongs)
});
// 取得專輯資料
router.get('/album/', async (req, res) => {
router.get('/album/', async(req, res) => {
let moduleName = req.query.moduleName
let _module = moduleName in moduleList ? require(moduleList[moduleName].js) : null;
// 沒這東西
Expand All @@ -209,7 +210,7 @@ router.get('/album/', async (req, res) => {
});
//-----------------------------> 播放清單
// 取得播放清單的清單
router.get('/playlists/', async (req, res) => {
router.get('/playlists/', async(req, res) => {
//http://localhost:3000/pokaapi/playlists
let r = { playlists: [] }
for (var i in Object.keys(moduleList)) {
Expand All @@ -225,7 +226,7 @@ router.get('/playlists/', async (req, res) => {
res.json(r);
});
// 取得播放清單的歌曲
router.get('/playlistSongs/', async (req, res) => {
router.get('/playlistSongs/', async(req, res) => {
//http://localhost:3000/pokaapi/playlistSongs/?moduleName=DSM&id=playlist_shared_normal/15
let moduleName = req.query.moduleName
let _module = moduleName in moduleList ? require(moduleList[moduleName].js) : null;
Expand All @@ -237,7 +238,7 @@ router.get('/playlistSongs/', async (req, res) => {

//-----------------------------> 演出者
// 取得演出者資料
router.get('/artist/', async (req, res) => {
router.get('/artist/', async(req, res) => {
//http://localhost:3000/pokaapi/artist/?moduleName=Netease2&id=19859
let moduleName = req.query.moduleName
let _module = moduleName in moduleList ? require(moduleList[moduleName].js) : null;
Expand All @@ -248,7 +249,7 @@ router.get('/artist/', async (req, res) => {
});

// 取得演出者清單
router.get('/artists/', async (req, res) => {
router.get('/artists/', async(req, res) => {
//http://localhost:3000/pokaapi/artists
let r = { artists: [] }
for (var i in Object.keys(moduleList)) {
Expand All @@ -264,7 +265,7 @@ router.get('/artists/', async (req, res) => {
res.json(r);
});
// 取得演出者的專輯
router.get('/artistAlbums/', async (req, res) => {
router.get('/artistAlbums/', async(req, res) => {
//http://localhost:3000/pokaapi/artistAlbums/?moduleName=DSM&id=ひいらぎ
let moduleName = req.query.moduleName
let _module = moduleName in moduleList ? require(moduleList[moduleName].js) : null;
Expand All @@ -275,7 +276,7 @@ router.get('/artistAlbums/', async (req, res) => {
});
//-----------------------------> 作曲者
// 取得作曲者清單
router.get('/composers/', async (req, res) => {
router.get('/composers/', async(req, res) => {
//http://localhost:3000/pokaapi/composers
let r = { composers: [] }
for (var i in Object.keys(moduleList)) {
Expand All @@ -292,7 +293,7 @@ router.get('/composers/', async (req, res) => {
});

// 取得作曲者的專輯
router.get('/composerAlbums/', async (req, res) => {
router.get('/composerAlbums/', async(req, res) => {
//http://localhost:3000/pokaapi/composerAlbums/?moduleName=DSM&id=飛内将大
let moduleName = req.query.moduleName
let _module = moduleName in moduleList ? require(moduleList[moduleName].js) : null;
Expand All @@ -303,7 +304,7 @@ router.get('/composerAlbums/', async (req, res) => {
});
//-----------------------------> 歌曲
// 取得歌曲串流
router.get('/song/', async (req, res) => {
router.get('/song/', async(req, res) => {
// http://localhost:3000/pokaapi/song/?moduleName=DSM&songRes=original&songId=music_758 //這首 Chrome 會出錯
// http://localhost:3000/pokaapi/song/?moduleName=DSM&songRes=original&songId=music_941
// -> getSong(req, "original", "music_758")
Expand All @@ -315,7 +316,7 @@ router.get('/song/', async (req, res) => {
if (typeof song == 'string')
return res.redirect(song)
else
return song.on('response', function (response) {
return song.on('response', function(response) {
//針對 Audio 寫入 Header 避免 Chrome 時間軸不能跳
res.writeHead(206, {
"Accept-Ranges": response.headers['accept-ranges'] ? response.headers['accept-ranges'] : '',
Expand All @@ -327,7 +328,7 @@ router.get('/song/', async (req, res) => {
});
//-----------------------------> 封面
// 取得封面
router.get('/cover/', async (req, res) => {
router.get('/cover/', async(req, res) => {
let moduleName = req.query.moduleName
let _module = moduleName in moduleList ? require(moduleList[moduleName].js) : null;
// 沒這東西
Expand All @@ -341,7 +342,7 @@ router.get('/cover/', async (req, res) => {
return cover.pipe(res)
});

router.get('/req/', async (req, res) => {
router.get('/req/', async(req, res) => {
let moduleName = req.query.moduleName
let _module = moduleName in moduleList ? require(moduleList[moduleName].js) : null;
// 沒這東西
Expand All @@ -354,7 +355,7 @@ router.get('/req/', async (req, res) => {
});
//-----------------------------> 歌詞
// 搜尋歌詞
router.get('/searchLyrics/', async (req, res) => {
router.get('/searchLyrics/', async(req, res) => {
//http://localhost:3000/pokaapi/searchLyrics/?keyword=a
let resData = { lyrics: [] }
for (var i in Object.keys(moduleList)) {
Expand All @@ -368,7 +369,7 @@ router.get('/searchLyrics/', async (req, res) => {
}
return res.json(resData)
});
router.get('/lyric/', async (req, res) => {
router.get('/lyric/', async(req, res) => {
//http://localhost:3000/pokaapi/lyric/?moduleName=DSM&id=music_1801
let moduleName = req.query.moduleName
let _module = moduleName in moduleList ? require(moduleList[moduleName].js) : null;
Expand All @@ -384,7 +385,7 @@ router.get('/lyric/', async (req, res) => {
});
//-----------------------------> 隨機
// 隨機歌曲
router.get('/randomSongs/', async (req, res) => {
router.get('/randomSongs/', async(req, res) => {
//http://localhost:3000/pokaapi/randomSongs/
let resData = { songs: [] }
for (var i in Object.keys(moduleList)) {
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pokaplayer",
"version": "0.10.5",
"version": "0.10.6",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
6 changes: 3 additions & 3 deletions public/js/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ function getBackground() {

/*===== Pin =====*/
async function isPinned(source, type, id, name) {
let result = (await axios.get(`/pokaapi/isPinned/?moduleName=${source}&type=${type}&id=${id}&name=${name}`))
let result = (await axios.post(`/pokaapi/isPinned/?moduleName=${source}&type=${type}&id=${id}&name=${name}`))
return result.data
}
async function addPin(source, type, id, name) {
let result = (await axios.get(`/pokaapi/addPin/?moduleName=${source}&type=${type}&id=${id}&name=${name}`)).data
let result = (await axios.post(`/pokaapi/addPin/?moduleName=${source}&type=${type}&id=${id}&name=${name}`)).data
if (result != true)
mdui.snackbar({
message: `釘選失敗`,
Expand All @@ -26,7 +26,7 @@ async function addPin(source, type, id, name) {
return result
}
async function unPin(source, type, id, name) {
let result = (await axios.get(`/pokaapi/unPin/?moduleName=${source}&type=${type}&id=${id}&name=${name}`)).data
let result = (await axios.post(`/pokaapi/unPin/?moduleName=${source}&type=${type}&id=${id}&name=${name}`)).data
if (result != true)
mdui.snackbar({
message: `取消釘選失敗`,
Expand Down
Loading

0 comments on commit f08ef24

Please sign in to comment.