Browse Source

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-folder
20230320
MengYX 5 years ago
parent
commit
53d4b5efe5
  1. 55
      package-lock.json
  2. 4
      package.json
  3. 70
      public/index.html
  4. 5
      public/manifest.json
  5. 2
      public/robots.txt
  6. 229
      src/App.vue
  7. 58
      src/components/HelloWorld.vue
  8. 5
      src/main.js
  9. 32
      src/plugins/element.js
  10. 165
      src/plugins/ncm.js
  11. 125
      src/plugins/qmc.js
  12. 51
      src/plugins/raw.js
  13. 4
      vue.config.js

55
package-lock.json

@ -1881,6 +1881,38 @@
"pify": "^4.0.1" "pify": "^4.0.1"
} }
}, },
"babel-plugin-component": {
"version": "1.1.1",
"resolved": "https://registry.npm.taobao.org/babel-plugin-component/download/babel-plugin-component-1.1.1.tgz",
"integrity": "sha1-mwI6I/9cmq4P1WxaGLnKuMTUXuo=",
"dev": true,
"requires": {
"@babel/helper-module-imports": "7.0.0-beta.35"
},
"dependencies": {
"@babel/helper-module-imports": {
"version": "7.0.0-beta.35",
"resolved": "https://registry.npm.taobao.org/@babel/helper-module-imports/download/@babel/helper-module-imports-7.0.0-beta.35.tgz",
"integrity": "sha1-MI41DnMXUs200PBY3x1wSSXGTgo=",
"dev": true,
"requires": {
"@babel/types": "7.0.0-beta.35",
"lodash": "^4.2.0"
}
},
"@babel/types": {
"version": "7.0.0-beta.35",
"resolved": "https://registry.npm.taobao.org/@babel/types/download/@babel/types-7.0.0-beta.35.tgz",
"integrity": "sha1-z5M6mpo4SEynJLM1uI2Dcm1auWA=",
"dev": true,
"requires": {
"esutils": "^2.0.2",
"lodash": "^4.2.0",
"to-fast-properties": "^2.0.0"
}
}
}
},
"babel-plugin-dynamic-import-node": { "babel-plugin-dynamic-import-node": {
"version": "2.3.0", "version": "2.3.0",
"resolved": "https://registry.npm.taobao.org/babel-plugin-dynamic-import-node/download/babel-plugin-dynamic-import-node-2.3.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fbabel-plugin-dynamic-import-node%2Fdownload%2Fbabel-plugin-dynamic-import-node-2.3.0.tgz", "resolved": "https://registry.npm.taobao.org/babel-plugin-dynamic-import-node/download/babel-plugin-dynamic-import-node-2.3.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fbabel-plugin-dynamic-import-node%2Fdownload%2Fbabel-plugin-dynamic-import-node-2.3.0.tgz",
@ -2173,6 +2205,11 @@
"integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=", "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=",
"dev": true "dev": true
}, },
"browser-id3-writer": {
"version": "4.1.0",
"resolved": "https://registry.npm.taobao.org/browser-id3-writer/download/browser-id3-writer-4.1.0.tgz",
"integrity": "sha1-pL+ye82dpgHoqgPAvuJvovVuf0c="
},
"browserify-aes": { "browserify-aes": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "https://registry.npm.taobao.org/browserify-aes/download/browserify-aes-1.2.0.tgz", "resolved": "https://registry.npm.taobao.org/browserify-aes/download/browserify-aes-1.2.0.tgz",
@ -3092,6 +3129,11 @@
"randomfill": "^1.0.3" "randomfill": "^1.0.3"
} }
}, },
"crypto-js": {
"version": "3.1.9-1",
"resolved": "https://registry.npm.taobao.org/crypto-js/download/crypto-js-3.1.9-1.tgz",
"integrity": "sha1-/aGedh/Ad+Af+/3G6f38WeiAbNg="
},
"css-color-names": { "css-color-names": {
"version": "0.0.4", "version": "0.0.4",
"resolved": "https://registry.npm.taobao.org/css-color-names/download/css-color-names-0.0.4.tgz", "resolved": "https://registry.npm.taobao.org/css-color-names/download/css-color-names-0.0.4.tgz",
@ -6046,6 +6088,14 @@
"integrity": "sha1-gFZNLkg9rPbo7yCWUKZ98/DCg6Q=", "integrity": "sha1-gFZNLkg9rPbo7yCWUKZ98/DCg6Q=",
"dev": true "dev": true
}, },
"jsmediatags": {
"version": "3.9.1",
"resolved": "https://registry.npm.taobao.org/jsmediatags/download/jsmediatags-3.9.1.tgz",
"integrity": "sha1-yPFsVd2Es0HbQvcNSbEMVTFM8X0=",
"requires": {
"xhr2": "^0.1.4"
}
},
"json-parse-better-errors": { "json-parse-better-errors": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npm.taobao.org/json-parse-better-errors/download/json-parse-better-errors-1.0.2.tgz", "resolved": "https://registry.npm.taobao.org/json-parse-better-errors/download/json-parse-better-errors-1.0.2.tgz",
@ -10617,6 +10667,11 @@
"async-limiter": "~1.0.0" "async-limiter": "~1.0.0"
} }
}, },
"xhr2": {
"version": "0.1.4",
"resolved": "https://registry.npm.taobao.org/xhr2/download/xhr2-0.1.4.tgz",
"integrity": "sha1-f4dliEdxbbUCYyOBL4GMras4el8="
},
"xtend": { "xtend": {
"version": "4.0.1", "version": "4.0.1",
"resolved": "http://registry.npm.taobao.org/xtend/download/xtend-4.0.1.tgz", "resolved": "http://registry.npm.taobao.org/xtend/download/xtend-4.0.1.tgz",

4
package.json

@ -7,8 +7,11 @@
"build": "vue-cli-service build" "build": "vue-cli-service build"
}, },
"dependencies": { "dependencies": {
"browser-id3-writer": "^4.1.0",
"core-js": "^2.6.5", "core-js": "^2.6.5",
"crypto-js": "^3.1.9-1",
"element-ui": "^2.4.5", "element-ui": "^2.4.5",
"jsmediatags": "^3.9.1",
"register-service-worker": "^1.6.2", "register-service-worker": "^1.6.2",
"vue": "^2.6.10" "vue": "^2.6.10"
}, },
@ -16,6 +19,7 @@
"@vue/cli-plugin-babel": "^3.9.0", "@vue/cli-plugin-babel": "^3.9.0",
"@vue/cli-plugin-pwa": "^3.9.0", "@vue/cli-plugin-pwa": "^3.9.0",
"@vue/cli-service": "^3.9.0", "@vue/cli-service": "^3.9.0",
"babel-plugin-component": "^1.1.1",
"vue-cli-plugin-element": "^1.0.1", "vue-cli-plugin-element": "^1.0.1",
"vue-template-compiler": "^2.6.10" "vue-template-compiler": "^2.6.10"
} }

