Finish ncm qmc flac mp3
Finish UI Add loading screen Change PWA Config Remove useless file Load Element-UI on Demand Fix deploy on sub-folderremotes/origin/HEAD
parent
295925a823
commit
53d4b5efe5
@ -1,2 +0,0 @@
|
||||
User-agent: *
|
||||
Disallow:
|
@ -1,58 +0,0 @@
|
||||
<template>
|
||||
<div class="hello">
|
||||
<h1>{{ msg }}</h1>
|
||||
<p>
|
||||
For a guide and recipes on how to configure / customize this project,<br>
|
||||
check out the
|
||||
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
|
||||
</p>
|
||||
<h3>Installed CLI Plugins</h3>
|
||||
<ul>
|
||||
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
|
||||
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-pwa" target="_blank" rel="noopener">pwa</a></li>
|
||||
</ul>
|
||||
<h3>Essential Links</h3>
|
||||
<ul>
|
||||
<li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
|
||||
<li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
|
||||
<li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
|
||||
<li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
|
||||
<li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
|
||||
</ul>
|
||||
<h3>Ecosystem</h3>
|
||||
<ul>
|
||||
<li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
|
||||
<li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
|
||||
<li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
|
||||
<li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
|
||||
<li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'HelloWorld',
|
||||
props: {
|
||||
msg: String
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
||||
<style scoped>
|
||||
h3 {
|
||||
margin: 40px 0 0;
|
||||
}
|
||||
ul {
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
}
|
||||
li {
|
||||
display: inline-block;
|
||||
margin: 0 10px;
|
||||
}
|
||||
a {
|
||||
color: #42b983;
|
||||
}
|
||||
</style>
|
@ -1,5 +1,33 @@
|
||||
import Vue from 'vue'
|
||||
import Element from 'element-ui'
|
||||
import {
|
||||
Image,
|
||||
Button,
|
||||
Table,
|
||||
TableColumn,
|
||||
Main,
|
||||
Footer,
|
||||
Container,
|
||||
Icon,
|
||||
Row,
|
||||
Col,
|
||||
Upload,
|
||||
Notification,
|
||||
Link
|
||||
} from 'element-ui';
|
||||
import 'element-ui/lib/theme-chalk/index.css'
|
||||
|
||||
Vue.use(Element)
|
||||
Vue.use(Link);
|
||||
Vue.use(Image);
|
||||
Vue.use(Button);
|
||||
Vue.use(Table);
|
||||
Vue.use(TableColumn);
|
||||
Vue.use(Main);
|
||||
Vue.use(Footer);
|
||||
Vue.use(Container);
|
||||
Vue.use(Icon);
|
||||
Vue.use(Row);
|
||||
Vue.use(Col);
|
||||
Vue.use(Upload);
|
||||
Vue.prototype.$notify = Notification;
|
||||
|
||||
|
||||
|
@ -0,0 +1,165 @@
|
||||
const CryptoJS = require("crypto-js");
|
||||
const CORE_KEY = CryptoJS.enc.Hex.parse("687a4852416d736f356b496e62617857");
|
||||
const META_KEY = CryptoJS.enc.Hex.parse("2331346C6A6B5F215C5D2630553C2728");
|
||||
|
||||
const audio_mime_type = {
|
||||
mp3: "audio/mpeg",
|
||||
flac: "audio/flac"
|
||||
};
|
||||
|
||||
|
||||
export {Decrypt};
|
||||
|
||||
async function Decrypt(file) {
|
||||
|
||||
const fileBuffer = await new Promise(reslove => {
|
||||
const reader = new FileReader();
|
||||
reader.onload = (e) => {
|
||||
reslove(e.target.result);
|
||||
};
|
||||
reader.readAsArrayBuffer(file);
|
||||
});
|
||||
|
||||
const dataView = new DataView(fileBuffer);
|
||||
|
||||
if (dataView.getUint32(0, true) !== 0x4e455443 ||
|
||||
dataView.getUint32(4, true) !== 0x4d414446
|
||||
) {
|
||||
console.log({type: "error", data: "not ncm file"});
|
||||
return;
|
||||
}
|
||||
|
||||
let offset = 10;
|
||||
|
||||
const keyData = (() => {
|
||||
const keyLen = dataView.getUint32(offset, true);
|
||||
offset += 4;
|
||||
const cipherText = new Uint8Array(fileBuffer, offset, keyLen).map(
|
||||
uint8 => uint8 ^ 0x64
|
||||
);
|
||||
offset += keyLen;
|
||||
|
||||
const plainText = CryptoJS.AES.decrypt(
|
||||
{ciphertext: CryptoJS.lib.WordArray.create(cipherText)},
|
||||
CORE_KEY,
|
||||
{
|
||||
mode: CryptoJS.mode.ECB,
|
||||
padding: CryptoJS.pad.Pkcs7
|
||||
}
|
||||
);
|
||||
|
||||
const result = new Uint8Array(plainText.sigBytes);
|
||||
|
||||
{
|
||||
const words = plainText.words;
|
||||
const sigBytes = plainText.sigBytes;
|
||||
for (let i = 0; i < sigBytes; i++) {
|
||||
result[i] = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
|
||||
}
|
||||
}
|
||||
|
||||
return result.slice(17);
|
||||
})();
|
||||
|
||||
const keyBox = (() => {
|
||||
const box = new Uint8Array(Array(256).keys());
|
||||
|
||||
const keyDataLen = keyData.length;
|
||||
|
||||
let j = 0;
|
||||
|
||||
for (let i = 0; i < 256; i++) {
|
||||
j = (box[i] + j + keyData[i % keyDataLen]) & 0xff;
|
||||
[box[i], box[j]] = [box[j], box[i]];
|
||||
}
|
||||
|
||||
return box.map((_, i, arr) => {
|
||||
i = (i + 1) & 0xff;
|
||||
const si = arr[i];
|
||||
const sj = arr[(i + si) & 0xff];
|
||||
return arr[(si + sj) & 0xff];
|
||||
});
|
||||
})();
|
||||
|
||||
/**
|
||||
* @typedef {Object} MusicMetaType
|
||||
* @property {Number} musicId
|
||||
* @property {String} musicName
|
||||
* @property {[[String, Number]]} artist
|
||||
* @property {String} album
|
||||
* @property {"flac"|"mp3"} format
|
||||
* @property {String} albumPic
|
||||
*/
|
||||
|
||||
/** @type {MusicMetaType|undefined} */
|
||||
const musicMeta = (() => {
|
||||
const metaDataLen = dataView.getUint32(offset, true);
|
||||
offset += 4;
|
||||
if (metaDataLen === 0) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const cipherText = new Uint8Array(fileBuffer, offset, metaDataLen).map(
|
||||
data => data ^ 0x63
|
||||
);
|
||||
offset += metaDataLen;
|
||||
|
||||
const plainText = CryptoJS.AES.decrypt(
|
||||
{
|
||||
ciphertext: CryptoJS.enc.Base64.parse(
|
||||
CryptoJS.lib.WordArray.create(cipherText.slice(22)).toString(CryptoJS.enc.Utf8)
|
||||
)
|
||||
},
|
||||
META_KEY,
|
||||
{mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7}
|
||||
);
|
||||
|
||||
const result = JSON.parse(plainText.toString(CryptoJS.enc.Utf8).slice(6));
|
||||
result.albumPic = result.albumPic.replace("http:", "https:");
|
||||
return result;
|
||||
})();
|
||||
|
||||
offset += dataView.getUint32(offset + 5, true) + 13;
|
||||
|
||||
const audioData = new Uint8Array(fileBuffer, offset);
|
||||
const audioDataLen = audioData.length;
|
||||
|
||||
|
||||
for (let cur = 0; cur < audioDataLen; ++cur) {
|
||||
audioData[cur] ^= keyBox[cur & 0xff];
|
||||
}
|
||||
|
||||
|
||||
if (musicMeta.format === undefined) {
|
||||
musicMeta.format = (() => {
|
||||
const [f, L, a, C] = audioData;
|
||||
if (f === 0x66 && L === 0x4c && a === 0x61 && C === 0x43) {
|
||||
return "flac";
|
||||
}
|
||||
return "mp3";
|
||||
})();
|
||||
}
|
||||
const mime = audio_mime_type[musicMeta.format];
|
||||
const musicData = new Blob([audioData], {
|
||||
type: mime
|
||||
});
|
||||
|
||||
const musicUrl = URL.createObjectURL(musicData);
|
||||
|
||||
const artists = [];
|
||||
musicMeta.artist.forEach(arr => {
|
||||
artists.push(arr[0]);
|
||||
});
|
||||
const filename = artists.join(" & ") + " - " + musicMeta.musicName + "." + musicMeta.format;
|
||||
return {
|
||||
meta: musicMeta,
|
||||
file: musicUrl,
|
||||
picture: musicMeta.albumPic,
|
||||
title: musicMeta.musicName,
|
||||
album: musicMeta.album,
|
||||
artist: artists.join(" & "),
|
||||
filename: filename,
|
||||
mime: mime
|
||||
};
|
||||
}
|
||||
|
@ -0,0 +1,125 @@
|
||||
const jsmediatags = require("jsmediatags");
|
||||
export {Decrypt}
|
||||
const SEED_MAP = [
|
||||
[0x4a, 0xd6, 0xca, 0x90, 0x67, 0xf7, 0x52],
|
||||
[0x5e, 0x95, 0x23, 0x9f, 0x13, 0x11, 0x7e],
|
||||
[0x47, 0x74, 0x3d, 0x90, 0xaa, 0x3f, 0x51],
|
||||
[0xc6, 0x09, 0xd5, 0x9f, 0xfa, 0x66, 0xf9],
|
||||
[0xf3, 0xd6, 0xa1, 0x90, 0xa0, 0xf7, 0xf0],
|
||||
[0x1d, 0x95, 0xde, 0x9f, 0x84, 0x11, 0xf4],
|
||||
[0x0e, 0x74, 0xbb, 0x90, 0xbc, 0x3f, 0x92],
|
||||
[0x00, 0x09, 0x5b, 0x9f, 0x62, 0x66, 0xa1]];
|
||||
const audio_mime_type = {
|
||||
mp3: "audio/mpeg",
|
||||
flac: "audio/flac"
|
||||
};
|
||||
|
||||
async function Decrypt(file) {
|
||||
// 获取扩展名
|
||||
let filename_ext = file.name.substring(file.name.lastIndexOf(".") + 1, file.name.length).toLowerCase();
|
||||
let new_ext;
|
||||
switch (filename_ext) {
|
||||
case "qmc0":
|
||||
case "qmc3":
|
||||
new_ext = "mp3";
|
||||
break;
|
||||
case "qmcflac":
|
||||
new_ext = "flac";
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
const mime = audio_mime_type[new_ext];
|
||||
// 读取文件
|
||||
const fileBuffer = await new Promise(reslove => {
|
||||
const reader = new FileReader();
|
||||
reader.onload = (e) => {
|
||||
reslove(e.target.result);
|
||||
};
|
||||
reader.readAsArrayBuffer(file);
|
||||
});
|
||||
const audioData = new Uint8Array(fileBuffer);
|
||||
const audioDataLen = audioData.length;
|
||||
// 转换数据
|
||||
const seed = new Mask();
|
||||
for (let cur = 0; cur < audioDataLen; ++cur) {
|
||||
audioData[cur] ^= seed.NextMask();
|
||||
}
|
||||
// 导出
|
||||
const musicData = new Blob([audioData], {
|
||||
type: mime
|
||||
});
|
||||
const musicUrl = URL.createObjectURL(musicData);
|
||||
// 读取Meta
|
||||
let tag = await new Promise(resolve => {
|
||||
new jsmediatags.Reader(musicData).read({
|
||||
onSuccess: resolve,
|
||||
onError: (err) => {
|
||||
console.log(err);
|
||||
resolve({tags: {}})
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 处理无标题歌手
|
||||
let filename_array = file.name.substring(0, file.name.lastIndexOf(".")).split("-");
|
||||
let title = tag.tags.title;
|
||||
let artist = tag.tags.artist;
|
||||
if (filename_array.length > 1) {
|
||||
if (artist === undefined) artist = filename_array[0].trim();
|
||||
if (title === undefined) title = filename_array[1].trim();
|
||||
} else if (filename_array.length === 1) {
|
||||
if (title === undefined) title = filename_array[0].trim();
|
||||
}
|
||||
const filename = artist + " - " + title + "." + new_ext;
|
||||
// 处理无封面
|
||||
let pic_url = "";
|
||||
if (tag.tags.picture !== undefined) {
|
||||
let pic = new Blob([new Uint8Array(tag.tags.picture.data)], {type: tag.tags.picture.format});
|
||||
pic_url = URL.createObjectURL(pic);
|
||||
}
|
||||
// 返回
|
||||
return {
|
||||
filename: filename,
|
||||
title: title,
|
||||
artist: artist,
|
||||
album: tag.tags.album,
|
||||
file: musicUrl,
|
||||
picture: pic_url,
|
||||
mime: mime
|
||||
}
|
||||
}
|
||||
|
||||
class Mask {
|
||||
constructor() {
|
||||
this.x = -1;
|
||||
this.y = 8;
|
||||
this.dx = 1;
|
||||
this.index = -1;
|
||||
}
|
||||
|
||||
NextMask() {
|
||||
let ret;
|
||||
this.index++;
|
||||
if (this.x < 0) {
|
||||
this.dx = 1;
|
||||
this.y = (8 - this.y) % 8;
|
||||
ret = 0xc3
|
||||
} else if (this.x > 6) {
|
||||
this.dx = -1;
|
||||
this.y = 7 - this.y;
|
||||
ret = 0xd8
|
||||
} else {
|
||||
ret = SEED_MAP[this.y][this.x]
|
||||
}
|
||||
this.x += this.dx;
|
||||
if (this.index === 0x8000 || (this.index > 0x8000 && (this.index + 1) % 0x8000 === 0)) {
|
||||
return this.NextMask()
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,51 @@
|
||||
const jsmediatags = require("jsmediatags");
|
||||
export {Decrypt}
|
||||
|
||||
const audio_mime_type = {
|
||||
mp3: "audio/mpeg",
|
||||
flac: "audio/flac"
|
||||
};
|
||||
|
||||
async function Decrypt(file) {
|
||||
let tag = await new Promise(resolve => {
|
||||
new jsmediatags.Reader(file).read({
|
||||
onSuccess: resolve,
|
||||
onError: () => {
|
||||
resolve({tags: {}})
|
||||
}
|
||||
});
|
||||
});
|
||||
let pic_url = "";
|
||||
if (tag.tags.picture !== undefined) {
|
||||
let pic = new Blob([new Uint8Array(tag.tags.picture.data)], {type: tag.tags.picture.format});
|
||||
pic_url = URL.createObjectURL(pic);
|
||||
}
|
||||
|
||||
let file_url = URL.createObjectURL(file);
|
||||
|
||||
|
||||
let filename_no_ext = file.name.substring(0, file.name.lastIndexOf("."));
|
||||
let filename_array = filename_no_ext.split("-");
|
||||
let filename_ext = file.name.substring(file.name.lastIndexOf(".") + 1, file.name.length).toLowerCase();
|
||||
const mime = audio_mime_type[filename_ext];
|
||||
let title = tag.tags.title;
|
||||
let artist = tag.tags.artist;
|
||||
|
||||
if (filename_array.length > 1) {
|
||||
if (artist === undefined) artist = filename_array[0].trim();
|
||||
if (title === undefined) title = filename_array[1].trim();
|
||||
} else if (filename_array.length === 1) {
|
||||
if (title === undefined) title = filename_array[0].trim();
|
||||
}
|
||||
|
||||
const filename = artist + " - " + title + "." + filename_ext;
|
||||
return {
|
||||
filename: filename,
|
||||
title: title,
|
||||
artist: artist,
|
||||
album: tag.tags.album,
|
||||
picture: pic_url,
|
||||
file: file_url,
|
||||
mime: mime
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
module.exports = {
|
||||
publicPath: '/music/',
|
||||
productionSourceMap: false
|
||||
};
|
Loading…
Reference in New Issue