web/src/decrypt/common.js

64 lines
2.5 KiB
JavaScript
Raw Normal View History

2020-01-21 11:03:41 +00:00
const NcmDecrypt = require("./ncm");
2020-04-23 10:15:07 +00:00
const KwmDecrypt = require("./kwm");
2020-04-23 12:46:08 +00:00
const XmDecrypt = require("./xm");
2020-01-21 11:03:41 +00:00
const QmcDecrypt = require("./qmc");
const RawDecrypt = require("./raw");
2020-01-21 11:21:17 +00:00
const TmDecrypt = require("./tm");
2020-07-16 14:22:32 +00:00
const KgmDecrypt = require("./kgm");
2020-01-21 11:03:41 +00:00
2020-02-04 16:30:44 +00:00
export async function CommonDecrypt(file) {
2020-01-21 11:03:41 +00:00
let raw_ext = file.name.substring(file.name.lastIndexOf(".") + 1, file.name.length).toLowerCase();
let raw_filename = file.name.substring(0, file.name.lastIndexOf("."));
let rt_data;
switch (raw_ext) {
case "ncm":// Netease Mp3/Flac
rt_data = await NcmDecrypt.Decrypt(file.raw, raw_filename, raw_ext);
2020-01-21 11:03:41 +00:00
break;
2020-04-23 12:46:08 +00:00
case "kwm":// Kuwo Mp3/Flac
2020-04-23 10:15:07 +00:00
rt_data = await KwmDecrypt.Decrypt(file.raw, raw_filename, raw_ext);
break
2020-04-23 12:46:08 +00:00
case "xm": // Xiami Wav/M4a/Mp3/Flac
case "wav":// Xiami/Raw Wav
case "mp3":// Xiami/Raw Mp3
case "flac":// Xiami/Raw Flac
case "m4a":// Xiami/Raw M4a
rt_data = await XmDecrypt.Decrypt(file.raw, raw_filename, raw_ext);
break;
2020-01-27 09:36:20 +00:00
case "ogg":// Raw Ogg
2020-01-21 11:21:17 +00:00
rt_data = await RawDecrypt.Decrypt(file.raw, raw_filename, raw_ext);
break;
2020-01-21 11:03:41 +00:00
case "tm0":// QQ Music IOS Mp3
case "tm3":// QQ Music IOS Mp3
2020-01-21 11:21:17 +00:00
rt_data = await RawDecrypt.Decrypt(file.raw, raw_filename, "mp3");
2020-01-21 11:03:41 +00:00
break;
case "qmc3"://QQ Music Android Mp3
2020-04-04 17:01:59 +00:00
case "qmc2"://QQ Music Android Ogg
2020-01-21 11:03:41 +00:00
case "qmc0"://QQ Music Android Mp3
case "qmcflac"://QQ Music Android Flac
case "qmcogg"://QQ Music Android Ogg
2020-01-27 09:36:20 +00:00
case "tkm"://QQ Music Accompaniment M4a
2020-01-27 04:50:24 +00:00
case "bkcmp3"://Moo Music Mp3
case "bkcflac"://Moo Music Flac
2020-01-21 11:03:41 +00:00
case "mflac"://QQ Music Desktop Flac
case "mgg": //QQ Music Desktop Ogg
rt_data = await QmcDecrypt.Decrypt(file.raw, raw_filename, raw_ext);
2020-02-10 12:06:59 +00:00
break;
2020-01-27 09:36:20 +00:00
case "tm2":// QQ Music IOS M4a
case "tm6":// QQ Music IOS M4a
2020-01-21 11:21:17 +00:00
rt_data = await TmDecrypt.Decrypt(file.raw, raw_filename);
2020-01-21 11:03:41 +00:00
break;
2020-07-16 14:22:32 +00:00
case "vpr":
case "kgm":
case "kgma":
rt_data = await KgmDecrypt.Decrypt(file.raw, raw_filename, raw_ext);
break
2020-01-21 11:03:41 +00:00
default:
rt_data = {status: false, message: "不支持此文件格式",}
}
2020-02-06 08:01:35 +00:00
2020-05-14 09:36:16 +00:00
if (!rt_data.rawExt) rt_data.rawExt = raw_ext;
if (!rt_data.rawFilename) rt_data.rawFilename = raw_filename;
console.log(rt_data);
2020-01-21 11:03:41 +00:00
return rt_data;
}