Optimize Import

remotes/origin/HEAD
MengYX 5 years ago
parent 41a45176be
commit 10f09958c4
No known key found for this signature in database
GPG Key ID: E63F9C7303E8F604

@ -10,6 +10,7 @@
</el-image>
</template>
</el-table-column>
<!--todo: Check sortable-->
<el-table-column label="歌曲" sortable>
<template slot-scope="scope">
<span style="margin-left: 10px">{{ scope.row.title }}</span>

@ -27,10 +27,10 @@
},
mounted() {
if (document.location.host !== "" && process.env.NODE_ENV === 'production') {
//todo: Fail on Hot Reload
const worker = require("workerize-loader!../decrypt/common");
this.thread_num = navigator.hardwareConcurrency || 1;
for (let i = 0; i < this.thread_num; i++) {
//todo: Optimize for first loading
// noinspection JSValidateTypes,JSUnresolvedVariable
this.workers.push(worker().CommonDecrypt);
this.idle_workers.push(i);

@ -1,15 +1,12 @@
const CryptoJS = require("crypto-js");
const ID3Writer = require("browser-id3-writer");
const util = require("./util");
const CORE_KEY = CryptoJS.enc.Hex.parse("687a4852416d736f356b496e62617857");
const META_KEY = CryptoJS.enc.Hex.parse("2331346C6A6B5F215C5D2630553C2728");
import {AudioMimeType, GetArrayBuffer} from "./util"
export async function Decrypt(file) {
export {Decrypt};
async function Decrypt(file) {
const fileBuffer = await util.GetArrayBuffer(file);
const fileBuffer = await GetArrayBuffer(file);
const dataView = new DataView(fileBuffer);
if (dataView.getUint32(0, true) !== 0x4e455443 ||
@ -38,7 +35,7 @@ async function Decrypt(file) {
musicMeta.format = "mp3";
}
}
const mime = util.AudioMimeType[musicMeta.format];
const mime = AudioMimeType[musicMeta.format];
const artists = [];
musicMeta.artist.forEach(arr => {

@ -1,18 +1,18 @@
import {AudioMimeType, GetArrayBuffer, GetCoverURL, GetFileInfo} from "./util";
import * as mask from "./qmcMask"
import {QmcMaskCreate58, QmcMaskGetDefault, QmcMaskDetectMgg, QmcMaskDetectMflac} from "./qmcMask";
const musicMetadata = require("music-metadata-browser");
const HandlerMap = {
"mgg": {handler: mask.QmcMaskDetectMgg, ext: "ogg", detect: true},
"mflac": {handler: mask.QmcMaskDetectMflac, ext: "flac", detect: true},
"qmc0": {handler: mask.QmcMaskGetDefault, ext: "mp3", detect: false},
"qmc3": {handler: mask.QmcMaskGetDefault, ext: "mp3", detect: false},
"qmcogg": {handler: mask.QmcMaskGetDefault, ext: "ogg", detect: false},
"qmcflac": {handler: mask.QmcMaskGetDefault, ext: "flac", detect: false},
"bkcmp3": {handler: mask.QmcMaskGetDefault, ext: "mp3", detect: false},
"bkcflac": {handler: mask.QmcMaskGetDefault, ext: "flac", detect: false},
"tkm": {handler: mask.QmcMaskGetDefault, ext: "m4a", detect: false}
"mgg": {handler: QmcMaskDetectMgg, ext: "ogg", detect: true},
"mflac": {handler: QmcMaskDetectMflac, ext: "flac", detect: true},
"qmc0": {handler: QmcMaskGetDefault, ext: "mp3", detect: false},
"qmc3": {handler: QmcMaskGetDefault, ext: "mp3", detect: false},
"qmcogg": {handler: QmcMaskGetDefault, ext: "ogg", detect: false},
"qmcflac": {handler: QmcMaskGetDefault, ext: "flac", detect: false},
"bkcmp3": {handler: QmcMaskGetDefault, ext: "mp3", detect: false},
"bkcflac": {handler: QmcMaskGetDefault, ext: "flac", detect: false},
"tkm": {handler: QmcMaskGetDefault, ext: "m4a", detect: false}
};
//todo: use header to detect media type
@ -72,7 +72,7 @@ async function queryKeyInfo(keyData, filename, format) {
body: JSON.stringify({Format: format, Key: Array.from(keyData), Filename: filename}),
});
let data = await resp.json();
return mask.QmcMaskCreate58(data.Matrix58, data.Super58A, data.Super58B);
return QmcMaskCreate58(data.Matrix58, data.Super58A, data.Super58B);
} catch (e) {
}
}

@ -1,19 +1,17 @@
const musicMetadata = require("music-metadata-browser");
const util = require("./util");
export {Decrypt}
import {GetCoverURL, GetFileInfo, AudioMimeType} from "./util";
async function Decrypt(file, raw_filename, raw_ext) {
export async function Decrypt(file, raw_filename, raw_ext) {
const tag = await musicMetadata.parseBlob(file);
const info = util.GetFileInfo(tag.common.artist, tag.common.title, raw_filename);
const info = GetFileInfo(tag.common.artist, tag.common.title, raw_filename);
return {
status: true,
title: info.title,
artist: info.artist,
ext: raw_ext,
album: tag.common.album,
picture: util.GetCoverURL(tag),
picture: GetCoverURL(tag),
file: URL.createObjectURL(file),
mime: util.AudioMimeType[raw_ext]
mime: AudioMimeType[raw_ext]
}
}

@ -1,14 +1,14 @@
const rawDecrypt = require("./raw");
const util = require("./util");
export {Decrypt}
const header = [0x00, 0x00, 0x00, 0x20, 0x66, 0x74, 0x79, 0x70];
import {Decrypt as RawDecrypt} from "./raw";
import {GetArrayBuffer} from "./util";
async function Decrypt(file, raw_filename) {
const fileBuffer = await util.GetArrayBuffer(file);
const TM_HEADER = [0x00, 0x00, 0x00, 0x20, 0x66, 0x74, 0x79, 0x70];
export async function Decrypt(file, raw_filename) {
const fileBuffer = await GetArrayBuffer(file);
const audioData = new Uint8Array(fileBuffer);
for (let cur = 0; cur < 8; ++cur) {
audioData[cur] = header[cur];
audioData[cur] = TM_HEADER[cur];
}
const musicData = new Blob([audioData], {type: "audio/mp4"});
return await rawDecrypt.Decrypt(musicData, raw_filename, "m4a")
return await RawDecrypt(musicData, raw_filename, "m4a")
}

@ -1,10 +1,10 @@
export const FLAC_HEADER = [0x66, 0x4C, 0x61, 0x43, 0x00];
export const AudioMimeType = {
mp3: "audio/mpeg",
flac: "audio/flac",
m4a: "audio/mp4",
ogg: "audio/ogg"
};
export const FLAC_HEADER = [0x66, 0x4C, 0x61, 0x43, 0x00];
// Also a new draft API: blob.arrayBuffer()
export async function GetArrayBuffer(blobObject) {

@ -2,21 +2,9 @@ import Vue from 'vue'
import App from './App.vue'
import './registerServiceWorker'
import {
Button,
Col,
Container,
Footer,
Icon,
Image,
Link,
Main,
Button, Col, Container, Footer, Icon, Image, Link, Main,
Row, Table, TableColumn, Upload, Radio, Checkbox,
Notification,
Row,
Table,
TableColumn,
Upload,
Radio,
Checkbox
} from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css'
@ -36,7 +24,6 @@ Vue.use(Checkbox);
Vue.use(Radio);
Vue.prototype.$notify = Notification;
// only if your build system can import css, otherwise import it wherever you would import your css.
Vue.config.productionTip = false;
new Vue({

Loading…
Cancel
Save