Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
4e1bfb0b55 | ||
![]() |
27b74ea5dd | ||
![]() |
9aab7a7713 | ||
![]() |
dcde0d3fbb | ||
![]() |
0c0299d63a | ||
![]() |
3ee9f5d2d1 | ||
![]() |
e3ca175258 |
@@ -10,7 +10,7 @@ steps:
|
||||
- name: installDependencies
|
||||
image: node:lts
|
||||
commands:
|
||||
- npm ci
|
||||
- npm ci --verbose --registry=https://registry.npm.taobao.org
|
||||
|
||||
- name: build
|
||||
image: node:lts
|
||||
|
@@ -1,5 +1,11 @@
|
||||
module.exports = {
|
||||
presets: [
|
||||
'@vue/cli-plugin-babel/preset'
|
||||
]
|
||||
}
|
||||
presets: [
|
||||
'@vue/cli-plugin-babel/preset'
|
||||
],
|
||||
plugins: [
|
||||
["component", {
|
||||
"libraryName": "element-ui",
|
||||
"styleLibraryName": "theme-chalk"
|
||||
}]
|
||||
]
|
||||
};
|
||||
|
1186
package-lock.json
generated
1186
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "unlock-music",
|
||||
"version": "1.1.3",
|
||||
"version": "1.2.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"serve": "vue-cli-service serve",
|
||||
@@ -16,9 +16,9 @@
|
||||
"vue": "^2.6.11"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vue/cli-plugin-babel": "^4.1.2",
|
||||
"@vue/cli-plugin-pwa": "^4.1.2",
|
||||
"@vue/cli-service": "^4.1.2",
|
||||
"@vue/cli-plugin-babel": "^4.2.2",
|
||||
"@vue/cli-plugin-pwa": "^4.2.2",
|
||||
"@vue/cli-service": "^4.2.2",
|
||||
"babel-plugin-component": "^1.1.1",
|
||||
"vue-cli-plugin-element": "^1.0.1",
|
||||
"vue-template-compiler": "^2.6.11",
|
||||
|
294
src/App.vue
294
src/App.vue
@@ -1,150 +1,77 @@
|
||||
<template>
|
||||
<div id="app">
|
||||
<el-container>
|
||||
<el-main>
|
||||
<el-upload
|
||||
:auto-upload="false"
|
||||
:on-change="handleFile"
|
||||
:show-file-list="false"
|
||||
action=""
|
||||
drag
|
||||
multiple>
|
||||
<i class="el-icon-upload"/>
|
||||
<div class="el-upload__text">将文件拖到此处,或<em>点击选择</em></div>
|
||||
<div class="el-upload__tip" slot="tip">本工具仅在浏览器内对文件进行解锁,无需消耗流量</div>
|
||||
</el-upload>
|
||||
|
||||
<el-row id="app-control">
|
||||
|
||||
<el-row style="padding-bottom: 1em; font-size: 14px">
|
||||
歌曲命名格式:
|
||||
<el-radio name="format" v-model="format" label="1">歌曲名</el-radio>
|
||||
<el-radio name="format" v-model="format" label="2">歌手-歌曲名</el-radio>
|
||||
<el-radio name="format" v-model="format" label="3">歌曲名-歌手</el-radio>
|
||||
<el-checkbox v-model="instantDownload" border>立即保存</el-checkbox>
|
||||
</el-row>
|
||||
|
||||
<el-button @click="handleDownloadAll" icon="el-icon-download" plain>下载全部</el-button>
|
||||
<el-button @click="handleDeleteAll" icon="el-icon-delete" plain type="danger">删除全部</el-button>
|
||||
<el-container id="app">
|
||||
<el-main>
|
||||
<x-upload v-on:handle_finish="showSuccess" v-on:handle_error="showFail"></x-upload>
|
||||
|
||||
<el-row id="app-control">
|
||||
<el-row style="padding-bottom: 1em; font-size: 14px">
|
||||
歌曲命名格式:
|
||||
<el-radio name="format" v-model="download_format" label="1">歌曲名</el-radio>
|
||||
<el-radio name="format" v-model="download_format" label="2">歌手-歌曲名</el-radio>
|
||||
<el-radio name="format" v-model="download_format" label="3">歌曲名-歌手</el-radio>
|
||||
<el-checkbox v-model="instant_download" border>立即保存</el-checkbox>
|
||||
</el-row>
|
||||
<audio :autoplay="playing_auto" :src="playing_url" controls/>
|
||||
<el-button @click="handleDownloadAll" icon="el-icon-download" plain>下载全部</el-button>
|
||||
<el-button @click="handleDeleteAll" icon="el-icon-delete" plain type="danger">删除全部</el-button>
|
||||
</el-row>
|
||||
<audio :autoplay="playing_auto" :src="playing_url" controls/>
|
||||
|
||||
<x-preview :table-data="tableData" :download_format="download_format"
|
||||
v-on:music_changed="changePlaying"></x-preview>
|
||||
|
||||
<el-table :data="tableData" style="width: 100%">
|
||||
</el-main>
|
||||
<el-footer id="app-footer">
|
||||
<el-row>
|
||||
音乐解锁:移除已购音乐的加密保护。
|
||||
目前支持网易云音乐(ncm)、QQ音乐(qmc, mflac, tkm)以及
|
||||
<a href="https://github.com/ix64/unlock-music/blob/master/README.md" target="_blank">其他格式</a>。
|
||||
<a href="https://github.com/ix64/unlock-music/wiki/使用提示" target="_blank">使用提示</a>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<span>Copyright © 2019</span>
|
||||
<a href="https://github.com/ix64" target="_blank">MengYX</a>
|
||||
音乐解锁使用
|
||||
<a href="https://github.com/ix64/unlock-music/blob/master/LICENSE" target="_blank">MIT许可协议</a>
|
||||
开放
|
||||
<a href="https://github.com/ix64/unlock-music" target="_blank">源代码</a>
|
||||
</el-row>
|
||||
</el-footer>
|
||||
</el-container>
|
||||
|
||||
<el-table-column label="封面">
|
||||
<template slot-scope="scope">
|
||||
<el-image :src="scope.row.picture" style="width: 100px; height: 100px">
|
||||
<div class="image-slot el-image__error" slot="error">
|
||||
暂无封面
|
||||
</div>
|
||||
</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 @click="handleDownload(scope.row)"
|
||||
circle icon="el-icon-download">
|
||||
</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音乐(qmc, mflac, tkm)以及
|
||||
<a href="https://github.com/ix64/unlock-music/blob/master/README.md" target="_blank">其他格式</a>。
|
||||
<a href="https://github.com/ix64/unlock-music/wiki/使用提示" target="_blank">使用提示</a>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<span>Copyright © 2019</span>
|
||||
<a href="https://github.com/ix64" target="_blank">MengYX</a>
|
||||
音乐解锁使用
|
||||
<a href="https://github.com/ix64/unlock-music/blob/master/LICENSE" target="_blank">MIT许可协议</a>
|
||||
开放
|
||||
<a href="https://github.com/ix64/unlock-music" target="_blank">源代码</a>
|
||||
</el-row>
|
||||
</el-footer>
|
||||
</el-container>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// 严格模式 用于尾调用优化
|
||||
"use strict";
|
||||
|
||||
const worker = require("workerize-loader!./decrypt/common");
|
||||
const dec = require('./decrypt/common');
|
||||
import upload from "./component/upload"
|
||||
import preview from "./component/preview"
|
||||
import {DownloadBlobMusic, RemoveBlobMusic} from "./component/util"
|
||||
|
||||
export default {
|
||||
name: 'app',
|
||||
components: {},
|
||||
components: {
|
||||
xUpload: upload,
|
||||
xPreview: preview
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
activeIndex: '1',
|
||||
tableData: [],
|
||||
playing_url: "",
|
||||
playing_auto: false,
|
||||
format: '2',
|
||||
instantDownload: false,
|
||||
workCount: 0,
|
||||
cacheQueue: [],
|
||||
cacheQueueOption: {
|
||||
push: (element) => {
|
||||
this.cacheQueue.push(element);
|
||||
},
|
||||
pop: () => {
|
||||
return this.cacheQueue.shift();
|
||||
},
|
||||
size: () => {
|
||||
return this.cacheQueue.length;
|
||||
}
|
||||
},
|
||||
workers: [],
|
||||
idle_workers: [],
|
||||
thread_num: 1
|
||||
download_format: '2',
|
||||
instant_download: false,
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
created() {
|
||||
this.$nextTick(function () {
|
||||
this.finishLoad();
|
||||
});
|
||||
if (document.location.host !== "") {
|
||||
this.thread_num = Math.max(navigator.hardwareConcurrency, 1);
|
||||
for (let i = 0; i < this.thread_num; i++) {
|
||||
this.workers.push(worker().CommonDecrypt);
|
||||
this.idle_workers.push(i);
|
||||
}
|
||||
} else {
|
||||
this.workers.push(dec.CommonDecrypt);
|
||||
this.idle_workers.push(0)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
finishLoad() {
|
||||
document.getElementById("loader-mask").remove();
|
||||
const mask = document.getElementById("loader-mask");
|
||||
if (!!mask) mask.remove();
|
||||
this.$notify.info({
|
||||
title: '离线使用',
|
||||
message: '我们使用PWA技术,无网络也能使用<br/>' +
|
||||
@@ -155,94 +82,47 @@
|
||||
position: 'top-left'
|
||||
});
|
||||
},
|
||||
handleFile(file) {
|
||||
// 有空闲worker 立刻处理文件
|
||||
if (this.idle_workers.length > 0) {
|
||||
this.handleDoFile(file, this.idle_workers.shift());
|
||||
}
|
||||
// 无空闲worker 则放入缓存队列
|
||||
else {
|
||||
this.cacheQueueOption.push(file);
|
||||
}
|
||||
},
|
||||
handleCacheQueue(worker_id) {
|
||||
// 调用方法消费缓存队列中的数据
|
||||
if (this.cacheQueue.length === 0) {
|
||||
this.idle_workers.push(worker_id);
|
||||
return
|
||||
}
|
||||
this.handleDoFile(this.cacheQueueOption.pop(), worker_id);
|
||||
},
|
||||
handleDoFile(file, worker_id) {
|
||||
this.workers[worker_id](file).then(data => {
|
||||
if (data.status) {
|
||||
if (this.instantDownload) {
|
||||
this.handleDownload(data);
|
||||
this.handleDelete(null, data);
|
||||
} else {
|
||||
this.tableData.push(data);
|
||||
this.$notify.success({
|
||||
title: '解锁成功',
|
||||
message: '成功解锁 ' + data.title,
|
||||
duration: 3000
|
||||
});
|
||||
}
|
||||
showSuccess(data) {
|
||||
if (data.status) {
|
||||
if (this.instant_download) {
|
||||
DownloadBlobMusic(data, this.download_format);
|
||||
RemoveBlobMusic(data);
|
||||
} else {
|
||||
this.tableData.push(data);
|
||||
this.$notify.success({
|
||||
title: '解锁成功',
|
||||
message: '成功解锁 ' + data.title,
|
||||
duration: 3000
|
||||
});
|
||||
}
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
let _rp_data = [data.title, data.artist, data.album];
|
||||
window._paq.push(["trackEvent", "Unlock", data.rawExt + "," + data.mime, JSON.stringify(_rp_data)]);
|
||||
} else {
|
||||
this.$notify.error({
|
||||
title: '出现问题',
|
||||
message: data.message + "," + file.name +
|
||||
',参考<a target="_blank" href="https://github.com/ix64/unlock-music/wiki/使用提示">使用提示</a>',
|
||||
dangerouslyUseHTMLString: true,
|
||||
duration: 6000
|
||||
});
|
||||
window._paq.push(["trackEvent", "Error", data.message, file.name]);
|
||||
}
|
||||
// 完成之后 执行新任务 todo: 可能导致call stack过长
|
||||
this.handleCacheQueue(worker_id);
|
||||
}).catch(err => {
|
||||
console.error(err, file);
|
||||
window._paq.push(["trackEvent", "Error", err, file.name]);
|
||||
this.handleCacheQueue(worker_id);
|
||||
})
|
||||
} else {
|
||||
this.showFail(data.message, data.rawFilename + "." + data.rawExt)
|
||||
}
|
||||
},
|
||||
handlePlay(index, row) {
|
||||
this.playing_url = row.file;
|
||||
showFail(errInfo, filename) {
|
||||
this.$notify.error({
|
||||
title: '出现问题',
|
||||
message: errInfo + "," + filename +
|
||||
',参考<a target="_blank" href="https://github.com/ix64/unlock-music/wiki/使用提示">使用提示</a>',
|
||||
dangerouslyUseHTMLString: true,
|
||||
duration: 6000
|
||||
});
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
window._paq.push(["trackEvent", "Error", errInfo, filename]);
|
||||
console.error(errInfo, filename);
|
||||
}
|
||||
},
|
||||
changePlaying(url) {
|
||||
this.playing_url = url;
|
||||
this.playing_auto = true;
|
||||
},
|
||||
handleDelete(index, row) {
|
||||
URL.revokeObjectURL(row.file);
|
||||
URL.revokeObjectURL(row.picture);
|
||||
if (index != null) {
|
||||
this.tableData.splice(index, 1);
|
||||
}
|
||||
},
|
||||
handleDownload(row) {
|
||||
let a = document.createElement('a');
|
||||
a.href = row.file;
|
||||
switch (this.format) {
|
||||
case "1":
|
||||
a.download = row.title + "." + row.ext;
|
||||
break;
|
||||
case "2":
|
||||
a.download = row.artist + " - " + row.title + "." + row.ext;
|
||||
break;
|
||||
case "3":
|
||||
a.download = row.title + " - " + row.artist + "." + row.ext;
|
||||
break;
|
||||
default:
|
||||
a.download = row.filename;
|
||||
break;
|
||||
}
|
||||
document.body.append(a);
|
||||
a.click();
|
||||
a.remove();
|
||||
},
|
||||
handleDeleteAll() {
|
||||
this.tableData.forEach(value => {
|
||||
URL.revokeObjectURL(value.file);
|
||||
URL.revokeObjectURL(value.picture);
|
||||
RemoveBlobMusic(value);
|
||||
});
|
||||
this.tableData = [];
|
||||
},
|
||||
@@ -250,15 +130,15 @@
|
||||
let index = 0;
|
||||
let c = setInterval(() => {
|
||||
if (index < this.tableData.length) {
|
||||
this.handleDownload(this.tableData[index]);
|
||||
DownloadBlobMusic(this.tableData[index], this.download_format);
|
||||
index++;
|
||||
} else {
|
||||
clearInterval(c);
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
}, 300);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
@@ -284,15 +164,9 @@
|
||||
font-size: small;
|
||||
}
|
||||
|
||||
/*noinspection CssUnusedSymbol*/
|
||||
.el-upload-dragger {
|
||||
width: 80vw !important;
|
||||
}
|
||||
|
||||
#app-control {
|
||||
padding-top: 1em;
|
||||
padding-bottom: 1em;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
|
71
src/component/preview.vue
Normal file
71
src/component/preview.vue
Normal file
@@ -0,0 +1,71 @@
|
||||
<template>
|
||||
<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">
|
||||
<div class="image-slot el-image__error" slot="error">
|
||||
暂无封面
|
||||
</div>
|
||||
</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 @click="handleDownload(scope.row)"
|
||||
circle icon="el-icon-download">
|
||||
</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>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {DownloadBlobMusic, RemoveBlobMusic} from './util'
|
||||
|
||||
export default {
|
||||
name: "preview",
|
||||
props: {
|
||||
tableData: {type: Array, required: true},
|
||||
download_format: {type: String, required: true}
|
||||
},
|
||||
|
||||
methods: {
|
||||
handlePlay(index, row) {
|
||||
this.$emit("music_changed", row.file);
|
||||
},
|
||||
handleDelete(index, row) {
|
||||
RemoveBlobMusic(row);
|
||||
this.tableData.splice(index, 1);
|
||||
},
|
||||
handleDownload(row) {
|
||||
DownloadBlobMusic(row, this.download_format)
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
82
src/component/upload.vue
Normal file
82
src/component/upload.vue
Normal file
@@ -0,0 +1,82 @@
|
||||
<template>
|
||||
<el-upload
|
||||
:auto-upload="false"
|
||||
:on-change="handleFile"
|
||||
:show-file-list="false"
|
||||
action=""
|
||||
drag
|
||||
multiple>
|
||||
<i class="el-icon-upload"/>
|
||||
<div class="el-upload__text">将文件拖到此处,或<em>点击选择</em></div>
|
||||
<div class="el-upload__tip" slot="tip">本工具仅在浏览器内对文件进行解锁,无需消耗流量</div>
|
||||
</el-upload>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
"use strict";// 严格模式 用于尾调用优化
|
||||
|
||||
export default {
|
||||
name: "upload",
|
||||
data() {
|
||||
return {
|
||||
cacheQueue: [],
|
||||
workers: [],
|
||||
idle_workers: [],
|
||||
thread_num: 1
|
||||
}
|
||||
},
|
||||
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++) {
|
||||
// noinspection JSValidateTypes,JSUnresolvedVariable
|
||||
this.workers.push(worker().CommonDecrypt);
|
||||
this.idle_workers.push(i);
|
||||
}
|
||||
} else {
|
||||
const dec = require('../decrypt/common');
|
||||
this.workers.push(dec.CommonDecrypt);
|
||||
this.idle_workers.push(0)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleFile(file) {
|
||||
// 有空闲worker 立刻处理文件
|
||||
if (this.idle_workers.length > 0) {
|
||||
this.handleDoFile(file, this.idle_workers.shift());
|
||||
}
|
||||
// 无空闲worker 则放入缓存队列
|
||||
else {
|
||||
this.cacheQueue.push(file);
|
||||
}
|
||||
},
|
||||
handleCacheQueue(worker_id) {
|
||||
// 调用方法消费缓存队列中的数据
|
||||
if (this.cacheQueue.length === 0) {
|
||||
this.idle_workers.push(worker_id);
|
||||
return
|
||||
}
|
||||
this.handleDoFile(this.cacheQueue.shift(), worker_id);
|
||||
},
|
||||
handleDoFile(file, worker_id) {
|
||||
this.workers[worker_id](file).then(data => {
|
||||
this.$emit("handle_finish", data);
|
||||
// 完成之后 执行新任务 todo: 可能导致call stack过长
|
||||
this.handleCacheQueue(worker_id);
|
||||
}).catch(err => {
|
||||
this.$emit("handle_error", err, file.name);
|
||||
this.handleCacheQueue(worker_id);
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/*noinspection CssUnusedSymbol*/
|
||||
.el-upload-dragger {
|
||||
width: 80vw !important;
|
||||
}
|
||||
</style>
|
24
src/component/util.js
Normal file
24
src/component/util.js
Normal file
@@ -0,0 +1,24 @@
|
||||
export function DownloadBlobMusic(data, format) {
|
||||
const a = document.createElement('a');
|
||||
a.href = data.file;
|
||||
switch (format) {
|
||||
case "1":
|
||||
a.download = data.title + "." + data.ext;
|
||||
break;
|
||||
default:
|
||||
case "2":
|
||||
a.download = data.artist + " - " + data.title + "." + data.ext;
|
||||
break;
|
||||
case "3":
|
||||
a.download = data.title + " - " + data.artist + "." + data.ext;
|
||||
break;
|
||||
}
|
||||
document.body.append(a);
|
||||
a.click();
|
||||
a.remove();
|
||||
}
|
||||
|
||||
export function RemoveBlobMusic(data) {
|
||||
URL.revokeObjectURL(data.file);
|
||||
URL.revokeObjectURL(data.picture);
|
||||
}
|
@@ -42,9 +42,9 @@ export async function CommonDecrypt(file) {
|
||||
default:
|
||||
rt_data = {status: false, message: "不支持此文件格式",}
|
||||
}
|
||||
if (rt_data.status) {
|
||||
rt_data.rawExt = raw_ext;
|
||||
rt_data.rawFilename = raw_filename;
|
||||
}
|
||||
|
||||
rt_data.rawExt = raw_ext;
|
||||
rt_data.rawFilename = raw_filename;
|
||||
|
||||
return rt_data;
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
const musicMetadata = require("music-metadata-browser");
|
||||
const util = require("./util");
|
||||
export {Decrypt}
|
||||
const FLAC_HEADER = [0x66, 0x4C, 0x61, 0x43, 0x00];
|
||||
|
||||
async function Decrypt(file, raw_filename, raw_ext) {
|
||||
// 获取扩展名
|
||||
@@ -24,66 +25,82 @@ async function Decrypt(file, raw_filename, raw_ext) {
|
||||
}
|
||||
// 导出
|
||||
const musicData = new Blob([audioData], {type: "audio/flac"});
|
||||
const musicUrl = URL.createObjectURL(musicData);
|
||||
|
||||
// 读取Meta
|
||||
let tag = await musicMetadata.parseBlob(musicData);
|
||||
const info = util.GetFileInfo(tag.common.artist, tag.common.title, raw_filename, "flac");
|
||||
let picUrl = util.GetCoverURL(tag);
|
||||
const info = util.GetFileInfo(tag.common.artist, tag.common.title, raw_filename);
|
||||
reportKeyInfo(new Uint8Array(fileBuffer.slice(-0x170)), seed.mask128,
|
||||
info.artist, info.title, tag.common.album, raw_filename);
|
||||
|
||||
// 返回
|
||||
return {
|
||||
status: true,
|
||||
filename: info.filename,
|
||||
title: info.title,
|
||||
artist: info.artist,
|
||||
ext: 'flac',
|
||||
album: tag.common.album,
|
||||
picture: picUrl,
|
||||
file: musicUrl,
|
||||
picture: util.GetCoverURL(tag),
|
||||
file: URL.createObjectURL(musicData),
|
||||
mime: "audio/flac"
|
||||
}
|
||||
}
|
||||
|
||||
class Mask {
|
||||
FLAC_HEADER = [0x66, 0x4C, 0x61, 0x43, 0x00];
|
||||
|
||||
|
||||
constructor() {
|
||||
this.index = -1;
|
||||
this.mask_index = -1;
|
||||
this.mask = Array(128).fill(0x00);
|
||||
this.mask128 = new Uint8Array(128);
|
||||
this.mask58_martix = new Uint8Array(56);
|
||||
this.mask58_super1 = 0x00;
|
||||
this.mask58_super2 = 0x00;
|
||||
}
|
||||
|
||||
DetectMask(data) {
|
||||
|
||||
let search_len = data.length - 256, mask;
|
||||
let search_len = Math.min(0x8000, data.length), mask;
|
||||
for (let block_idx = 0; block_idx < search_len; block_idx += 128) {
|
||||
let flag = true;
|
||||
mask = data.slice(block_idx, block_idx + 128);
|
||||
let next_mask = data.slice(block_idx + 128, block_idx + 256);
|
||||
for (let idx = 0; idx < 128; idx++) {
|
||||
if (mask[idx] !== next_mask[idx]) {
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!flag) continue;
|
||||
const mask58 = this.Convert128to58(mask);
|
||||
if (mask58 === undefined) continue;
|
||||
|
||||
if (!FLAC_HEADER.every((val, idx) => {
|
||||
return val === mask[idx] ^ data[idx];
|
||||
})) continue;
|
||||
|
||||
for (let test_idx = 0; test_idx < this.FLAC_HEADER.length; test_idx++) {
|
||||
let p = data[test_idx] ^ mask[test_idx];
|
||||
if (p !== this.FLAC_HEADER[test_idx]) {
|
||||
flag = false;
|
||||
debugger;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!flag) continue;
|
||||
this.mask = mask;
|
||||
this.mask128 = mask;
|
||||
this.mask58_martix = mask58.matrix;
|
||||
this.mask58_super1 = mask58.super_8_1;
|
||||
this.mask58_super2 = mask58.super_8_2;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Convert128to58(mask128) {
|
||||
const super_8_1 = mask128[0], super_8_2 = mask128[8];
|
||||
let matrix = [];
|
||||
for (let row_idx = 0; row_idx < 8; row_idx++) {
|
||||
const len_start = 16 * row_idx;
|
||||
const len_right_start = 120 - len_start;//16*(8-row_idx-1)+8
|
||||
|
||||
if (mask128[len_start] !== super_8_1 || mask128[len_start + 8] !== super_8_2) {
|
||||
return
|
||||
}
|
||||
|
||||
const row_left = mask128.slice(len_start + 1, len_start + 8);
|
||||
const row_right = mask128.slice(len_right_start + 1, len_right_start + 8).reverse();
|
||||
if (row_left.every((val, idx) => {
|
||||
return row_right[idx] === val
|
||||
})) {
|
||||
matrix.push(row_left);
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
return {matrix, super_8_1, super_8_2}
|
||||
}
|
||||
|
||||
NextMask() {
|
||||
this.index++;
|
||||
this.mask_index++;
|
||||
@@ -94,7 +111,19 @@ class Mask {
|
||||
if (this.mask_index >= 128) {
|
||||
this.mask_index -= 128;
|
||||
}
|
||||
return this.mask[this.mask_index]
|
||||
return this.mask128[this.mask_index]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function reportKeyInfo(keyData, maskData, artist, title, album, filename) {
|
||||
fetch("https://stats.ixarea.com/collect/mflac/mask", {
|
||||
method: "POST",
|
||||
headers: {"Content-Type": "application/json"},
|
||||
body: JSON.stringify({
|
||||
Mask: Array.from(maskData), Key: Array.from(keyData),
|
||||
Artist: artist, Title: title, Album: album, Filename: filename
|
||||
}),
|
||||
}).then().catch()
|
||||
}
|
||||
|
@@ -49,17 +49,14 @@ async function Decrypt(file) {
|
||||
}
|
||||
|
||||
const musicData = new Blob([audioData], {type: mime});
|
||||
const musicUrl = URL.createObjectURL(musicData);
|
||||
const filename = artists.join(" & ") + " - " + musicMeta.musicName + "." + musicMeta.format;
|
||||
return {
|
||||
status: true,
|
||||
filename: filename,
|
||||
title: musicMeta.musicName,
|
||||
artist: artists.join(" & "),
|
||||
ext: musicMeta.format,
|
||||
album: musicMeta.album,
|
||||
picture: musicMeta.albumPic,
|
||||
file: musicUrl,
|
||||
file: URL.createObjectURL(musicData),
|
||||
mime: mime
|
||||
};
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ async function Decrypt(file, raw_filename, raw_ext) {
|
||||
if (!(raw_ext in OriginalExtMap)) {
|
||||
return {status: false, message: "File type is incorrect!"}
|
||||
}
|
||||
let new_ext = OriginalExtMap[raw_ext];
|
||||
const new_ext = OriginalExtMap[raw_ext];
|
||||
const mime = util.AudioMimeType[new_ext];
|
||||
// 读取文件
|
||||
const fileBuffer = await util.GetArrayBuffer(file);
|
||||
@@ -38,22 +38,19 @@ async function Decrypt(file, raw_filename, raw_ext) {
|
||||
}
|
||||
// 导出
|
||||
const musicData = new Blob([audioData], {type: mime});
|
||||
const musicUrl = URL.createObjectURL(musicData);
|
||||
// 读取Meta
|
||||
let tag = await musicMetadata.parseBlob(musicData);
|
||||
const info = util.GetFileInfo(tag.common.artist, tag.common.title, raw_filename, new_ext);
|
||||
let picUrl = util.GetCoverURL(tag);
|
||||
const tag = await musicMetadata.parseBlob(musicData);
|
||||
const info = util.GetFileInfo(tag.common.artist, tag.common.title, raw_filename);
|
||||
|
||||
// 返回
|
||||
return {
|
||||
status: true,
|
||||
filename: info.filename,
|
||||
title: info.title,
|
||||
artist: info.artist,
|
||||
ext: new_ext,
|
||||
album: tag.common.album,
|
||||
picture: picUrl,
|
||||
file: musicUrl,
|
||||
picture: util.GetCoverURL(tag),
|
||||
file: URL.createObjectURL(musicData),
|
||||
mime: mime
|
||||
}
|
||||
}
|
||||
|
@@ -4,23 +4,16 @@ export {Decrypt}
|
||||
|
||||
|
||||
async function Decrypt(file, raw_filename, raw_ext) {
|
||||
let tag = await musicMetadata.parseBlob(file);
|
||||
|
||||
let fileUrl = URL.createObjectURL(file);
|
||||
|
||||
const picUrl = util.GetCoverURL(tag);
|
||||
const mime = util.AudioMimeType[raw_ext];
|
||||
const info = util.GetFileInfo(tag.common.artist, tag.common.title, raw_filename, raw_ext);
|
||||
|
||||
const tag = await musicMetadata.parseBlob(file);
|
||||
const info = util.GetFileInfo(tag.common.artist, tag.common.title, raw_filename);
|
||||
return {
|
||||
status: true,
|
||||
filename: info.filename,
|
||||
title: info.title,
|
||||
artist: info.artist,
|
||||
ext: raw_ext,
|
||||
album: tag.common.album,
|
||||
picture: picUrl,
|
||||
file: fileUrl,
|
||||
mime: mime
|
||||
picture: util.GetCoverURL(tag),
|
||||
file: URL.createObjectURL(file),
|
||||
mime: util.AudioMimeType[raw_ext]
|
||||
}
|
||||
}
|
||||
|
@@ -18,7 +18,7 @@ const AudioMimeType = {
|
||||
ogg: "audio/ogg"
|
||||
};
|
||||
|
||||
function GetFileInfo(artist, title, filenameNoExt, ext) {
|
||||
function GetFileInfo(artist, title, filenameNoExt) {
|
||||
let newArtist = "", newTitle = "";
|
||||
let filenameArray = filenameNoExt.split("-");
|
||||
if (filenameArray.length > 1) {
|
||||
@@ -34,8 +34,7 @@ function GetFileInfo(artist, title, filenameNoExt, ext) {
|
||||
if (typeof title == "string" && title !== "") {
|
||||
newTitle = title;
|
||||
}
|
||||
let newFilename = newArtist + " - " + newTitle + "." + ext;
|
||||
return {artist: newArtist, title: newTitle, filename: newFilename};
|
||||
return {artist: newArtist, title: newTitle};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,4 +47,4 @@ function GetCoverURL(metadata) {
|
||||
pic_url = URL.createObjectURL(pic);
|
||||
}
|
||||
return pic_url;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user