70
public/index.html

@ -1,17 +1,69 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="zh-CN">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0"> <meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico"> <link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>music-crack</title> <title>音乐解锁 - By IXarea</title>
</head> <meta content="音乐,解锁,ncm,qmc,qmc0,qmc3,qmcflac,qq音乐,网易云音乐,加密" name="keywords"/>
<body> <meta content="音乐解锁 - 在任何设备上解锁已购的加密音乐!" name="description"/>
<style>
/* Center the loader */
#loader {
position: absolute;
left: 50%;
top: 50%;
z-index: 1010;
margin: -75px 0 0 -75px;
border: 16px solid #f3f3f3;
border-radius: 50%;
border-top: 16px solid #3498db;
width: 120px;
height: 120px;
animation: spin 2s linear infinite;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
#loader-mask {
position: absolute;
width: 100%;
height: 100%;
bottom: 0;
left: 0;
right: 0;
top: 0;
z-index: 1009;
background-color: rgba(242, 246, 252, 0.88);
}
</style>
</head>
<body>
<div id="loader-mask">
<div id="loader"></div>
<noscript> <noscript>
<strong>We're sorry but music-crack doesn't work properly without JavaScript enabled. Please enable it to continue.</strong> <strong>很抱歉,音乐解锁需要启用JavaScript的现代浏览器!如
<a href="https://www.google.cn/chrome/">Google Chrome</a>
<a href="https://www.firefox.com.cn/">Mozilla Firefox</a>
</strong>
</noscript> </noscript>
<div id="app"></div> <script>
<!-- built files will be auto injected --> window.onload = function () {
</body> document.getElementById("loader-mask").remove();
};
</script>
</div>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html> </html>

