2022-11-21 22:40:02 +00:00
|
|
|
import { Decrypt as Mg3dDecrypt } from '@/decrypt/mg3d';
|
2021-12-18 13:55:31 +00:00
|
|
|
import { Decrypt as NcmDecrypt } from '@/decrypt/ncm';
|
|
|
|
import { Decrypt as NcmCacheDecrypt } from '@/decrypt/ncmcache';
|
|
|
|
import { Decrypt as XmDecrypt } from '@/decrypt/xm';
|
|
|
|
import { Decrypt as QmcDecrypt } from '@/decrypt/qmc';
|
|
|
|
import { Decrypt as QmcCacheDecrypt } from '@/decrypt/qmccache';
|
|
|
|
import { Decrypt as KgmDecrypt } from '@/decrypt/kgm';
|
|
|
|
import { Decrypt as KwmDecrypt } from '@/decrypt/kwm';
|
|
|
|
import { Decrypt as RawDecrypt } from '@/decrypt/raw';
|
|
|
|
import { Decrypt as TmDecrypt } from '@/decrypt/tm';
|
2021-12-19 23:03:46 +00:00
|
|
|
import { Decrypt as JooxDecrypt } from '@/decrypt/joox';
|
2021-12-18 13:55:31 +00:00
|
|
|
import { DecryptResult, FileInfo } from '@/decrypt/entity';
|
|
|
|
import { SplitFilename } from '@/decrypt/utils';
|
2021-12-20 22:22:35 +00:00
|
|
|
import { storage } from '@/utils/storage';
|
|
|
|
import InMemoryStorage from '@/utils/storage/InMemoryStorage';
|
|
|
|
|
2022-01-09 02:22:00 +00:00
|
|
|
export async function Decrypt(file: FileInfo, config: Record<string, any>): Promise<DecryptResult> {
|
2021-12-20 22:22:35 +00:00
|
|
|
// Worker thread will fallback to in-memory storage.
|
|
|
|
if (storage instanceof InMemoryStorage) {
|
|
|
|
await storage.setAll(config);
|
|
|
|
}
|
2021-05-23 15:47:01 +00:00
|
|
|
|
2021-12-18 13:55:31 +00:00
|
|
|
const raw = SplitFilename(file.name);
|
|
|
|
let rt_data: DecryptResult;
|
|
|
|
switch (raw.ext) {
|
2022-11-21 22:40:02 +00:00
|
|
|
case 'mg3d': // Migu Wav
|
|
|
|
rt_data = await Mg3dDecrypt(file.raw, raw.name);
|
|
|
|
break;
|
2021-12-18 13:55:31 +00:00
|
|
|
case 'ncm': // Netease Mp3/Flac
|
|
|
|
rt_data = await NcmDecrypt(file.raw, raw.name, raw.ext);
|
|
|
|
break;
|
|
|
|
case 'uc': // Netease Cache
|
|
|
|
rt_data = await NcmCacheDecrypt(file.raw, raw.name, raw.ext);
|
|
|
|
break;
|
|
|
|
case 'kwm': // Kuwo Mp3/Flac
|
|
|
|
rt_data = await KwmDecrypt(file.raw, raw.name, raw.ext);
|
|
|
|
break;
|
|
|
|
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(file.raw, raw.name, raw.ext);
|
|
|
|
break;
|
|
|
|
case 'ogg': // Raw Ogg
|
|
|
|
rt_data = await RawDecrypt(file.raw, raw.name, raw.ext);
|
|
|
|
break;
|
|
|
|
case 'tm0': // QQ Music IOS Mp3
|
|
|
|
case 'tm3': // QQ Music IOS Mp3
|
|
|
|
rt_data = await RawDecrypt(file.raw, raw.name, 'mp3');
|
|
|
|
break;
|
|
|
|
case 'qmc3': //QQ Music Android Mp3
|
|
|
|
case 'qmc2': //QQ Music Android Ogg
|
|
|
|
case 'qmc0': //QQ Music Android Mp3
|
|
|
|
case 'qmcflac': //QQ Music Android Flac
|
|
|
|
case 'qmcogg': //QQ Music Android Ogg
|
|
|
|
case 'tkm': //QQ Music Accompaniment M4a
|
2022-01-08 17:24:01 +00:00
|
|
|
// Moo Music
|
|
|
|
case 'bkcmp3':
|
|
|
|
case 'bkcm4a':
|
|
|
|
case 'bkcflac':
|
|
|
|
case 'bkcwav':
|
|
|
|
case 'bkcape':
|
|
|
|
case 'bkcogg':
|
|
|
|
case 'bkcwma':
|
|
|
|
// QQ Music v2
|
|
|
|
case 'mggl': //QQ Music Mac
|
2021-12-18 13:55:31 +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
|
2022-01-21 03:38:58 +00:00
|
|
|
case 'mgg0':
|
2021-12-18 13:55:31 +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
|
|
|
|
rt_data = await QmcDecrypt(file.raw, raw.name, raw.ext);
|
|
|
|
break;
|
|
|
|
case 'tm2': // QQ Music IOS M4a
|
|
|
|
case 'tm6': // QQ Music IOS M4a
|
|
|
|
rt_data = await TmDecrypt(file.raw, raw.name);
|
|
|
|
break;
|
|
|
|
case 'cache': //QQ Music Cache
|
|
|
|
rt_data = await QmcCacheDecrypt(file.raw, raw.name, raw.ext);
|
|
|
|
break;
|
|
|
|
case 'vpr':
|
|
|
|
case 'kgm':
|
|
|
|
case 'kgma':
|
|
|
|
rt_data = await KgmDecrypt(file.raw, raw.name, raw.ext);
|
|
|
|
break;
|
2021-12-19 23:03:46 +00:00
|
|
|
case 'ofl_en':
|
|
|
|
rt_data = await JooxDecrypt(file.raw, raw.name, raw.ext);
|
|
|
|
break;
|
2021-12-18 13:55:31 +00:00
|
|
|
default:
|
|
|
|
throw '不支持此文件格式';
|
|
|
|
}
|
2020-02-06 08:01:35 +00:00
|
|
|
|
2021-12-18 13:55:31 +00:00
|
|
|
if (!rt_data.rawExt) rt_data.rawExt = raw.ext;
|
|
|
|
if (!rt_data.rawFilename) rt_data.rawFilename = raw.name;
|
|
|
|
console.log(rt_data);
|
|
|
|
return rt_data;
|
2020-01-21 11:03:41 +00:00
|
|
|
}
|