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

Commit

Permalink
Merge pull request #289 from trazyn/dev
Browse files Browse the repository at this point in the history
Release v1.3.1
  • Loading branch information
trazyn authored Sep 21, 2018
2 parents 9d98e26 + 9f1cb8b commit 6bf01a9
Show file tree
Hide file tree
Showing 25 changed files with 903 additions and 179 deletions.
34 changes: 34 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: "2" # required to adjust maintainability checks
checks:
argument-count:
config:
threshold: 4
complex-logic:
config:
threshold: 4
file-lines:
config:
threshold: 1000
method-complexity:
config:
threshold: 6
method-count:
config:
threshold: 20
method-lines:
config:
threshold: 500
nested-control-flow:
config:
threshold: 4
return-statements:
config:
threshold: 4

engines:
duplication:
enabled: false
config:
languages:
javascript:
mass_threshold: 65
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,27 @@
Download the last version on the [website](https://github.com/trazyn/ieaseMusic/releases/latest) or below.

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

#### Linux

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

[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':
[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':
```
$ sudo yum localinstall ieaseMusic-1.3.0-linux-x86_64.rpm
$ sudo yum localinstall ieaseMusic-1.3.1-linux-x86_64.rpm
```

[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:
[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:
```
$ chmod u+x iease-music-1.3.0-x86_64.AppImage
$ ./iease-music-1.3.0-x86_64.AppImage
$ chmod u+x iease-music-1.3.1-x86_64.AppImage
$ ./iease-music-1.3.1-x86_64.AppImage
```

Archlinux `pacman` install:
Expand Down
30 changes: 28 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ let tray;
let mainWindow;
let isOsx = _PLATFORM === 'darwin';
let isLinux = _PLATFORM === 'linux';

let showMenuBarOnLinux = false;
let revertTrayIcon = false;

// Shared data to other applocation via a unix socket file
let shared = {
modes: [],
Expand Down Expand Up @@ -400,7 +404,7 @@ let dockMenu = [
];

function updateMenu(playing) {
if (!isOsx) {
if (!isOsx && !showMenuBarOnLinux) {
return;
}

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

if (revertTrayIcon) {
icon = playing
? `${__dirname}/src/assets/playing-dark-panel.png`
: `${__dirname}/src/assets/notplaying-dark-panel.png`
;
}

if (!tray) {
// Init tray icon
tray = new Tray(icon);
Expand Down Expand Up @@ -479,7 +490,9 @@ const createMainWindow = () => {
path.join(__dirname, 'src/assets/dock.png')
);
// Disable default menu bar
mainWindow.setMenu(null);
if (!showMenuBarOnLinux) {
mainWindow.setMenu(null);
}
}

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

revertTrayIcon = args.revertTrayIcon;
debug(revertTrayIcon);

if (!args.showTray) {
if (tray) {
tray.destroy();
Expand Down Expand Up @@ -638,6 +654,8 @@ const createMainWindow = () => {
updater.installAutoUpdater(() => goodbye());
downloader.createDownloader();
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');

global.mainWindow = mainWindow;
debug('Create main process success 🍻');
};

Expand Down Expand Up @@ -666,6 +684,14 @@ app.on('before-quit', e => {
process.exit(0);
});
app.on('ready', () => {
storage.get('preferences', (err, data) => {
debug(data);
if (!err && data) {
showMenuBarOnLinux = data.showMenuBarOnLinux;
revertTrayIcon = data.revertTrayIcon;
}
});

createMainWindow();

storage.get('preferences', (err, data) => {
Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iease-music",
"version": "1.3.0",
"version": "1.3.1",
"description": "这应该是最好的网易云音乐播放器了,没有之一,如果有请打醒 🤘",
"main": "main.js",
"scripts": {
Expand Down Expand Up @@ -99,7 +99,7 @@
"copy-webpack-plugin": "^4.0.1",
"cross-env": "^5.2.0",
"css-loader": "^1.0.0",
"electron": "^2.0.6",
"electron": "^2.0.9",
"electron-builder": "^20.19.2",
"eslint": "^5.2.0",
"eslint-config-standard": "^11.0.0",
Expand All @@ -114,7 +114,7 @@
"express": "^4.15.4",
"html-loader": "^0.5.1",
"html-webpack-plugin": "^3.2.0",
"style-loader": "^0.21.0",
"style-loader": "^0.23.0",
"svg-inline-loader": "^0.8.0",
"uglifyjs-webpack-plugin": "^1.1.8",
"url-loader": "^1.0.1",
Expand All @@ -129,11 +129,12 @@
"big-integer": "^1.6.25",
"classname": "0.0.0",
"cookie-parser": "^1.4.3",
"debug": "^3.1.0",
"crypto": "^1.0.1",
"debug": "^4.0.1",
"delegate": "^3.1.3",
"electron-json-storage": "^4.1.1",
"electron-updater": "^3.0.3",
"electron-window-state": "^4.1.1",
"electron-window-state": "^5.0.1",
"han": "0.0.7",
"ionicons201": "^1.0.0",
"libphonenumber-js": "^0.4.44",
Expand Down
2 changes: 1 addition & 1 deletion server/provider/Kuwo.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default async(request, keyword, artists) => {
},
});

if (!response) {
if (!response || response === 'IPDeny') {
error(chalk.black.bgRed('🚧 Nothing.'));
return Promise.reject(Error(404));
}
Expand Down
7 changes: 6 additions & 1 deletion server/provider/MiGu.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ export default async(request, keyword, artists) => {
}
});

if (response.success !== true || response.musics.length === 0) {
if (
false
|| response.success !== true
|| !response.musics
|| response.musics.length === 0
) {
error(chalk.black.bgRed('🚧 Nothing.'));
return Promise.reject(Error(404));
}
Expand Down
27 changes: 21 additions & 6 deletions server/provider/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@

import storage from 'electron-json-storage';
import fs from 'fs';
import Netease from './Netease';
import QQ from './QQ';
import MiGu from './MiGu';
import Kugou from './Kugou';
import Baidu from './Baidu';
import Xiami from './Xiami';
import Kuwo from './Kuwo';
import storage from '../../common/storage';

async function getPreferences() {
return new Promise(resolve => {
storage.get('preferences', (err, data) => {
resolve(err ? {} : data);
});
});
return await storage.get('preferences') || {};
}

async function exe(plugins, ...args) {
Expand Down Expand Up @@ -53,6 +50,23 @@ async function getFlac(keyword, artists) {
return exe([QQ], keyword, artists, true);
}

async function loadFromLocal(id) {
var downloaded = (await storage.get('downloaded')) || {};
var task = downloaded[id];

if (task) {
if (fs.existsSync(task.path) === false) {
delete downloaded[id];
await storage.set('downloaded', downloaded);
return;
}

return {
src: encodeURI(`file://${task.path}`)
};
}
}

async function getTrack(keyword, artists, id /** This id is only work for netease music */) {
var preferences = await getPreferences();
var enginers = preferences.enginers;
Expand Down Expand Up @@ -97,6 +111,7 @@ async function getTrack(keyword, artists, id /** This id is only work for neteas
}

export {
loadFromLocal,
getFlac,
getTrack,
};
26 changes: 24 additions & 2 deletions server/router/artist.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,33 @@

import express from 'express';
import axios from 'axios';
import crypto from 'crypto';
import _debug from 'debug';

const debug = _debug('dev:api');
const error = _debug('dev:error');
const router = express();

// https://github.com/skyline75489/nmdown/blob/ee0f66448b6e64f8b9bdb2f7451a8d4ff63e14c4/cloudmusic/hasher.py
function id2url(id) {
var key = '3go8&$8*3*3h0k(2)2';
var keyCodes = Array.from(key).map((e, i) => key.charCodeAt(i));
var fidCodes = Array.from(id).map((e, i) => id.charCodeAt(i));

var hashCodes = [];

for (let i = 0; i < fidCodes.length; i++) {
let code = (fidCodes[i] ^ keyCodes[i % key.length]) & 0XFF;
hashCodes.push(code);
}

var string = hashCodes.map((e, i) => String.fromCharCode(hashCodes[i])).join('');
var md5 = crypto.createHash('md5').update(string).digest();
var result = Buffer.from(md5).toString('base64').replace(/\//g, '_').replace(/\+/g, '-');

return `https://p4.music.126.net/${result}/${id}.jpg?param=y177y177`;
}

async function getArtist(id) {
var profile = {};
var songs = [];
Expand Down Expand Up @@ -43,7 +64,7 @@ async function getArtist(id) {
album: {
id: al.id.toString(),
name: al.name,
cover: `${al.picUrl}?param=y100y100`,
cover: id2url(al.pic_str),
link: `/player/1/${al.id}`
},
artists: ar.map(e => ({
Expand Down Expand Up @@ -84,7 +105,8 @@ async function getAlbums(id) {
id: e.id.toString(),
name: e.name,
cover: e.picUrl,
link: `/player/1/${e.id}`
link: `/player/1/${e.id}`,
publishTime: e.publishTime,
}));
}
} catch (ex) {
Expand Down
3 changes: 2 additions & 1 deletion server/router/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ router.get('/song/:id/:name/:artists/:flac?', cache('3 minutes', onlyStatus200),

try {
// Get the highquality track
song = await selector.getFlac(name, artists, true);
song = await selector.loadFromLocal(id) || await selector.getFlac(name, artists, true);
} catch (ex) {
error(ex);
}
Expand All @@ -204,6 +204,7 @@ router.get('/song/:id/:name/:artists/:flac?', cache('3 minutes', onlyStatus200),
}
}
} catch (ex) {
error(ex);
debug(chalk.red.underline.bold(`💔 Not found: "${name} - ${artists}"`));
}

Expand Down
11 changes: 10 additions & 1 deletion src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,15 @@ class App extends Component {
playing.toggle(true);
});

// Get the playlist
ipcRenderer.on('request-playlist', () => {
let downloader = remote.getGlobal('downloader');

if (downloader) {
downloader.webContents.send('response-playlist', JSON.stringify(controller.playlist));
}
});

// Right click menu
window.addEventListener('contextmenu', e => {
let logined = me.hasLogin();
Expand Down Expand Up @@ -173,7 +182,7 @@ class App extends Component {
{
label: 'Download 🍭',
click: () => {
ipcRenderer.send('download', { song: JSON.stringify(controller.song) });
ipcRenderer.send('download', { songs: JSON.stringify(controller.song) });
}
},
{
Expand Down
Binary file added src/assets/notplaying-dark-panel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/playing-dark-panel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/js/components/Controller/classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export default theme => {

'& $playing:after': {
bottom: 16,
opacity: 1,
visibility: 'visible',
}
},

Expand All @@ -75,6 +77,8 @@ export default theme => {
right: 0,
bottom: 2,
display: 'inline-block',
opacity: 0,
visibility: 'hidden',
padding: '10px 6px',
fontFamily: 'Roboto',
fontSize: 12,
Expand Down
Loading

0 comments on commit 6bf01a9

Please sign in to comment.