2021-05-24 14:19:37 +00:00
|
|
|
import {Decrypt as NcmDecrypt} from "@/decrypt/ncm";
|
2021-06-03 05:00:35 +00:00
|
|
|
import {Decrypt as NcmCacheDecrypt} from "@/decrypt/ncmcache";
|
2021-05-24 14:19:37 +00:00
|
|
|
import {Decrypt as XmDecrypt} from "@/decrypt/xm";
|
|
|
|
import {Decrypt as QmcDecrypt} from "@/decrypt/qmc";
|
2021-06-03 05:00:35 +00:00
|
|
|
import {Decrypt as QmcCacheDecrypt} from "@/decrypt/qmccache";
|
2021-05-24 14:19:37 +00:00
|
|
|
import {Decrypt as KgmDecrypt} from "@/decrypt/kgm";
|
2021-05-23 15:47:01 +00:00
|
|
|
import {Decrypt as KwmDecrypt} from "@/decrypt/kwm";
|
|
|
|
import {Decrypt as RawDecrypt} from "@/decrypt/raw";
|
|
|
|
import {Decrypt as TmDecrypt} from "@/decrypt/tm";
|
2021-05-24 14:19:37 +00:00
|
|
|
import {DecryptResult, FileInfo} from "@/decrypt/entity";
|
2021-06-03 04:47:51 +00:00
|
|
|
import {SplitFilename} from "@/decrypt/utils";
|
2021-05-23 15:47:01 +00:00
|
|
|
|
|
|
|
|
2021-05-24 07:05:14 +00:00
|
|
|
export async function CommonDecrypt(file: FileInfo): Promise<DecryptResult> {
|
2021-06-03 04:47:51 +00:00
|
|
|
const raw = SplitFilename(file.name)
|
2021-05-24 07:05:14 +00:00
|
|
|
let rt_data: DecryptResult;
|
2021-06-03 04:47:51 +00:00
|
|
|
switch (raw.ext) {
|
2020-01-21 11:03:41 +00:00
|
|
|
case "ncm":// Netease Mp3/Flac
|
2021-06-03 04:47:51 +00:00
|
|
|
rt_data = await NcmDecrypt(file.raw, raw.name, raw.ext);
|
2020-01-21 11:03:41 +00:00
|
|
|
break;
|
2021-06-03 05:00:35 +00:00
|
|
|
case "uc":// Netease Cache
|
2021-06-03 04:47:51 +00:00
|
|
|
rt_data = await NcmCacheDecrypt(file.raw, raw.name, raw.ext);
|
2021-06-03 05:00:35 +00:00
|
|
|
break;
|
2020-04-23 12:46:08 +00:00
|
|
|
case "kwm":// Kuwo Mp3/Flac
|
2021-06-03 04:47:51 +00:00
|
|
|
rt_data = await KwmDecrypt(file.raw, raw.name, raw.ext);
|
2020-04-23 10:15:07 +00:00
|
|
|
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
|
2021-06-03 04:47:51 +00:00
|
|
|
rt_data = await XmDecrypt(file.raw, raw.name, raw.ext);
|
2020-04-23 12:46:08 +00:00
|
|
|
break;
|
2020-01-27 09:36:20 +00:00
|
|
|
case "ogg":// Raw Ogg
|
2021-06-03 04:47:51 +00:00
|
|
|
rt_data = await RawDecrypt(file.raw, raw.name, raw.ext);
|
2020-01-21 11:21:17 +00:00
|
|
|
break;
|
2020-01-21 11:03:41 +00:00
|
|
|
case "tm0":// QQ Music IOS Mp3
|
|
|
|
case "tm3":// QQ Music IOS Mp3
|
2021-06-03 04:47:51 +00:00
|
|
|
rt_data = await RawDecrypt(file.raw, raw.name, "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
|
2021-12-15 19:58:43 +00:00
|
|
|
case "mflac"://QQ Music New Flac
|
|
|
|
case "mflac0"://QQ Music New Flac
|
|
|
|
case "mgg": //QQ Music New Ogg
|
|
|
|
case "mgg1": //QQ Music New Ogg
|
2020-09-19 04:00:58 +00:00
|
|
|
case "666c6163"://QQ Music Weiyun Flac
|
|
|
|
case "6d7033"://QQ Music Weiyun Mp3
|
|
|
|
case "6f6767"://QQ Music Weiyun Ogg
|
|
|
|
case "6d3461"://QQ Music Weiyun M4a
|
|
|
|
case "776176"://QQ Music Weiyun Wav
|
2021-06-03 04:47:51 +00:00
|
|
|
rt_data = await QmcDecrypt(file.raw, raw.name, 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
|
2021-06-03 04:47:51 +00:00
|
|
|
rt_data = await TmDecrypt(file.raw, raw.name);
|
2020-01-21 11:03:41 +00:00
|
|
|
break;
|
2021-06-03 05:00:35 +00:00
|
|
|
case "cache"://QQ Music Cache
|
2021-06-03 04:47:51 +00:00
|
|
|
rt_data = await QmcCacheDecrypt(file.raw, raw.name, raw.ext);
|
2021-06-03 05:00:35 +00:00
|
|
|
break;
|
2020-07-16 14:22:32 +00:00
|
|
|
case "vpr":
|
|
|
|
case "kgm":
|
|
|
|
case "kgma":
|
2021-06-03 04:47:51 +00:00
|
|
|
rt_data = await KgmDecrypt(file.raw, raw.name, raw.ext);
|
2020-07-16 14:22:32 +00:00
|
|
|
break
|
2020-01-21 11:03:41 +00:00
|
|
|
default:
|
2021-05-24 07:05:14 +00:00
|
|
|
throw "不支持此文件格式"
|
2020-01-21 11:03:41 +00:00
|
|
|
}
|
2020-02-06 08:01:35 +00:00
|
|
|
|
2021-06-03 04:47:51 +00:00
|
|
|
if (!rt_data.rawExt) rt_data.rawExt = raw.ext;
|
|
|
|
if (!rt_data.rawFilename) rt_data.rawFilename = raw.name;
|
2020-07-31 17:10:27 +00:00
|
|
|
console.log(rt_data);
|
2020-01-21 11:03:41 +00:00
|
|
|
return rt_data;
|
|
|
|
}
|
2021-05-24 14:19:37 +00:00
|
|
|
|