5
public/manifest.json

@ -1,6 +1,7 @@
{ {
"name": "music-crack", "name": "音乐解锁 - By IXarea",
"short_name": "music-crack", "short_name": "音乐解锁",
"description": "在任何设备上解锁已购的加密音乐!支持QQ音乐与网易云音乐!",
"icons": [ "icons": [
{ {
"src": "./img/icons/android-chrome-192x192.png", "src": "./img/icons/android-chrome-192x192.png",

2
public/robots.txt

@ -1,2 +0,0 @@
User-agent: *
Disallow:

229
src/App.vue

@ -1,36 +1,227 @@
<template> <template>
<div id="app"> <div id="app">
<img src="./assets/logo.png"> <el-container>
<div> <el-main>
<p> <el-upload
If Element is successfully added to this project, you'll see an :auto-upload="false"
<code v-text="'<el-button>'"></code> :on-change="handleFile"
below :show-file-list="false"
</p> action=""
<el-button>el-button</el-button> drag
</div> multiple>
<HelloWorld msg="Welcome to Your Vue.js App"/> <i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处<em>点击选择</em></div>
<div class="el-upload__tip" slot="tip">本工具仅在浏览器内对文件进行解锁无需消耗流量</div>
</el-upload>
<el-row id="app-control">
<el-button @click="handleDownloadAll" icon="el-icon-download" plain>下载全部</el-button>
<el-button @click="handleDeleteAll" icon="el-icon-download" plain type="danger">删除全部</el-button>
</el-row>
<audio :autoplay="playing_auto" :src="playing_url" controls></audio>
<el-table :data="tableData" style="width: 100%">
<el-table-column label="图片">
<template slot-scope="scope">
<el-image :src="scope.row.picture" style="width: 100px; height: 100px"></el-image>
</template>
</el-table-column>
<el-table-column label="歌曲" sortable>
<template slot-scope="scope">
<span style="margin-left: 10px">{{ scope.row.title }}</span>
</template>
</el-table-column>
<el-table-column label="歌手" sortable>
<template slot-scope="scope">
<p>{{ scope.row.artist }}</p>
</template>
</el-table-column>
<el-table-column label="专辑" sortable>
<template slot-scope="scope">
<p>{{ scope.row.album }}</p>
</template>
</el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<el-button @click="handlePlay(scope.$index, scope.row)"
circle icon="el-icon-video-play" type="success">
</el-button>
<el-button circle>
<el-link :download="scope.row.filename" :href="scope.row.file"
:underline="false" icon="el-icon-download">
</el-link>
</el-button>
<el-button @click="handleDelete(scope.$index, scope.row)"
circle icon="el-icon-delete" type="danger">
</el-button>
</template>
</el-table-column>
</el-table>
</el-main>
<el-footer id="app-footer">
<el-row>
音乐解锁移除已购音乐的加密保护
目前支持网易云音乐(ncm)和QQ音乐(qmc0, qmc3, qmcflac)
</el-row>
<el-row>
<span>Copyright &copy; 2019</span>
<a href="https://ixarea.com" target="_blank">IXarea</a>
<span>and</span>
<a href="https://github.com/ix64" target="_blank">MengYX</a>
</el-row>
</el-footer>
</el-container>
</div> </div>
</template> </template>
<script> <script>
import HelloWorld from './components/HelloWorld.vue'
export default { const NcmDecrypt = require("./plugins/ncm");
const QmcDecrypt = require("./plugins/qmc");
const RawDecrypt = require("./plugins/raw");
export default {
name: 'app', name: 'app',
components: { components: {},
HelloWorld data() {
return {
activeIndex: '1',
tableData: [],
playing_url: "",
playing_auto: false,
}
},
mounted() {
this.$nextTick(function () {
this.finishLoad();
});
},
methods: {
finishLoad() {
this.$notify.info({
title: '离线使用',
message: "音乐解锁加载成功。我们使用PWA技术,可以添加到桌面或收藏夹,无网络状况下也能使用。",
duration: 30000,
position: 'top-left'
});
},
handleFile(file) {
let ext = file.name.substring(file.name.lastIndexOf(".") + 1, file.name.length).toLowerCase();
(async () => {
let data = null;
switch (ext) {
case "ncm":
data = await NcmDecrypt.Decrypt(file.raw);
break;
case "mp3":
case "flac":
data = await RawDecrypt.Decrypt(file.raw);
break;
case "qmc3":
case "qmc0":
case "qmcflac":
data = await QmcDecrypt.Decrypt(file.raw);
break;
default:
break;
}
if (null != data) {
this.tableData.push(data);
this.$notify.success({
title: '解锁成功',
message: '成功解锁 ' + data.title
});
} else {
this.$notify.error({
title: '错误',
message: '不支持此文件类型'
});
}
})();
},
handlePlay(index, row) {
this.playing_url = row.file;
this.playing_auto = true;
},
handleDelete(index, row) {
console.log(index);
URL.revokeObjectURL(row.file);
URL.revokeObjectURL(row.picture);
this.tableData.splice(index, 1);
},
handleDeleteAll() {
this.tableData.forEach(value => {
URL.revokeObjectURL(value.file);
URL.revokeObjectURL(value.picture);
});
this.tableData = [];
},
handleDownloadAll() {
let index = 0;
let c = setInterval(() => {
if (index < this.tableData.length) {
let a = document.createElement('a');
a.href = this.tableData[index].file;
a.download = this.tableData[index].filename;
document.body.append(a);
a.click();
a.remove();
index++;
} else {
clearInterval(c);
} }
}
}, 1000);
}
}
}
</script> </script>
<style> <style>
#app { #app {
font-family: 'Avenir', Helvetica, Arial, sans-serif; font-family: "Helvetica Neue", Helvetica, "PingFang SC",
"Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
text-align: center; text-align: center;
color: #2c3e50; color: #2c3e50;
margin-top: 60px; padding-top: 30px;
} }
#app-footer a {
padding-left: 0.5em;
padding-right: 0.5em;
}
#app-footer {
text-align: center;
font-size: small;
}
.el-upload-dragger {
width: 80vw !important;
}
#app-control {
padding-top: 1em;
padding-bottom: 1em;
}
</style> </style>

58
src/components/HelloWorld.vue

@ -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>

5
src/main.js

@ -3,8 +3,9 @@ import App from './App.vue'
import './registerServiceWorker' import './registerServiceWorker'
import './plugins/element.js' import './plugins/element.js'
Vue.config.productionTip = false // only if your build system can import css, otherwise import it wherever you would import your css.
Vue.config.productionTip = false;
new Vue({ new Vue({
render: h => h(App), render: h => h(App),
}).$mount('#app') }).$mount('#app');

32
src/plugins/element.js

@ -1,5 +1,33 @@
import Vue from 'vue' 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' 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;

165
src/plugins/ncm.js

@ -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
};
}

125
src/plugins/qmc.js

@ -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
}
}

51
src/plugins/raw.js

@ -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
}
}

4
vue.config.js

@ -0,0 +1,4 @@
module.exports = {
publicPath: '/music/',
productionSourceMap: false
};
Loading…
Cancel
Save