Skip to content
This repository was archived by the owner on Jun 26, 2024. It is now read-only.

Commit 6bf01a9

Browse files
author
trazyn
authored
Merge pull request #289 from trazyn/dev
Release v1.3.1
2 parents 9d98e26 + 9f1cb8b commit 6bf01a9

File tree

25 files changed

+903
-179
lines changed

25 files changed

+903
-179
lines changed

.codeclimate.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
version: "2" # required to adjust maintainability checks
2+
checks:
3+
argument-count:
4+
config:
5+
threshold: 4
6+
complex-logic:
7+
config:
8+
threshold: 4
9+
file-lines:
10+
config:
11+
threshold: 1000
12+
method-complexity:
13+
config:
14+
threshold: 6
15+
method-count:
16+
config:
17+
threshold: 20
18+
method-lines:
19+
config:
20+
threshold: 500
21+
nested-control-flow:
22+
config:
23+
threshold: 4
24+
return-statements:
25+
config:
26+
threshold: 4
27+
28+
engines:
29+
duplication:
30+
enabled: false
31+
config:
32+
languages:
33+
javascript:
34+
mass_threshold: 65

README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -48,27 +48,27 @@
4848
Download the last version on the [website](https://github.com/trazyn/ieaseMusic/releases/latest) or below.
4949

5050
#### Mac(10.9+)
51-
[Download](https://github.com/trazyn/ieaseMusic/releases/download/v1.3.0/ieaseMusic-1.3.0-mac.dmg) the `.dmg` file, Or use `homebrew`:
51+
[Download](https://github.com/trazyn/ieaseMusic/releases/download/v1.3.1/ieaseMusic-1.3.1-mac.dmg) the `.dmg` file, Or use `homebrew`:
5252
```
5353
brew cask install ieasemusic
5454
```
5555

5656
#### Linux
5757

58-
[Download](https://github.com/trazyn/ieaseMusic/releases/download/v1.3.0/ieaseMusic-1.3.0-linux-amd64.deb) the `.deb` file for 'Debian / Ubuntu':
58+
[Download](https://github.com/trazyn/ieaseMusic/releases/download/v1.3.1/ieaseMusic-1.3.1-linux-amd64.deb) the `.deb` file for 'Debian / Ubuntu':
5959
```
60-
$ sudo dpkg -i ieaseMusic-1.3.0-linux-amd64.deb
60+
$ sudo dpkg -i ieaseMusic-1.3.1-linux-amd64.deb
6161
```
6262

63-
[Download](https://github.com/trazyn/ieaseMusic/releases/download/v1.3.0/ieaseMusic-1.3.0-linux-x86_64.rpm) the `.rpm` file for 'Centos/RHEL':
63+
[Download](https://github.com/trazyn/ieaseMusic/releases/download/v1.3.1/ieaseMusic-1.3.1-linux-x86_64.rpm) the `.rpm` file for 'Centos/RHEL':
6464
```
65-
$ sudo yum localinstall ieaseMusic-1.3.0-linux-x86_64.rpm
65+
$ sudo yum localinstall ieaseMusic-1.3.1-linux-x86_64.rpm
6666
```
6767

68-
[Download](https://github.com/trazyn/ieaseMusic/releases/download/v1.3.0/iease-music-1.3.0-x86_64.AppImage) the `.Appimage` file for other distribution:
68+
[Download](https://github.com/trazyn/ieaseMusic/releases/download/v1.3.1/iease-music-1.3.1-x86_64.AppImage) the `.Appimage` file for other distribution:
6969
```
70-
$ chmod u+x iease-music-1.3.0-x86_64.AppImage
71-
$ ./iease-music-1.3.0-x86_64.AppImage
70+
$ chmod u+x iease-music-1.3.1-x86_64.AppImage
71+
$ ./iease-music-1.3.1-x86_64.AppImage
7272
```
7373

7474
Archlinux `pacman` install:

main.js

+28-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ let tray;
2323
let mainWindow;
2424
let isOsx = _PLATFORM === 'darwin';
2525
let isLinux = _PLATFORM === 'linux';
26+
27+
let showMenuBarOnLinux = false;
28+
let revertTrayIcon = false;
29+
2630
// Shared data to other applocation via a unix socket file
2731
let shared = {
2832
modes: [],
@@ -400,7 +404,7 @@ let dockMenu = [
400404
];
401405

402406
function updateMenu(playing) {
403-
if (!isOsx) {
407+
if (!isOsx && !showMenuBarOnLinux) {
404408
return;
405409
}
406410

@@ -420,6 +424,13 @@ function updateTray(playing) {
420424
: `${__dirname}/src/assets/notplaying.png`
421425
;
422426

427+
if (revertTrayIcon) {
428+
icon = playing
429+
? `${__dirname}/src/assets/playing-dark-panel.png`
430+
: `${__dirname}/src/assets/notplaying-dark-panel.png`
431+
;
432+
}
433+
423434
if (!tray) {
424435
// Init tray icon
425436
tray = new Tray(icon);
@@ -479,7 +490,9 @@ const createMainWindow = () => {
479490
path.join(__dirname, 'src/assets/dock.png')
480491
);
481492
// Disable default menu bar
482-
mainWindow.setMenu(null);
493+
if (!showMenuBarOnLinux) {
494+
mainWindow.setMenu(null);
495+
}
483496
}
484497

485498
mainWindowState.manage(mainWindow);
@@ -586,6 +599,9 @@ const createMainWindow = () => {
586599
() => debug('Apply proxy: %s', args.proxy)
587600
);
588601

602+
revertTrayIcon = args.revertTrayIcon;
603+
debug(revertTrayIcon);
604+
589605
if (!args.showTray) {
590606
if (tray) {
591607
tray.destroy();
@@ -638,6 +654,8 @@ const createMainWindow = () => {
638654
updater.installAutoUpdater(() => goodbye());
639655
downloader.createDownloader();
640656
mainWindow.webContents.setUserAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8');
657+
658+
global.mainWindow = mainWindow;
641659
debug('Create main process success 🍻');
642660
};
643661

@@ -666,6 +684,14 @@ app.on('before-quit', e => {
666684
process.exit(0);
667685
});
668686
app.on('ready', () => {
687+
storage.get('preferences', (err, data) => {
688+
debug(data);
689+
if (!err && data) {
690+
showMenuBarOnLinux = data.showMenuBarOnLinux;
691+
revertTrayIcon = data.revertTrayIcon;
692+
}
693+
});
694+
669695
createMainWindow();
670696

671697
storage.get('preferences', (err, data) => {

package.json

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "iease-music",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"description": "这应该是最好的网易云音乐播放器了,没有之一,如果有请打醒 🤘",
55
"main": "main.js",
66
"scripts": {
@@ -99,7 +99,7 @@
9999
"copy-webpack-plugin": "^4.0.1",
100100
"cross-env": "^5.2.0",
101101
"css-loader": "^1.0.0",
102-
"electron": "^2.0.6",
102+
"electron": "^2.0.9",
103103
"electron-builder": "^20.19.2",
104104
"eslint": "^5.2.0",
105105
"eslint-config-standard": "^11.0.0",
@@ -114,7 +114,7 @@
114114
"express": "^4.15.4",
115115
"html-loader": "^0.5.1",
116116
"html-webpack-plugin": "^3.2.0",
117-
"style-loader": "^0.21.0",
117+
"style-loader": "^0.23.0",
118118
"svg-inline-loader": "^0.8.0",
119119
"uglifyjs-webpack-plugin": "^1.1.8",
120120
"url-loader": "^1.0.1",
@@ -129,11 +129,12 @@
129129
"big-integer": "^1.6.25",
130130
"classname": "0.0.0",
131131
"cookie-parser": "^1.4.3",
132-
"debug": "^3.1.0",
132+
"crypto": "^1.0.1",
133+
"debug": "^4.0.1",
133134
"delegate": "^3.1.3",
134135
"electron-json-storage": "^4.1.1",
135136
"electron-updater": "^3.0.3",
136-
"electron-window-state": "^4.1.1",
137+
"electron-window-state": "^5.0.1",
137138
"han": "0.0.7",
138139
"ionicons201": "^1.0.0",
139140
"libphonenumber-js": "^0.4.44",

server/provider/Kuwo.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default async(request, keyword, artists) => {
5252
},
5353
});
5454

55-
if (!response) {
55+
if (!response || response === 'IPDeny') {
5656
error(chalk.black.bgRed('🚧 Nothing.'));
5757
return Promise.reject(Error(404));
5858
}

server/provider/MiGu.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ export default async(request, keyword, artists) => {
1919
}
2020
});
2121

22-
if (response.success !== true || response.musics.length === 0) {
22+
if (
23+
false
24+
|| response.success !== true
25+
|| !response.musics
26+
|| response.musics.length === 0
27+
) {
2328
error(chalk.black.bgRed('🚧 Nothing.'));
2429
return Promise.reject(Error(404));
2530
}

server/provider/index.js

+21-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11

2-
import storage from 'electron-json-storage';
2+
import fs from 'fs';
33
import Netease from './Netease';
44
import QQ from './QQ';
55
import MiGu from './MiGu';
66
import Kugou from './Kugou';
77
import Baidu from './Baidu';
88
import Xiami from './Xiami';
99
import Kuwo from './Kuwo';
10+
import storage from '../../common/storage';
1011

1112
async function getPreferences() {
12-
return new Promise(resolve => {
13-
storage.get('preferences', (err, data) => {
14-
resolve(err ? {} : data);
15-
});
16-
});
13+
return await storage.get('preferences') || {};
1714
}
1815

1916
async function exe(plugins, ...args) {
@@ -53,6 +50,23 @@ async function getFlac(keyword, artists) {
5350
return exe([QQ], keyword, artists, true);
5451
}
5552

53+
async function loadFromLocal(id) {
54+
var downloaded = (await storage.get('downloaded')) || {};
55+
var task = downloaded[id];
56+
57+
if (task) {
58+
if (fs.existsSync(task.path) === false) {
59+
delete downloaded[id];
60+
await storage.set('downloaded', downloaded);
61+
return;
62+
}
63+
64+
return {
65+
src: encodeURI(`file://${task.path}`)
66+
};
67+
}
68+
}
69+
5670
async function getTrack(keyword, artists, id /** This id is only work for netease music */) {
5771
var preferences = await getPreferences();
5872
var enginers = preferences.enginers;
@@ -97,6 +111,7 @@ async function getTrack(keyword, artists, id /** This id is only work for neteas
97111
}
98112

99113
export {
114+
loadFromLocal,
100115
getFlac,
101116
getTrack,
102117
};

server/router/artist.js

+24-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,33 @@
11

22
import express from 'express';
33
import axios from 'axios';
4+
import crypto from 'crypto';
45
import _debug from 'debug';
56

67
const debug = _debug('dev:api');
78
const error = _debug('dev:error');
89
const router = express();
910

11+
// https://github.com/skyline75489/nmdown/blob/ee0f66448b6e64f8b9bdb2f7451a8d4ff63e14c4/cloudmusic/hasher.py
12+
function id2url(id) {
13+
var key = '3go8&$8*3*3h0k(2)2';
14+
var keyCodes = Array.from(key).map((e, i) => key.charCodeAt(i));
15+
var fidCodes = Array.from(id).map((e, i) => id.charCodeAt(i));
16+
17+
var hashCodes = [];
18+
19+
for (let i = 0; i < fidCodes.length; i++) {
20+
let code = (fidCodes[i] ^ keyCodes[i % key.length]) & 0XFF;
21+
hashCodes.push(code);
22+
}
23+
24+
var string = hashCodes.map((e, i) => String.fromCharCode(hashCodes[i])).join('');
25+
var md5 = crypto.createHash('md5').update(string).digest();
26+
var result = Buffer.from(md5).toString('base64').replace(/\//g, '_').replace(/\+/g, '-');
27+
28+
return `https://p4.music.126.net/${result}/${id}.jpg?param=y177y177`;
29+
}
30+
1031
async function getArtist(id) {
1132
var profile = {};
1233
var songs = [];
@@ -43,7 +64,7 @@ async function getArtist(id) {
4364
album: {
4465
id: al.id.toString(),
4566
name: al.name,
46-
cover: `${al.picUrl}?param=y100y100`,
67+
cover: id2url(al.pic_str),
4768
link: `/player/1/${al.id}`
4869
},
4970
artists: ar.map(e => ({
@@ -84,7 +105,8 @@ async function getAlbums(id) {
84105
id: e.id.toString(),
85106
name: e.name,
86107
cover: e.picUrl,
87-
link: `/player/1/${e.id}`
108+
link: `/player/1/${e.id}`,
109+
publishTime: e.publishTime,
88110
}));
89111
}
90112
} catch (ex) {

server/router/player.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ router.get('/song/:id/:name/:artists/:flac?', cache('3 minutes', onlyStatus200),
189189

190190
try {
191191
// Get the highquality track
192-
song = await selector.getFlac(name, artists, true);
192+
song = await selector.loadFromLocal(id) || await selector.getFlac(name, artists, true);
193193
} catch (ex) {
194194
error(ex);
195195
}
@@ -204,6 +204,7 @@ router.get('/song/:id/:name/:artists/:flac?', cache('3 minutes', onlyStatus200),
204204
}
205205
}
206206
} catch (ex) {
207+
error(ex);
207208
debug(chalk.red.underline.bold(`💔 Not found: "${name} - ${artists}"`));
208209
}
209210

src/app.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,15 @@ class App extends Component {
118118
playing.toggle(true);
119119
});
120120

121+
// Get the playlist
122+
ipcRenderer.on('request-playlist', () => {
123+
let downloader = remote.getGlobal('downloader');
124+
125+
if (downloader) {
126+
downloader.webContents.send('response-playlist', JSON.stringify(controller.playlist));
127+
}
128+
});
129+
121130
// Right click menu
122131
window.addEventListener('contextmenu', e => {
123132
let logined = me.hasLogin();
@@ -173,7 +182,7 @@ class App extends Component {
173182
{
174183
label: 'Download 🍭',
175184
click: () => {
176-
ipcRenderer.send('download', { song: JSON.stringify(controller.song) });
185+
ipcRenderer.send('download', { songs: JSON.stringify(controller.song) });
177186
}
178187
},
179188
{

src/assets/notplaying-dark-panel.png

9.32 KB
Loading

src/assets/playing-dark-panel.png

774 Bytes
Loading

src/js/components/Controller/classes.js

+4
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ export default theme => {
4949

5050
'& $playing:after': {
5151
bottom: 16,
52+
opacity: 1,
53+
visibility: 'visible',
5254
}
5355
},
5456

@@ -75,6 +77,8 @@ export default theme => {
7577
right: 0,
7678
bottom: 2,
7779
display: 'inline-block',
80+
opacity: 0,
81+
visibility: 'hidden',
7882
padding: '10px 6px',
7983
fontFamily: 'Roboto',
8084
fontSize: 12,

0 commit comments

Comments
 (0)