Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Music Unlock Web
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
many-archive
Music Unlock Web
Commits
7b398d1e
There was an error fetching the commit references. Please try again later.
Commit
7b398d1e
authored
3 years ago
by
Emmm Monster
Browse files
Options
Downloads
Patches
Plain Diff
simplify: decrypt/ncm-cache & decrypt/common
parent
0f19bee7
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/decrypt/common.ts
+15
-15
15 additions, 15 deletions
src/decrypt/common.ts
src/decrypt/ncmcache.ts
+7
-10
7 additions, 10 deletions
src/decrypt/ncmcache.ts
with
22 additions
and
25 deletions
src/decrypt/common.ts
+
15
−
15
View file @
7b398d1e
...
...
@@ -8,35 +8,35 @@ import {Decrypt as KwmDecrypt} from "@/decrypt/kwm";
import
{
Decrypt
as
RawDecrypt
}
from
"
@/decrypt/raw
"
;
import
{
Decrypt
as
TmDecrypt
}
from
"
@/decrypt/tm
"
;
import
{
DecryptResult
,
FileInfo
}
from
"
@/decrypt/entity
"
;
import
{
SplitFilename
}
from
"
@/decrypt/utils
"
;
export
async
function
CommonDecrypt
(
file
:
FileInfo
):
Promise
<
DecryptResult
>
{
let
raw_ext
=
file
.
name
.
substring
(
file
.
name
.
lastIndexOf
(
"
.
"
)
+
1
,
file
.
name
.
length
).
toLowerCase
();
let
raw_filename
=
file
.
name
.
substring
(
0
,
file
.
name
.
lastIndexOf
(
"
.
"
));
const
raw
=
SplitFilename
(
file
.
name
)
let
rt_data
:
DecryptResult
;
switch
(
raw
_
ext
)
{
switch
(
raw
.
ext
)
{
case
"
ncm
"
:
// Netease Mp3/Flac
rt_data
=
await
NcmDecrypt
(
file
.
raw
,
raw
_file
name
,
raw
_
ext
);
rt_data
=
await
NcmDecrypt
(
file
.
raw
,
raw
.
name
,
raw
.
ext
);
break
;
case
"
uc
"
:
// Netease Cache
rt_data
=
await
NcmCacheDecrypt
(
file
.
raw
,
raw
_file
name
,
raw
_
ext
);
rt_data
=
await
NcmCacheDecrypt
(
file
.
raw
,
raw
.
name
,
raw
.
ext
);
break
;
case
"
kwm
"
:
// Kuwo Mp3/Flac
rt_data
=
await
KwmDecrypt
(
file
.
raw
,
raw
_file
name
,
raw
_
ext
);
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
_file
name
,
raw
_
ext
);
rt_data
=
await
XmDecrypt
(
file
.
raw
,
raw
.
name
,
raw
.
ext
);
break
;
case
"
ogg
"
:
// Raw Ogg
rt_data
=
await
RawDecrypt
(
file
.
raw
,
raw
_file
name
,
raw
_
ext
);
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
_file
name
,
"
mp3
"
);
rt_data
=
await
RawDecrypt
(
file
.
raw
,
raw
.
name
,
"
mp3
"
);
break
;
case
"
qmc3
"
:
//QQ Music Android Mp3
case
"
qmc2
"
:
//QQ Music Android Ogg
...
...
@@ -53,26 +53,26 @@ export async function CommonDecrypt(file: FileInfo): Promise<DecryptResult> {
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
_file
name
,
raw
_
ext
);
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
_file
name
);
rt_data
=
await
TmDecrypt
(
file
.
raw
,
raw
.
name
);
break
;
case
"
cache
"
:
//QQ Music Cache
rt_data
=
await
QmcCacheDecrypt
(
file
.
raw
,
raw
_file
name
,
raw
_
ext
);
rt_data
=
await
QmcCacheDecrypt
(
file
.
raw
,
raw
.
name
,
raw
.
ext
);
break
;
case
"
vpr
"
:
case
"
kgm
"
:
case
"
kgma
"
:
rt_data
=
await
KgmDecrypt
(
file
.
raw
,
raw
_file
name
,
raw
_
ext
);
rt_data
=
await
KgmDecrypt
(
file
.
raw
,
raw
.
name
,
raw
.
ext
);
break
default
:
throw
"
不支持此文件格式
"
}
if
(
!
rt_data
.
rawExt
)
rt_data
.
rawExt
=
raw
_
ext
;
if
(
!
rt_data
.
rawFilename
)
rt_data
.
rawFilename
=
raw
_file
name
;
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
;
}
...
...
This diff is collapsed.
Click to expand it.
src/decrypt/ncmcache.ts
+
7
−
10
View file @
7b398d1e
...
...
@@ -4,18 +4,15 @@ import {DecryptResult} from "@/decrypt/entity";
import
{
parseBlob
as
metaParseBlob
}
from
"
music-metadata-browser
"
;
export
async
function
Decrypt
(
file
:
Blob
,
raw_filename
:
string
,
raw_ext
:
string
,
detect
:
boolean
=
true
)
export
async
function
Decrypt
(
file
:
Blob
,
raw_filename
:
string
,
raw_ext
:
string
)
:
Promise
<
DecryptResult
>
{
let
ext
=
raw_ext
;
if
(
detect
)
{
const
buffer
=
new
Uint8Array
(
await
GetArrayBuffer
(
file
));
let
length
=
buffer
.
length
for
(
let
i
=
0
;
i
<
length
;
i
++
)
{
buffer
[
i
]
^=
163
}
ext
=
SniffAudioExt
(
buffer
,
raw_ext
);
if
(
ext
!==
raw_ext
)
file
=
new
Blob
([
buffer
],
{
type
:
AudioMimeType
[
ext
]})
const
buffer
=
new
Uint8Array
(
await
GetArrayBuffer
(
file
));
let
length
=
buffer
.
length
for
(
let
i
=
0
;
i
<
length
;
i
++
)
{
buffer
[
i
]
^=
163
}
const
ext
=
SniffAudioExt
(
buffer
,
raw_ext
);
if
(
ext
!==
raw_ext
)
file
=
new
Blob
([
buffer
],
{
type
:
AudioMimeType
[
ext
]})
const
tag
=
await
metaParseBlob
(
file
);
const
{
title
,
artist
}
=
GetMetaFromFile
(
raw_filename
,
tag
.
common
.
title
,
tag
.
common
.
artist
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment