Browse Source
Finish UI Add loading screen Change PWA Config Remove useless file Load Element-UI on Demand Fix deploy on sub-folder20230320
MengYX
5 years ago
13 changed files with 720 additions and 103 deletions
@ -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> |
||||
|
@ -1,2 +0,0 @@ |
|||||
User-agent: * |
|
||||
Disallow: |
|
@ -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 |
||||
|
multiple> |
||||
|
<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 © 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> |
||||
<HelloWorld msg="Welcome to Your Vue.js App"/> |
|
||||
</div> |
|
||||
</template> |
</template> |
||||
|
|
||||
<script> |
<script> |
||||
import HelloWorld from './components/HelloWorld.vue' |
|
||||
|
const NcmDecrypt = require("./plugins/ncm"); |
||||
export default { |
const QmcDecrypt = require("./plugins/qmc"); |
||||
name: 'app', |
const RawDecrypt = require("./plugins/raw"); |
||||
components: { |
export default { |
||||
HelloWorld |
name: 'app', |
||||
} |
components: {}, |
||||
} |
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", |
||||
-webkit-font-smoothing: antialiased; |
"Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif; |
||||
-moz-osx-font-smoothing: grayscale; |
-webkit-font-smoothing: antialiased; |
||||
text-align: center; |
-moz-osx-font-smoothing: grayscale; |
||||
color: #2c3e50; |
text-align: center; |
||||
margin-top: 60px; |
color: #2c3e50; |
||||
} |
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> |
||||
|
@ -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 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; |
||||
|
|
||||
|
|
||||
|
@ -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