Skip to content

Commit

Permalink
v3.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
davidxuang committed Nov 25, 2020
1 parent 2481c95 commit 68e3441
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Media.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static class MediaTypeExtensions
{
return null;
}

}

public static string GetMime(this ImageTypes type) => type switch
Expand Down
2 changes: 1 addition & 1 deletion MusicDecrypto.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<Version>3.1.0</Version>
<Version>3.2.0</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions NetEase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ protected override void Decrypt()
_buffer.Origin = _buffer.Position;
_buffer.PerformEach((x, i) =>
{
int j = (i + 1) & 0xff;
return (byte)(x ^ (_mainKey[(_mainKey[j] + _mainKey[(_mainKey[j] + j) & 0xff]) & 0xff]));
var offset = (byte)(i + 1);
return (byte)(x ^ (_mainKey[(byte)(_mainKey[offset] + _mainKey[(byte)(_mainKey[offset] + offset)])]));
});
_musicType = _buffer.ToArray().ParseMusicType();
}
Expand Down Expand Up @@ -164,7 +164,7 @@ protected override void PostDecrypt()
if (_metadata?.Artists?.Count() > 0)
{
tag.Performers = _metadata?.Artists?.ToArray();
tag.AlbumArtists = new string[] { _metadata?.Artists?.First() };
tag.AlbumArtists = new[] { _metadata?.Artists?.First() };
}
if (_metadata?.Album != null)
tag.Album = _metadata?.Album;
Expand Down
83 changes: 75 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,98 @@
[![Build status](https://ci.appveyor.com/api/projects/status/github/davidxuang/musicdecrypto?svg=true)](https://ci.appveyor.com/project/davidxuang/musicdecrypto)
[![GitHub license](https://img.shields.io/github/license/davidxuang/musicdecrypto.svg)](https://github.com/davidxuang/musicdecrypto/blob/master/LICENSE)

This project aims to implement music de-DRM for NetEase Cloud Music and QQ Music on .NET Core, and generate native executable through [CoreRT](https://github.com/dotnet/corert).
This project aims to implement music de-DRM for NetEase Cloud Music and QQ Music on .NET Core, and generate native executable through experimental [Native AOT](https://github.com/dotnet/runtimelab/tree/feature/NativeAOT) feature.

## Supported formats

<table><tbody align="center">
<tr>
<th>Format</th>
<th>Vorbis</th>
<th>MP3</th>
<th>AAC</th>
<th>PCM</th>
<th>FLAC</th>
</tr>
<tr>
<td>NetEase</td>
<td></td>
<td>✔️<br/><sub>.ncm</sub></td>
<td></td>
<td></td>
<td>✔️<br/><sub>.ncm</sub></td>
</tr>
<tr>
<td>Moo</td>
<td></td>
<td>✔️<br/><sub>.bkcmp3</sub></td>
<td></td>
<td></td>
<td>✔️<br/><sub>.bkcflac</sub></td>
</tr>
<tr>
<td rowspan="3">QQ</td>
<td></td>
<td><sup>*</sup></td>
<td>✔️<br/><sub>.tm2/tm6</sub></td>
<td></td>
<td></td>
</tr>
<tr>
<td>✔️<br/><sub>.qmcogg</sub></td>
<td>✔️<br/><sub>.qmc0/qmc3</sub></td>
<td>✔️<br/><sub>.tkm</sub></td>
<td></td>
<td>✔️<br/><sub>.qmcflac</sub></td>
</tr>
<tr>
<td>❌<br/><sub>.mgg</sub></td>
<td></td>
<td></td>
<td></td>
<td>⭕<br/><sub>.mflac</sub></td>
</tr>
<tr>
<td>Xiami</td>
<td></td>
<td>✔️<br/><sub>.xm**</sub></td>
<td>✔️<br/><sub>.xm**</sub></td>
<td>✔️<br/><sub>.xm**</sub></td>
<td>✔️<br/><sub>.xm**</sub></td>
</tr>
<tr>
<td colspan="6" align="left">
<sup>*</sup> .tm0/tm3 are just custom MP3 extensions.<br/>
<sup>**</sup> use <code>-x</code> to include files with a “normal” extension.</td>
</tr>
</tbody></table>

## Build

`dotnet build -c Release`

### Dependencies

- [.NET Core](https://dotnet.microsoft.com) 3.1
- [CommandLineParser](https://github.com/commandlineparser/commandline)
- [.NET](https://dotnet.microsoft.com) 5
- [Json.NET](https://www.newtonsoft.com/json)
- [NLog](https://nlog-project.org/)
- [System.Commandline](https://github.com/dotnet/command-line-api)
- [TagLib#](https://github.com/mono/taglib-sharp)

## Run

Drag and drop files and/or directories into the executable or run:

`MusicDecrypto [options] path...`
`MusicDecrypto [options] [<input>...]`

### Options

- `-d, --skip-duplicate` Do not overwrite existing files.
- `-n, --force-rename` Try to fix Tencent file name basing on metadata.
- `-o, --output <directory>` Specify output directory.
```
-f, --force-overwrite Overwrite existing files.
-n, --renew-name Renew Hash-like names basing on metadata.
-r, --recursive Search files recursively.
-x, --extensive Extend range of extensions to be detected.
-o, --output <output> Output directory.
```

## References

Expand Down
6 changes: 3 additions & 3 deletions Tencent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public abstract class TencentMaskDecrypto : TencentDecrypto
protected int _length;

protected TencentMaskDecrypto(FileInfo file, MusicTypes type) : base(file, type)
{
{
_length = Convert.ToInt32(_buffer.Length);
}

Expand All @@ -78,7 +78,7 @@ protected byte GetMask(int index)

public sealed class TencentStaticDecrypto : TencentMaskDecrypto
{
private static readonly byte[] _mask = new byte[]
private static readonly byte[] _mask = new byte[]
{
0xc3, 0x4a, 0xd6, 0xca, 0x90, 0x67, 0xf7, 0x52,
0xd8, 0xa1, 0x66, 0x62, 0x9f, 0x5b, 0x09, 0x00,
Expand All @@ -95,7 +95,7 @@ public sealed class TencentStaticDecrypto : TencentMaskDecrypto
0xc3, 0x0e, 0x74, 0xbb, 0x90, 0xbc, 0x3f, 0x92,
0xd8, 0x7e, 0x11, 0x13, 0x9f, 0x23, 0x95, 0x5e,
0xc3, 0x00, 0x09, 0x5b, 0x9f, 0x62, 0x66, 0xa1,
0xd8, 0x52, 0xf7, 0x67, 0x90, 0xca, 0xd6, 0x4a,
0xd8, 0x52, 0xf7, 0x67, 0x90, 0xca, 0xd6, 0x4a,
};

public TencentStaticDecrypto(FileInfo file, MusicTypes type) : base(file, type) { }
Expand Down
16 changes: 9 additions & 7 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: '3.1.0.{build}'
version: '3.2.0.{build}'
image:
- Ubuntu
- Ubuntu2004
- Visual Studio 2019
environment:
DOTNET_SDK: net5.0
Expand All @@ -9,7 +9,7 @@ environment:
- ARCH: x64
matrix:
exclude:
- image: Ubuntu
- image: Ubuntu2004
ARCH: generic
shallow_clone: true
pull_requests:
Expand All @@ -22,8 +22,6 @@ dotnet_csproj:
assembly_version: '{version}'
file_version: '{version}'
informational_version: '{version}'
before_build:
- dotnet add package Microsoft.DotNet.ILCompiler -v 6.0.0-*
deploy:
- provider: GitHub
artifact: archive
Expand All @@ -46,16 +44,18 @@ for:
- pwsh: >-
if ($env:APPVEYOR_REPO_TAG_NAME -eq $null) { $env:APPVEYOR_REPO_TAG_NAME = 'snapshot' }
7z a "MusicDecrypto-net5.0-generic-$env:APPVEYOR_REPO_TAG_NAME.7z" .\bin\Release\net5.0\publish\*;
(Get-FileHash "MusicDecrypto-net5.0-generic-$env:APPVEYOR_REPO_TAG_NAME.7z" SHA256).Hash + " MusicDecrypto-net5.0-generic-$env:APPVEYOR_REPO_TAG_NAME.7z" > "MusicDecrypto-net5.0-generic-$APPVEYOR_REPO_TAG_NAME.7z.sha256"
(Get-FileHash "MusicDecrypto-net5.0-generic-$env:APPVEYOR_REPO_TAG_NAME.7z" SHA256).Hash + " MusicDecrypto-net5.0-generic-$env:APPVEYOR_REPO_TAG_NAME.7z" > "MusicDecrypto-net5.0-generic-$env:APPVEYOR_REPO_TAG_NAME.7z.sha256"
artifacts:
- path: '*.7z*'
name: archive
-
matrix:
only:
- image: Ubuntu
- image: Ubuntu2004
install:
- sudo apt-get update && sudo apt-get -y install libkrb5-dev
before_build:
- dotnet add package Microsoft.DotNet.ILCompiler -v 6.0.0-*
build_script:
- dotnet publish -r linux-x64 -c Release /p:IlcInvariantGlobalization=true /p:IlcGenerateCompleteTypeMetadata=false /p:IlcGenerateStackTraceData=false
after_build:
Expand All @@ -70,6 +70,8 @@ for:
matrix:
only:
- image: Visual Studio 2019
before_build:
- dotnet add package Microsoft.DotNet.ILCompiler -v 6.0.0-*
build_script:
- dotnet publish -r win-x64 -c Release /p:IlcInvariantGlobalization=true /p:IlcGenerateCompleteTypeMetadata=false /p:IlcGenerateStackTraceData=false
after_build:
Expand Down

0 comments on commit 68e3441

Please sign in to comment.