From 68e3441bfad79243c4d692f4f748cf3b4da2234e Mon Sep 17 00:00:00 2001 From: David Xuang Date: Tue, 24 Nov 2020 14:39:25 +0800 Subject: [PATCH] v3.2.0 --- Media.cs | 2 +- MusicDecrypto.csproj | 2 +- NetEase.cs | 6 ++-- README.md | 83 +++++++++++++++++++++++++++++++++++++++----- Tencent.cs | 6 ++-- appveyor.yml | 16 +++++---- 6 files changed, 92 insertions(+), 23 deletions(-) diff --git a/Media.cs b/Media.cs index 43b3cfd..c179d4e 100644 --- a/Media.cs +++ b/Media.cs @@ -51,7 +51,7 @@ public static class MediaTypeExtensions { return null; } - + } public static string GetMime(this ImageTypes type) => type switch diff --git a/MusicDecrypto.csproj b/MusicDecrypto.csproj index 4439334..6c01f81 100644 --- a/MusicDecrypto.csproj +++ b/MusicDecrypto.csproj @@ -3,7 +3,7 @@ Exe net5.0 - 3.1.0 + 3.2.0 diff --git a/NetEase.cs b/NetEase.cs index f5033fc..ddb6104 100644 --- a/NetEase.cs +++ b/NetEase.cs @@ -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(); } @@ -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; diff --git a/README.md b/README.md index babbd7e..f74ff5b 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,71 @@ [![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 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FormatVorbisMP3AACPCMFLAC
NetEase✔️
.ncm
✔️
.ncm
Moo✔️
.bkcmp3
✔️
.bkcflac
QQ*✔️
.tm2/tm6
✔️
.qmcogg
✔️
.qmc0/qmc3
✔️
.tkm
✔️
.qmcflac

.mgg

.mflac
Xiami✔️
.xm**
✔️
.xm**
✔️
.xm**
✔️
.xm**
+* .tm0/tm3 are just custom MP3 extensions.
+** use -x to include files with a “normal” extension.
## Build @@ -12,23 +76,26 @@ This project aims to implement music de-DRM for NetEase Cloud Music and QQ Music ### 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] [...]` ### Options -- `-d, --skip-duplicate` Do not overwrite existing files. -- `-n, --force-rename` Try to fix Tencent file name basing on metadata. -- `-o, --output ` 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 directory. +``` ## References diff --git a/Tencent.cs b/Tencent.cs index 54cf654..97f4d1b 100644 --- a/Tencent.cs +++ b/Tencent.cs @@ -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); } @@ -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, @@ -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) { } diff --git a/appveyor.yml b/appveyor.yml index 9eddb11..5373c28 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -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 @@ -9,7 +9,7 @@ environment: - ARCH: x64 matrix: exclude: - - image: Ubuntu + - image: Ubuntu2004 ARCH: generic shallow_clone: true pull_requests: @@ -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 @@ -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: @@ -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: