Repository: cqjjjzr/MusicBee-NeteaseLyrics
Branch: master
Commit: 130f12ba6ebe
Files: 20
Total size: 113.0 KB
Directory structure:
gitextract_nwibctos/
├── .gitattributes
├── .gitignore
├── DataStucture.cs
├── FodyWeavers.xml
├── FodyWeavers.xsd
├── LICENSE
├── LICENSE-Zony
├── LyricProcessor.cs
├── MusicBeeInterface.cs
├── NeteaseApi.cs
├── NeteaseLyrics.cs
├── NeteaseLyrics.csproj
├── NeteaseLyrics.sln
├── NeteaseMusicEncryptionHandler.cs
├── Properties/
│ └── AssemblyInfo.cs
├── README.MD
├── SearchMatch.cs
├── SearchMatchLegacy.cs
├── app.config
└── packages.config
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitattributes
================================================
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain
================================================
FILE: .gitignore
================================================
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# Build result!!!!!!!!!!!!!!!!
pkg/
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
**/Properties/launchSettings.json
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Typescript v1 declaration files
typings/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush
.cr/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
================================================
FILE: DataStucture.cs
================================================
using System.Collections.Generic;
#pragma warning disable 649 // Suppresses: ___ is never assigned to
// ReSharper disable All
namespace MusicBeePlugin
{
internal class SearchResult
{
public SearchResultResult result;
public int code;
}
internal class SearchResultResult
{
public int songCount;
public IEnumerable<SearchResultSong> songs;
}
internal class SearchResultSong
{
public string name;
public long id;
public long duration; // in ms
public SearchResultAlbum album;
public SearchResultArtist[] artists;
}
internal class SearchResultAlbum
{
public long id;
public string name;
}
internal class SearchResultArtist
{
public long id;
public string name;
}
internal class LyricResult
{
public LyricInner lrc;
public LyricInner tlyric;
public int code;
}
internal class LyricInner
{
public string lyric;
}
}
================================================
FILE: FodyWeavers.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<Costura DisableCompression='true' />
</Weavers>
================================================
FILE: FodyWeavers.xsd
================================================
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="Costura" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:all>
<xs:element minOccurs="0" maxOccurs="1" name="ExcludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="IncludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="ExcludeRuntimeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="IncludeRuntimeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged32Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>Obsolete, use UnmanagedWinX86Assemblies instead</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="UnmanagedWinX86Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged X86 (32 bit) assembly names to include, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>Obsolete, use UnmanagedWinX64Assemblies instead.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="UnmanagedWinX64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged X64 (64 bit) assembly names to include, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="UnmanagedWinArm64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged Arm64 (64 bit) assembly names to include, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="PreloadOrder" type="xs:string">
<xs:annotation>
<xs:documentation>The order of preloaded assemblies, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:all>
<xs:attribute name="CreateTemporaryAssemblies" type="xs:boolean">
<xs:annotation>
<xs:documentation>This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeDebugSymbols" type="xs:boolean">
<xs:annotation>
<xs:documentation>Controls if .pdbs for reference assemblies are also embedded.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeRuntimeReferences" type="xs:boolean">
<xs:annotation>
<xs:documentation>Controls if runtime assemblies are also embedded.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="UseRuntimeReferencePaths" type="xs:boolean">
<xs:annotation>
<xs:documentation>Controls whether the runtime assemblies are embedded with their full path or only with their assembly name.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="DisableCompression" type="xs:boolean">
<xs:annotation>
<xs:documentation>Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="DisableCleanup" type="xs:boolean">
<xs:annotation>
<xs:documentation>As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="DisableEventSubscription" type="xs:boolean">
<xs:annotation>
<xs:documentation>The attach method no longer subscribes to the `AppDomain.AssemblyResolve` (.NET 4.x) and `AssemblyLoadContext.Resolving` (.NET 6.0+) events.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="LoadAtModuleInit" type="xs:boolean">
<xs:annotation>
<xs:documentation>Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IgnoreSatelliteAssemblies" type="xs:boolean">
<xs:annotation>
<xs:documentation>Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="ExcludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with |</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="ExcludeRuntimeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with |</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeRuntimeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="Unmanaged32Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>Obsolete, use UnmanagedWinX86Assemblies instead</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="UnmanagedWinX86Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged X86 (32 bit) assembly names to include, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="Unmanaged64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>Obsolete, use UnmanagedWinX64Assemblies instead</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="UnmanagedWinX64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged X64 (64 bit) assembly names to include, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="UnmanagedWinArm64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged Arm64 (64 bit) assembly names to include, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="PreloadOrder" type="xs:string">
<xs:annotation>
<xs:documentation>The order of preloaded assemblies, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>
================================================
FILE: LICENSE
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
================================================
FILE: LICENSE-Zony
================================================
[Included due to adoption of code from ZonyLrcToolsX in the Netease API part.]
MIT License
Copyright (c) 2019 Zony
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: LyricProcessor.cs
================================================
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text.RegularExpressions;
namespace MusicBeePlugin
{
[SuppressMessage("ReSharper", "InconsistentNaming")]
internal static class LyricProcessor
{
private static readonly Regex LyricLineRegex = new Regex(@"((\[.+?])+)(.*)", RegexOptions.Compiled);
public static string InjectTranslation(string originalLrc, string translationLrc)
{
var originalEntries = ExpandEntries(Parse(originalLrc));
var translationEntries = ExpandEntries(Parse(translationLrc));
foreach (var originalEntry in originalEntries)
{
var translationEntry = translationEntries.FirstOrDefault(entry => entry.timeLabel == originalEntry.timeLabel);
if (translationEntry != null)
originalEntry.content += "/" + translationEntry.content;
}
originalEntries.Sort();
return string.Join("\n", originalEntries);
}
private static List<LyricEntry> Parse(string lrc)
{
var result = lrc.Split('\n')
.Where(line => !string.IsNullOrWhiteSpace(line))
.Select(line => LyricLineRegex.Matches(line))
.Where(matches => matches.Count >= 1)
.Select(matches => matches[0])
.Where(match => match.Groups.Count >= 3)
.SelectMany(match => match.Groups[1].Captures.Cast<Capture>(),
(match, capture) => new LyricEntry(capture.Value, match.Groups[3].Value))
.ToList();
return result;
}
private static List<LyricEntry> ExpandEntries(List<LyricEntry> entries)
{
return entries.SelectMany(entry => entry.ExpandTimeLabel()).ToList();
}
}
[SuppressMessage("ReSharper", "InconsistentNaming")]
internal class LyricEntry : IComparable<LyricEntry>
{
private static readonly Regex LyricTimeRegex = new Regex(@"(\[[0-9.:]*])", RegexOptions.Compiled);
public string timeLabel;
public string content;
public LyricEntry(string timeLabel, string content)
{
this.timeLabel = timeLabel;
this.content = content;
}
public override string ToString()
{
return timeLabel + content;
}
public IEnumerable<LyricEntry> ExpandTimeLabel()
{
var matches = LyricTimeRegex.Matches(timeLabel);
foreach (var match in matches.Cast<Match>())
yield return new LyricEntry(match.Value, content);
}
public int CompareTo(LyricEntry other)
{
if (ReferenceEquals(this, other)) return 0;
if (ReferenceEquals(null, other)) return 1;
return string.Compare(timeLabel, other.timeLabel, StringComparison.Ordinal);
}
}
}
================================================
FILE: MusicBeeInterface.cs
================================================
// WARNING: This file is NOT a part of my work and it's from downloaded MusicBee API source!!!
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
namespace MusicBeePlugin
{
[SuppressMessage("ReSharper", "InconsistentNaming")]
public partial class Plugin
{
public const short PluginInfoVersion = 1;
public const short MinInterfaceVersion = 36;
public const short MinApiRevision = 48;
[StructLayout(LayoutKind.Sequential)]
public struct MusicBeeApiInterface
{
public void Initialise(IntPtr apiInterfacePtr)
{
CopyMemory(ref this, apiInterfacePtr, 4);
if (MusicBeeVersion == MusicBeeVersion.v2_0)
// MusicBee version 2.0 - Api methods > revision 25 are not available
CopyMemory(ref this, apiInterfacePtr, 456);
else if (MusicBeeVersion == MusicBeeVersion.v2_1)
CopyMemory(ref this, apiInterfacePtr, 516);
else if (MusicBeeVersion == MusicBeeVersion.v2_2)
CopyMemory(ref this, apiInterfacePtr, 584);
else if (MusicBeeVersion == MusicBeeVersion.v2_3)
CopyMemory(ref this, apiInterfacePtr, 596);
else if (MusicBeeVersion == MusicBeeVersion.v2_4)
CopyMemory(ref this, apiInterfacePtr, 604);
else if (MusicBeeVersion == MusicBeeVersion.v2_5)
CopyMemory(ref this, apiInterfacePtr, 648);
else
CopyMemory(ref this, apiInterfacePtr, Marshal.SizeOf(this));
}
public MusicBeeVersion MusicBeeVersion
{
get {
if (ApiRevision <= 25)
return MusicBeeVersion.v2_0;
else if (ApiRevision <= 31)
return MusicBeeVersion.v2_1;
else if (ApiRevision <= 33)
return MusicBeeVersion.v2_2;
else if (ApiRevision <= 38)
return MusicBeeVersion.v2_3;
else if (ApiRevision <= 43)
return MusicBeeVersion.v2_4;
else if (ApiRevision <= 47)
return MusicBeeVersion.v2_5;
else
return MusicBeeVersion.v3_0;
}
}
public short InterfaceVersion;
public short ApiRevision;
public MB_ReleaseStringDelegate MB_ReleaseString;
public MB_TraceDelegate MB_Trace;
public Setting_GetPersistentStoragePathDelegate Setting_GetPersistentStoragePath;
public Setting_GetSkinDelegate Setting_GetSkin;
public Setting_GetSkinElementColourDelegate Setting_GetSkinElementColour;
public Setting_IsWindowBordersSkinnedDelegate Setting_IsWindowBordersSkinned;
public Library_GetFilePropertyDelegate Library_GetFileProperty;
public Library_GetFileTagDelegate Library_GetFileTag;
public Library_SetFileTagDelegate Library_SetFileTag;
public Library_CommitTagsToFileDelegate Library_CommitTagsToFile;
public Library_GetLyricsDelegate Library_GetLyrics;
[Obsolete("Use Library_GetArtworkEx")]
public Library_GetArtworkDelegate Library_GetArtwork;
public Library_QueryFilesDelegate Library_QueryFiles;
public Library_QueryGetNextFileDelegate Library_QueryGetNextFile;
public Player_GetPositionDelegate Player_GetPosition;
public Player_SetPositionDelegate Player_SetPosition;
public Player_GetPlayStateDelegate Player_GetPlayState;
public Player_ActionDelegate Player_PlayPause;
public Player_ActionDelegate Player_Stop;
public Player_ActionDelegate Player_StopAfterCurrent;
public Player_ActionDelegate Player_PlayPreviousTrack;
public Player_ActionDelegate Player_PlayNextTrack;
public Player_ActionDelegate Player_StartAutoDj;
public Player_ActionDelegate Player_EndAutoDj;
public Player_GetVolumeDelegate Player_GetVolume;
public Player_SetVolumeDelegate Player_SetVolume;
public Player_GetMuteDelegate Player_GetMute;
public Player_SetMuteDelegate Player_SetMute;
public Player_GetShuffleDelegate Player_GetShuffle;
public Player_SetShuffleDelegate Player_SetShuffle;
public Player_GetRepeatDelegate Player_GetRepeat;
public Player_SetRepeatDelegate Player_SetRepeat;
public Player_GetEqualiserEnabledDelegate Player_GetEqualiserEnabled;
public Player_SetEqualiserEnabledDelegate Player_SetEqualiserEnabled;
public Player_GetDspEnabledDelegate Player_GetDspEnabled;
public Player_SetDspEnabledDelegate Player_SetDspEnabled;
public Player_GetScrobbleEnabledDelegate Player_GetScrobbleEnabled;
public Player_SetScrobbleEnabledDelegate Player_SetScrobbleEnabled;
public NowPlaying_GetFileUrlDelegate NowPlaying_GetFileUrl;
public NowPlaying_GetDurationDelegate NowPlaying_GetDuration;
public NowPlaying_GetFilePropertyDelegate NowPlaying_GetFileProperty;
public NowPlaying_GetFileTagDelegate NowPlaying_GetFileTag;
public NowPlaying_GetLyricsDelegate NowPlaying_GetLyrics;
public NowPlaying_GetArtworkDelegate NowPlaying_GetArtwork;
public NowPlayingList_ActionDelegate NowPlayingList_Clear;
public Library_QueryFilesDelegate NowPlayingList_QueryFiles;
public Library_QueryGetNextFileDelegate NowPlayingList_QueryGetNextFile;
public NowPlayingList_FileActionDelegate NowPlayingList_PlayNow;
public NowPlayingList_FileActionDelegate NowPlayingList_QueueNext;
public NowPlayingList_FileActionDelegate NowPlayingList_QueueLast;
public NowPlayingList_ActionDelegate NowPlayingList_PlayLibraryShuffled;
public Playlist_QueryPlaylistsDelegate Playlist_QueryPlaylists;
public Playlist_QueryGetNextPlaylistDelegate Playlist_QueryGetNextPlaylist;
public Playlist_GetTypeDelegate Playlist_GetType;
public Playlist_QueryFilesDelegate Playlist_QueryFiles;
public Library_QueryGetNextFileDelegate Playlist_QueryGetNextFile;
public MB_WindowHandleDelegate MB_GetWindowHandle;
public MB_RefreshPanelsDelegate MB_RefreshPanels;
public MB_SendNotificationDelegate MB_SendNotification;
public MB_AddMenuItemDelegate MB_AddMenuItem;
public Setting_GetFieldNameDelegate Setting_GetFieldName;
[Obsolete("Use Library_QueryFilesEx", true)]
public Library_QueryGetAllFilesDelegate Library_QueryGetAllFiles;
[Obsolete("Use NowPlayingList_QueryFilesEx", true)]
public Library_QueryGetAllFilesDelegate NowPlayingList_QueryGetAllFiles;
[Obsolete("Use Playlist_QueryFilesEx", true)]
public Library_QueryGetAllFilesDelegate Playlist_QueryGetAllFiles;
public MB_CreateBackgroundTaskDelegate MB_CreateBackgroundTask;
public MB_SetBackgroundTaskMessageDelegate MB_SetBackgroundTaskMessage;
public MB_RegisterCommandDelegate MB_RegisterCommand;
public Setting_GetDefaultFontDelegate Setting_GetDefaultFont;
public Player_GetShowTimeRemainingDelegate Player_GetShowTimeRemaining;
public NowPlayingList_GetCurrentIndexDelegate NowPlayingList_GetCurrentIndex;
public NowPlayingList_GetFileUrlDelegate NowPlayingList_GetListFileUrl;
public NowPlayingList_GetFilePropertyDelegate NowPlayingList_GetFileProperty;
public NowPlayingList_GetFileTagDelegate NowPlayingList_GetFileTag;
public NowPlaying_GetSpectrumDataDelegate NowPlaying_GetSpectrumData;
public NowPlaying_GetSoundGraphDelegate NowPlaying_GetSoundGraph;
public MB_GetPanelBoundsDelegate MB_GetPanelBounds;
public MB_AddPanelDelegate MB_AddPanel;
public MB_RemovePanelDelegate MB_RemovePanel;
public MB_GetLocalisationDelegate MB_GetLocalisation;
public NowPlayingList_IsAnyPriorTracksDelegate NowPlayingList_IsAnyPriorTracks;
public NowPlayingList_IsAnyFollowingTracksDelegate NowPlayingList_IsAnyFollowingTracks;
public Player_ShowEqualiserDelegate Player_ShowEqualiser;
public Player_GetAutoDjEnabledDelegate Player_GetAutoDjEnabled;
public Player_GetStopAfterCurrentEnabledDelegate Player_GetStopAfterCurrentEnabled;
public Player_GetCrossfadeDelegate Player_GetCrossfade;
public Player_SetCrossfadeDelegate Player_SetCrossfade;
public Player_GetReplayGainModeDelegate Player_GetReplayGainMode;
public Player_SetReplayGainModeDelegate Player_SetReplayGainMode;
public Player_QueueRandomTracksDelegate Player_QueueRandomTracks;
public Setting_GetDataTypeDelegate Setting_GetDataType;
public NowPlayingList_GetNextIndexDelegate NowPlayingList_GetNextIndex;
public NowPlaying_GetArtistPictureDelegate NowPlaying_GetArtistPicture;
public NowPlaying_GetArtworkDelegate NowPlaying_GetDownloadedArtwork;
// api version 16
public MB_ShowNowPlayingAssistantDelegate MB_ShowNowPlayingAssistant;
// api version 17
public NowPlaying_GetLyricsDelegate NowPlaying_GetDownloadedLyrics;
// api version 18
public Player_GetShowRatingTrackDelegate Player_GetShowRatingTrack;
public Player_GetShowRatingLoveDelegate Player_GetShowRatingLove;
// api version 19
public MB_CreateParameterisedBackgroundTaskDelegate MB_CreateParameterisedBackgroundTask;
public Setting_GetLastFmUserIdDelegate Setting_GetLastFmUserId;
public Playlist_GetNameDelegate Playlist_GetName;
public Playlist_CreatePlaylistDelegate Playlist_CreatePlaylist;
public Playlist_SetFilesDelegate Playlist_SetFiles;
public Library_QuerySimilarArtistsDelegate Library_QuerySimilarArtists;
public Library_QueryLookupTableDelegate Library_QueryLookupTable;
public Library_QueryGetLookupTableValueDelegate Library_QueryGetLookupTableValue;
public NowPlayingList_FilesActionDelegate NowPlayingList_QueueFilesNext;
public NowPlayingList_FilesActionDelegate NowPlayingList_QueueFilesLast;
// api version 20
public Setting_GetWebProxyDelegate Setting_GetWebProxy;
// api version 21
public NowPlayingList_RemoveAtDelegate NowPlayingList_RemoveAt;
// api version 22
public Playlist_RemoveAtDelegate Playlist_RemoveAt;
// api version 23
public MB_SetPanelScrollableAreaDelegate MB_SetPanelScrollableArea;
// api version 24
public MB_InvokeCommandDelegate MB_InvokeCommand;
public MB_OpenFilterInTabDelegate MB_OpenFilterInTab;
// api version 25
public MB_SetWindowSizeDelegate MB_SetWindowSize;
public Library_GetArtistPictureDelegate Library_GetArtistPicture;
public Pending_GetFileUrlDelegate Pending_GetFileUrl;
public Pending_GetFilePropertyDelegate Pending_GetFileProperty;
public Pending_GetFileTagDelegate Pending_GetFileTag;
// api version 26
public Player_GetButtonEnabledDelegate Player_GetButtonEnabled;
// api version 27
public NowPlayingList_MoveFilesDelegate NowPlayingList_MoveFiles;
// api version 28
public Library_GetArtworkDelegate Library_GetArtworkUrl;
public Library_GetArtistPictureThumbDelegate Library_GetArtistPictureThumb;
public NowPlaying_GetArtworkDelegate NowPlaying_GetArtworkUrl;
public NowPlaying_GetArtworkDelegate NowPlaying_GetDownloadedArtworkUrl;
public NowPlaying_GetArtistPictureThumbDelegate NowPlaying_GetArtistPictureThumb;
// api version 29
public Playlist_IsInListDelegate Playlist_IsInList;
// api version 30
public Library_GetArtistPictureUrlsDelegate Library_GetArtistPictureUrls;
public NowPlaying_GetArtistPictureUrlsDelegate NowPlaying_GetArtistPictureUrls;
// api version 31
public Playlist_AddFilesDelegate Playlist_AppendFiles;
// api version 32
public Sync_FileStartDelegate Sync_FileStart;
public Sync_FileEndDelegate Sync_FileEnd;
// api version 33
public Library_QueryFilesExDelegate Library_QueryFilesEx;
public Library_QueryFilesExDelegate NowPlayingList_QueryFilesEx;
public Playlist_QueryFilesExDelegate Playlist_QueryFilesEx;
public Playlist_MoveFilesDelegate Playlist_MoveFiles;
public Playlist_PlayNowDelegate Playlist_PlayNow;
public NowPlaying_IsSoundtrackDelegate NowPlaying_IsSoundtrack;
public NowPlaying_GetArtistPictureUrlsDelegate NowPlaying_GetSoundtrackPictureUrls;
public Library_GetDevicePersistentIdDelegate Library_GetDevicePersistentId;
public Library_SetDevicePersistentIdDelegate Library_SetDevicePersistentId;
public Library_FindDevicePersistentIdDelegate Library_FindDevicePersistentId;
public Setting_GetValueDelegate Setting_GetValue;
public Library_AddFileToLibraryDelegate Library_AddFileToLibrary;
public Playlist_DeletePlaylistDelegate Playlist_DeletePlaylist;
public Library_GetSyncDeltaDelegate Library_GetSyncDelta;
// api version 35
public Library_GetFileTagsDelegate Library_GetFileTags;
public NowPlaying_GetFileTagsDelegate NowPlaying_GetFileTags;
public NowPlayingList_GetFileTagsDelegate NowPlayingList_GetFileTags;
// api version 43
public MB_AddTreeNodeDelegate MB_AddTreeNode;
public MB_DownloadFileDelegate MB_DownloadFile;
// api version 47
public Setting_GetFileConvertCommandLineDelegate Setting_GetFileConvertCommandLine;
public Player_OpenStreamHandleDelegate Player_OpenStreamHandle;
public Player_UpdatePlayStatisticsDelegate Player_UpdatePlayStatistics;
public Library_GetArtworkExDelegate Library_GetArtworkEx;
public Library_SetArtworkExDelegate Library_SetArtworkEx;
public MB_GetVisualiserInformationDelegate MB_GetVisualiserInformation;
public MB_ShowVisualiserDelegate MB_ShowVisualiser;
public MB_GetPluginViewInformationDelegate MB_GetPluginViewInformation;
public MB_ShowPluginViewDelegate MB_ShowPluginView;
public Player_GetOutputDevicesDelegate Player_GetOutputDevices;
public Player_SetOutputDeviceDelegate Player_SetOutputDevice;
// api version 48
public MB_UninistallPluginDelegate MB_UninstallPlugin;
}
public enum MusicBeeVersion
{
v2_0 = 0,
v2_1 = 1,
v2_2 = 2,
v2_3 = 3,
v2_4 = 4,
v2_5 = 5,
v3_0 = 6
}
public enum PluginType
{
Unknown = 0,
General = 1,
LyricsRetrieval = 2,
ArtworkRetrieval = 3,
PanelView = 4,
DataStream = 5,
InstantMessenger = 6,
Storage = 7,
VideoPlayer = 8,
DSP = 9,
TagRetrieval = 10,
TagOrArtworkRetrieval = 11,
Upnp = 12
}
[StructLayout(LayoutKind.Sequential)]
public class PluginInfo
{
public short PluginInfoVersion;
public PluginType Type;
public string Name;
public string Description;
public string Author;
public string TargetApplication;
public short VersionMajor;
public short VersionMinor;
public short Revision;
public short MinInterfaceVersion;
public short MinApiRevision;
public ReceiveNotificationFlags ReceiveNotifications;
public int ConfigurationPanelHeight;
}
[Flags()]
public enum ReceiveNotificationFlags
{
StartupOnly = 0x0,
PlayerEvents = 0x1,
DataStreamEvents = 0x2,
TagEvents = 0x04,
DownloadEvents = 0x08
}
public enum NotificationType
{
PluginStartup = 0, // notification sent after successful initialisation for an enabled plugin
TrackChanging = 16,
TrackChanged = 1,
PlayStateChanged = 2,
AutoDjStarted = 3,
AutoDjStopped = 4,
VolumeMuteChanged = 5,
VolumeLevelChanged = 6,
NowPlayingListChanged = 7,
NowPlayingListEnded = 18,
NowPlayingArtworkReady = 8,
NowPlayingLyricsReady = 9,
TagsChanging = 10,
TagsChanged = 11,
RatingChanging = 15,
RatingChanged = 12,
PlayCountersChanged = 13,
ScreenSaverActivating = 14,
ShutdownStarted = 17,
EmbedInPanel = 19,
PlayerRepeatChanged = 20,
PlayerShuffleChanged = 21,
PlayerEqualiserOnOffChanged = 22,
PlayerScrobbleChanged = 23,
ReplayGainChanged = 24,
FileDeleting = 25,
FileDeleted = 26,
ApplicationWindowChanged = 27,
StopAfterCurrentChanged = 28,
LibrarySwitched = 29,
FileAddedToLibrary = 30,
FileAddedToInbox = 31,
SynchCompleted = 32,
DownloadCompleted = 33,
MusicBeeStarted = 34
}
public enum PluginCloseReason
{
MusicBeeClosing = 1,
UserDisabled = 2,
StopNoUnload = 3
}
public enum CallbackType
{
SettingsUpdated = 1,
StorageReady = 2,
StorageFailed = 3,
FilesRetrievedChanged = 4,
FilesRetrievedNoChange = 5,
FilesRetrievedFail = 6,
LyricsDownloaded = 7,
StorageEject = 8,
SuspendPlayCounters = 9,
ResumePlayCounters = 10,
EnablePlugin = 11,
DisablePlugin = 12,
RenderingDevicesChanged = 13,
FullscreenOn = 14,
FullscreenOff = 15
}
public enum FilePropertyType
{
Url = 2,
Kind = 4,
Format = 5,
Size = 7,
Channels = 8,
SampleRate = 9,
Bitrate = 10,
DateModified = 11,
DateAdded = 12,
LastPlayed = 13,
PlayCount = 14,
SkipCount = 15,
Duration = 16,
Status = 21,
NowPlayingListIndex = 78, // only has meaning when called from NowPlayingList_* commands
ReplayGainTrack = 94,
ReplayGainAlbum = 95
}
public enum MetaDataType
{
TrackTitle = 65,
Album = 30,
AlbumArtist = 31, // displayed album artist
AlbumArtistRaw = 34, // stored album artist
Artist = 32, // displayed artist
MultiArtist = 33, // individual artists, separated by a null char
PrimaryArtist = 19, // first artist from multi-artist tagged file, otherwise displayed artist
Artists = 144,
ArtistsWithArtistRole = 145,
ArtistsWithPerformerRole = 146,
ArtistsWithGuestRole = 147,
ArtistsWithRemixerRole = 148,
Artwork = 40,
BeatsPerMin = 41,
Composer = 43, // displayed composer
MultiComposer = 89, // individual composers, separated by a null char
Comment = 44,
Conductor = 45,
Custom1 = 46,
Custom2 = 47,
Custom3 = 48,
Custom4 = 49,
Custom5 = 50,
Custom6 = 96,
Custom7 = 97,
Custom8 = 98,
Custom9 = 99,
Custom10 = 128,
Custom11 = 129,
Custom12 = 130,
Custom13 = 131,
Custom14 = 132,
Custom15 = 133,
Custom16 = 134,
DiscNo = 52,
DiscCount = 54,
Encoder = 55,
Genre = 59,
Genres = 143,
GenreCategory = 60,
Grouping = 61,
Keywords = 84,
HasLyrics = 63,
Lyricist = 62,
Lyrics = 114,
Mood = 64,
Occasion = 66,
Origin = 67,
Publisher = 73,
Quality = 74,
Rating = 75,
RatingLove = 76,
RatingAlbum = 104,
Tempo = 85,
TrackNo = 86,
TrackCount = 87,
Virtual1 = 109,
Virtual2 = 110,
Virtual3 = 111,
Virtual4 = 112,
Virtual5 = 113,
Virtual6 = 122,
Virtual7 = 123,
Virtual8 = 124,
Virtual9 = 125,
Virtual10 = 135,
Virtual11 = 136,
Virtual12 = 137,
Virtual13 = 138,
Virtual14 = 139,
Virtual15 = 140,
Virtual16 = 141,
Year = 88
}
public enum FileCodec
{
Unknown = -1,
Mp3 = 1,
Aac = 2,
Flac = 3,
Ogg = 4,
WavPack = 5,
Wma = 6,
Tak = 7,
Mpc = 8,
Wave = 9,
Asx = 10,
Alac = 11,
Aiff = 12,
Pcm = 13,
Opus = 15,
Spx = 16,
Dsd = 17,
AacNoContainer = 18
}
public enum EncodeQuality
{
SmallSize = 1,
Portable = 2,
HighQuality = 3,
Archiving = 4
}
[Flags()]
public enum LibraryCategory
{
Music = 0,
Audiobook = 1,
Video = 2,
Inbox = 4
}
public enum DeviceIdType
{
GooglePlay = 1,
AppleDevice = 2,
GooglePlay2 = 3,
AppleDevice2 = 4
}
public enum DataType
{
String = 0,
Number = 1,
DateTime = 2,
Rating = 3
}
public enum SettingId
{
CompactPlayerFlickrEnabled = 1,
FileTaggingPreserveModificationTime = 2,
LastDownloadFolder = 3,
ArtistGenresOnly = 4,
IgnoreNamePrefixes = 5,
IgnoreNameChars = 6,
PlayCountTriggerPercent = 7,
PlayCountTriggerSeconds = 8,
SkipCountTriggerPercent = 9,
SkipCountTriggerSeconds = 10,
CustomWebLinkName1 = 11,
CustomWebLinkName2 = 12,
CustomWebLinkName3 = 13,
CustomWebLinkName4 = 14,
CustomWebLinkName5 = 15,
CustomWebLinkName6 = 16,
CustomWebLink1 = 17,
CustomWebLink2 = 18,
CustomWebLink3 = 19,
CustomWebLink4 = 20,
CustomWebLink5 = 21,
CustomWebLink6 = 22,
CustomWebLinkNowPlaying1 = 23,
CustomWebLinkNowPlaying2 = 24,
CustomWebLinkNowPlaying3 = 25,
CustomWebLinkNowPlaying4 = 26,
CustomWebLinkNowPlaying5 = 27,
CustomWebLinkNowPlaying6 = 28
}
public enum ComparisonType
{
Is = 0,
IsSimilar = 20
}
public enum LyricsType
{
NotSpecified = 0,
Synchronised = 1,
UnSynchronised = 2
}
public enum PlayState
{
Undefined = 0,
Loading = 1,
Playing = 3,
Paused = 6,
Stopped = 7
}
public enum RepeatMode
{
None = 0,
All = 1,
One = 2
}
public enum PlayButtonType
{
PreviousTrack = 0,
PlayPause = 1,
NextTrack = 2,
Stop = 3
}
public enum PlaylistFormat
{
Unknown = 0,
M3u = 1,
Xspf = 2,
Asx = 3,
Wpl = 4,
Pls = 5,
Auto = 7,
M3uAscii = 8,
AsxFile = 9,
Radio = 10,
M3uExtended = 11,
Mbp = 12
}
public enum SkinElement
{
SkinInputControl = 7,
SkinInputPanel = 10,
SkinInputPanelLabel = 14,
SkinTrackAndArtistPanel = -1
}
public enum ElementState
{
ElementStateDefault = 0,
ElementStateModified = 6
}
public enum ElementComponent
{
ComponentBorder = 0,
ComponentBackground = 1,
ComponentForeground = 3
}
public enum PluginPanelDock
{
ApplicationWindow = 0,
TrackAndArtistPanel = 1,
TextBox = 3,
ComboBox = 4,
MainPanel = 5
}
public enum ReplayGainMode
{
Off = 0,
Track = 1,
Album = 2,
Smart = 3
}
public enum PlayStatisticType
{
NoChange = 0,
IncreasePlayCount = 1,
IncreaseSkipCount = 2
}
public enum Command
{
NavigateTo = 1
}
public enum DownloadTarget
{
Inbox = 0,
MusicLibrary = 1,
SpecificFolder = 3
}
[Flags()]
public enum PictureLocations: byte
{
None = 0,
EmbedInFile = 1,
LinkToOrganisedCopy = 2,
LinkToSource = 4,
FolderThumb = 8
}
public enum WindowState
{
Off = -1,
Normal = 0,
Fullscreen = 1,
Desktop = 2
}
public delegate void MB_ReleaseStringDelegate(string p1);
public delegate void MB_TraceDelegate(string p1);
public delegate IntPtr MB_WindowHandleDelegate();
public delegate void MB_RefreshPanelsDelegate();
public delegate void MB_SendNotificationDelegate(CallbackType type);
public delegate System.Windows.Forms.ToolStripItem MB_AddMenuItemDelegate(string menuPath, string hotkeyDescription, EventHandler handler);
public delegate bool MB_AddTreeNodeDelegate(string treePath, string name, System.Drawing.Bitmap icon, EventHandler openHandler, EventHandler closeHandler);
public delegate void MB_RegisterCommandDelegate(string command, EventHandler handler);
public delegate void MB_CreateBackgroundTaskDelegate(System.Threading.ThreadStart taskCallback, System.Windows.Forms.Form owner);
public delegate void MB_CreateParameterisedBackgroundTaskDelegate(System.Threading.ParameterizedThreadStart taskCallback, object parameters, System.Windows.Forms.Form owner);
public delegate void MB_SetBackgroundTaskMessageDelegate(string message);
public delegate System.Drawing.Rectangle MB_GetPanelBoundsDelegate(PluginPanelDock dock);
public delegate bool MB_SetPanelScrollableAreaDelegate(System.Windows.Forms.Control panel, System.Drawing.Size scrollArea, bool alwaysShowScrollBar);
public delegate System.Windows.Forms.Control MB_AddPanelDelegate(System.Windows.Forms.Control panel, PluginPanelDock dock);
public delegate void MB_RemovePanelDelegate(System.Windows.Forms.Control panel);
public delegate string MB_GetLocalisationDelegate(string id, string defaultText);
public delegate bool MB_ShowNowPlayingAssistantDelegate();
public delegate bool MB_InvokeCommandDelegate(Command command, object parameter);
public delegate bool MB_OpenFilterInTabDelegate(MetaDataType field1, ComparisonType comparison1, string value1, MetaDataType field2, ComparisonType comparison2, string value2);
public delegate bool MB_SetWindowSizeDelegate(int width, int height);
public delegate bool MB_DownloadFileDelegate(string url, DownloadTarget target, string targetFolder, bool cancelDownload);
public delegate bool MB_GetVisualiserInformationDelegate(out string[] visualiserNames, out string defaultVisualiserName, out WindowState defaultState, out WindowState currentState);
public delegate bool MB_ShowVisualiserDelegate(string visualiserName, WindowState state);
public delegate bool MB_GetPluginViewInformationDelegate(string pluginFilename, out string[] viewNames, out string defaultViewName, out WindowState defaultState, out WindowState currentState);
public delegate bool MB_ShowPluginViewDelegate(string pluginFilename, string viewName, WindowState state);
public delegate bool MB_UninistallPluginDelegate(string pluginFilename, string password);
public delegate string Setting_GetFieldNameDelegate(MetaDataType field);
public delegate string Setting_GetPersistentStoragePathDelegate();
public delegate string Setting_GetSkinDelegate();
public delegate int Setting_GetSkinElementColourDelegate(SkinElement element, ElementState state, ElementComponent component);
public delegate bool Setting_IsWindowBordersSkinnedDelegate();
public delegate System.Drawing.Font Setting_GetDefaultFontDelegate();
public delegate DataType Setting_GetDataTypeDelegate(MetaDataType field);
public delegate string Setting_GetLastFmUserIdDelegate();
public delegate string Setting_GetWebProxyDelegate();
public delegate bool Setting_GetValueDelegate(SettingId settingId, ref object value);
public delegate string Setting_GetFileConvertCommandLineDelegate(FileCodec codec, EncodeQuality encodeQuality);
public delegate string Library_GetFilePropertyDelegate(string sourceFileUrl, FilePropertyType type);
public delegate string Library_GetFileTagDelegate(string sourceFileUrl, MetaDataType field);
public delegate bool Library_GetFileTagsDelegate(string sourceFileUrl, MetaDataType[] fields, ref string[] results);
public delegate bool Library_SetFileTagDelegate(string sourceFileUrl, MetaDataType field, string value);
public delegate string Library_GetDevicePersistentIdDelegate(string sourceFileUrl, DeviceIdType idType);
public delegate bool Library_SetDevicePersistentIdDelegate(string sourceFileUrl, DeviceIdType idType, string value);
public delegate bool Library_FindDevicePersistentIdDelegate(DeviceIdType idType, string[] ids, ref string[] values);
public delegate bool Library_CommitTagsToFileDelegate(string sourceFileUrl);
public delegate string Library_AddFileToLibraryDelegate(string sourceFileUrl, LibraryCategory category);
public delegate bool Library_GetSyncDeltaDelegate(string[] cachedFiles, DateTime updatedSince, LibraryCategory categories, ref string[] newFiles, ref string[] updatedFiles, ref string[] deletedFiles);
public delegate string Library_GetLyricsDelegate(string sourceFileUrl, LyricsType type);
public delegate string Library_GetArtworkDelegate(string sourceFileUrl, int index);
public delegate bool Library_GetArtworkExDelegate(string sourceFileUrl, int index, bool retrievePictureData, ref PictureLocations pictureLocations, ref string pictureUrl, ref byte[] imageData);
public delegate bool Library_SetArtworkExDelegate(string sourceFileUrl, int index, byte[] imageData);
public delegate string Library_GetArtistPictureDelegate(string artistName, int fadingPercent, int fadingColor);
public delegate bool Library_GetArtistPictureUrlsDelegate(string artistName, bool localOnly, ref string[] urls);
public delegate string Library_GetArtistPictureThumbDelegate(string artistName);
public delegate bool Library_QueryFilesDelegate(string query);
public delegate string Library_QueryGetNextFileDelegate();
public delegate string Library_QueryGetAllFilesDelegate();
public delegate bool Library_QueryFilesExDelegate(string query, ref string[] files);
public delegate string Library_QuerySimilarArtistsDelegate(string artistName, double minimumArtistSimilarityRating);
public delegate bool Library_QueryLookupTableDelegate(string keyTags, string valueTags, string query);
public delegate string Library_QueryGetLookupTableValueDelegate(string key);
public delegate int Player_GetPositionDelegate();
public delegate bool Player_SetPositionDelegate(int position);
public delegate PlayState Player_GetPlayStateDelegate();
public delegate bool Player_GetButtonEnabledDelegate(PlayButtonType button);
public delegate bool Player_ActionDelegate();
public delegate int Player_QueueRandomTracksDelegate(int count);
public delegate float Player_GetVolumeDelegate();
public delegate bool Player_SetVolumeDelegate(float volume);
public delegate bool Player_GetMuteDelegate();
public delegate bool Player_SetMuteDelegate(bool mute);
public delegate bool Player_GetShuffleDelegate();
public delegate bool Player_SetShuffleDelegate(bool shuffle);
public delegate RepeatMode Player_GetRepeatDelegate();
public delegate bool Player_SetRepeatDelegate(RepeatMode repeat);
public delegate bool Player_GetEqualiserEnabledDelegate();
public delegate bool Player_SetEqualiserEnabledDelegate(bool enabled);
public delegate bool Player_GetDspEnabledDelegate();
public delegate bool Player_SetDspEnabledDelegate(bool enabled);
public delegate bool Player_GetScrobbleEnabledDelegate();
public delegate bool Player_SetScrobbleEnabledDelegate(bool enabled);
public delegate bool Player_GetShowTimeRemainingDelegate();
public delegate bool Player_GetShowRatingTrackDelegate();
public delegate bool Player_GetShowRatingLoveDelegate();
public delegate bool Player_ShowEqualiserDelegate();
public delegate bool Player_GetAutoDjEnabledDelegate();
public delegate bool Player_GetStopAfterCurrentEnabledDelegate();
public delegate bool Player_GetCrossfadeDelegate();
public delegate bool Player_SetCrossfadeDelegate(bool crossfade);
public delegate ReplayGainMode Player_GetReplayGainModeDelegate();
public delegate bool Player_SetReplayGainModeDelegate(ReplayGainMode mode);
public delegate int Player_OpenStreamHandleDelegate(string url, bool useMusicBeeSettings, bool enableDsp, ReplayGainMode gainType);
public delegate bool Player_UpdatePlayStatisticsDelegate(string url, PlayStatisticType countType, bool disableScrobble);
public delegate bool Player_GetOutputDevicesDelegate(out string[] deviceNames, out string activeDeviceName);
public delegate bool Player_SetOutputDeviceDelegate(string deviceName);
public delegate string NowPlaying_GetFileUrlDelegate();
public delegate int NowPlaying_GetDurationDelegate();
public delegate string NowPlaying_GetFilePropertyDelegate(FilePropertyType type);
public delegate string NowPlaying_GetFileTagDelegate(MetaDataType field);
public delegate bool NowPlaying_GetFileTagsDelegate(MetaDataType[] fields, ref string[] results);
public delegate string NowPlaying_GetLyricsDelegate();
public delegate string NowPlaying_GetArtworkDelegate();
public delegate string NowPlaying_GetArtistPictureDelegate(int fadingPercent);
public delegate bool NowPlaying_GetArtistPictureUrlsDelegate(bool localOnly, ref string[] urls);
public delegate string NowPlaying_GetArtistPictureThumbDelegate();
public delegate bool NowPlaying_IsSoundtrackDelegate();
public delegate int NowPlaying_GetSpectrumDataDelegate(float[] fftData);
public delegate bool NowPlaying_GetSoundGraphDelegate(float[] graphData);
public delegate int NowPlayingList_GetCurrentIndexDelegate();
public delegate int NowPlayingList_GetNextIndexDelegate(int offset);
public delegate bool NowPlayingList_IsAnyPriorTracksDelegate();
public delegate bool NowPlayingList_IsAnyFollowingTracksDelegate();
public delegate string NowPlayingList_GetFileUrlDelegate(int index);
public delegate string NowPlayingList_GetFilePropertyDelegate(int index, FilePropertyType type);
public delegate string NowPlayingList_GetFileTagDelegate(int index, MetaDataType field);
public delegate bool NowPlayingList_GetFileTagsDelegate(int index, MetaDataType[] fields, ref string[] results);
public delegate bool NowPlayingList_ActionDelegate();
public delegate bool NowPlayingList_FileActionDelegate(string sourceFileUrl);
public delegate bool NowPlayingList_FilesActionDelegate(string[] sourceFileUrl);
public delegate bool NowPlayingList_RemoveAtDelegate(int index);
public delegate bool NowPlayingList_MoveFilesDelegate(int[] fromIndices, int toIndex);
public delegate string Playlist_GetNameDelegate(string playlistUrl);
public delegate PlaylistFormat Playlist_GetTypeDelegate(string playlistUrl);
public delegate bool Playlist_QueryPlaylistsDelegate();
public delegate string Playlist_QueryGetNextPlaylistDelegate();
public delegate bool Playlist_IsInListDelegate(string playlistUrl, string filename);
public delegate bool Playlist_QueryFilesDelegate(string playlistUrl);
public delegate bool Playlist_QueryFilesExDelegate(string playlistUrl, ref string[] filenames);
public delegate string Playlist_CreatePlaylistDelegate(string folderName, string playlistName, string[] filenames);
public delegate bool Playlist_DeletePlaylistDelegate(string playlistUrl);
public delegate bool Playlist_SetFilesDelegate(string playlistUrl, string[] filenames);
public delegate bool Playlist_AddFilesDelegate(string playlistUrl, string[] filenames);
public delegate bool Playlist_RemoveAtDelegate(string playlistUrl, int index);
public delegate bool Playlist_MoveFilesDelegate(string playlistUrl, int[] fromIndices, int toIndex);
public delegate bool Playlist_PlayNowDelegate(string playlistUrl);
public delegate string Pending_GetFileUrlDelegate();
public delegate string Pending_GetFilePropertyDelegate(FilePropertyType field);
public delegate string Pending_GetFileTagDelegate(MetaDataType field);
public delegate string Sync_FileStartDelegate(string filename);
public delegate void Sync_FileEndDelegate(string filename, bool success, string errorMessage);
[System.Security.SuppressUnmanagedCodeSecurity()]
[DllImport("kernel32.dll")]
private static extern void CopyMemory(ref MusicBeeApiInterface mbApiInterface, IntPtr src, int length);
}
}
================================================
FILE: NeteaseApi.cs
================================================
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
namespace MusicBeePlugin
{
/*
* Partially adopted from https://github.com/real-zony/ZonyLrcToolsX/blob/dev/src/ZonyLrcTools.Common/Lyrics/Providers/NetEase/NetEaseLyricsProvider.cs
*/
internal static class NeteaseApi
{
public static IEnumerable<SearchResultSong> Search(string s)
{
var postData = new Dictionary<string, object>
{
{ "csrf_token", "" },
{ "s", s },
{ "offset", 0 },
{ "type", 1 },
{ "limit", 20 }
};
var result = RequestNewApi<SearchResult>(
@"https://music.163.com/weapi/search/get",
postData, it => it.code == 200);
if (result == null)
return SearchLegacy(s);
return result.result.songCount > 0 ? result.result.songs : Enumerable.Empty<SearchResultSong>();
}
public static LyricResult RequestLyric(long id)
{
var postData = new Dictionary<string, object>
{
{ "OS", "pc" },
{ "id", id },
{ "lv", -1 },
{ "kv", -1 },
{ "tv", -1 },
{ "rv", -1 }
};
return RequestNewApi<LyricResult>(
@"https://music.163.com/weapi/song/lyric?csrf_token=",
postData, it => it.code == 200) ?? RequestLyricLegacy(id);
}
private static T RequestNewApi<T>(string url, Dictionary<string, object> postData, Func<T, bool> checkFunc)
where T : class
{
try
{
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Referrer = new Uri(@"https://music.163.com");
client.DefaultRequestHeaders.UserAgent.ParseAdd(
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36");
using (var result = client.PostAsync(
url,
new FormUrlEncodedContent(EncryptRequest(postData))).Result)
{
var resultString = result.Content.ReadAsStringAsync().Result;
if (!result.IsSuccessStatusCode)
throw new HttpRequestException($"non 200 response from {url}: {resultString}");;
var resultObject = JsonConvert.DeserializeObject<T>(resultString);
if (!checkFunc(resultObject))
throw new HttpRequestException($"non 200 response from {url}: {resultString}");
return resultObject;
}
}
}
catch (Exception e)
{
Debug.WriteLine(e);
return null;
}
}
private static Dictionary<string, string> EncryptRequest(object srcParams)
{
var secretKey = NeteaseMusicEncryptionHelper.CreateSecretKey(16);
var encSecKey = NeteaseMusicEncryptionHelper.RsaEncode(secretKey);
return new Dictionary<string, string>
{
{
"params",
NeteaseMusicEncryptionHelper.AesEncode(
NeteaseMusicEncryptionHelper.AesEncode(
JsonConvert.SerializeObject(srcParams),
NeteaseMusicEncryptionHelper.Nonce),
secretKey)
},
{ "encSecKey", encSecKey }
};
}
private static IEnumerable<SearchResultSong> SearchLegacy(string s)
{
try
{
using (var client = new WebClient())
{
client.Headers[HttpRequestHeader.Referer] = "https://music.163.com/";
client.Headers[HttpRequestHeader.UserAgent] =
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36";
var nameEncoded = Uri.EscapeDataString(s);
var resultStr = Encoding.UTF8.GetString(
client.DownloadData(
$"http://music.163.com/api/search/get/?csrf_token=hlpretag=&hlposttag=&s={nameEncoded}&type=1&offset=0&total=true&limit=6")
);
var searchResult = JsonConvert.DeserializeObject<SearchResult>(resultStr);
if (searchResult.code != 200) return null;
return searchResult.result.songCount <= 0
? Enumerable.Empty<SearchResultSong>()
: searchResult.result.songs;
}
}
catch (Exception ex)
{
Debug.WriteLine(ex);
return Enumerable.Empty<SearchResultSong>();
}
}
private static LyricResult RequestLyricLegacy(long id)
{
try
{
using (var client = new WebClient())
{
client.Headers[HttpRequestHeader.Referer] = "http://music.163.com/";
client.Headers[HttpRequestHeader.Cookie] = "appver=1.5.0.75771;";
var lyricResult = JsonConvert.DeserializeObject<LyricResult>(
Encoding.UTF8.GetString(client.DownloadData("http://music.163.com/api/song/lyric?os=pc&id=" +
id + "&lv=-1&kv=-1&tv=-1")));
return lyricResult.code != 200 ? null : lyricResult;
}
}
catch (Exception ex)
{
Debug.WriteLine(ex);
return null;
}
}
}
}
================================================
FILE: NeteaseLyrics.cs
================================================
using System;
using System.Diagnostics.CodeAnalysis;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using Newtonsoft.Json;
using System.Text.RegularExpressions;
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("NeteaseLyricsTest")]
namespace MusicBeePlugin
{
public class NeteaseConfig
{
public enum OutputFormat
{
Original = 0,
Both = 1,
Translation = 2
}
public OutputFormat Format { get; set; } = OutputFormat.Both;
public bool Fuzzy { get; set; }
public bool UseLegacyMatch { get; set; }
}
public partial class Plugin
{
private const string ProviderName = "Netease Cloud Music(网易云音乐)";
private const string ConfigFilename = "netease_config";
private const string NoTranslateFilename = "netease_notranslate";
private NeteaseConfig _config = new NeteaseConfig();
private ComboBox _formatComboBox;
private CheckBox _fuzzyCheckBox;
private CheckBox _useLegacyCheckBox;
private MusicBeeApiInterface _mbApiInterface;
private readonly PluginInfo _about = new PluginInfo();
[SuppressMessage("ReSharper", "UnusedMember.Global")]
public PluginInfo Initialise(IntPtr apiInterfacePtr)
{
var versions = Assembly.GetExecutingAssembly().GetName().Version.ToString().Split('.');
_mbApiInterface = new MusicBeeApiInterface();
_mbApiInterface.Initialise(apiInterfacePtr);
_about.PluginInfoVersion = PluginInfoVersion;
_about.Name = "Netease Lyrics";
_about.Description = "A plugin to retrieve lyrics from Netease Cloud Music.(从网易云音乐获取歌词的插件。)";
_about.Author = "Charlie Jiang";
_about.TargetApplication = ""; // current only applies to artwork, lyrics or instant messenger name that appears in the provider drop down selector or target Instant Messenger
_about.Type = PluginType.LyricsRetrieval;
_about.VersionMajor = short.Parse(versions[0]); // your plugin version
_about.VersionMinor = short.Parse(versions[1]);
_about.Revision = short.Parse(versions[2]);
_about.MinInterfaceVersion = MinInterfaceVersion;
_about.MinApiRevision = MinApiRevision;
_about.ReceiveNotifications = ReceiveNotificationFlags.DownloadEvents;
_about.ConfigurationPanelHeight = 120; // height in pixels that musicbee should reserve in a panel for config settings. When set, a handle to an empty panel will be passed to the Configure function
ReadConfig();
MigrateLegacySetting();
return _about;
}
[SuppressMessage("ReSharper", "UnusedMember.Global")]
public bool Configure(IntPtr panelHandle)
{
if (panelHandle == IntPtr.Zero) return false;
var configPanel = (Panel)Control.FromHandle(panelHandle);
// Components are automatically disposed when this is called.
configPanel.Controls.Clear();
// MB_AddPanel doesn't skin the component correctly either
//_formatComboBox = (ComboBox)_mbApiInterface.MB_AddPanel(null, PluginPanelDock.ComboBox);
_formatComboBox = new ComboBox
{
DropDownStyle = ComboBoxStyle.DropDownList,
AutoSize = true,
Location = new Point(0, 0),
Width = 300
};
_formatComboBox.Items.Add("Only original text");
_formatComboBox.Items.Add("Original text and translation");
_formatComboBox.Items.Add("Only translation");
_formatComboBox.SelectedIndex = (int)_config.Format;
configPanel.Controls.Add(_formatComboBox);
_useLegacyCheckBox = new CheckBox
{
Text = "Use legacy matching strategy",
Location = new Point(0, 50),
Checked = _config.UseLegacyMatch,
AutoSize = true
};
_fuzzyCheckBox = new CheckBox
{
Text = "Fuzzy matching (Don't double check match and use first result directly)",
Location = new Point(0, 80),
Checked = _config.Fuzzy,
AutoSize = true
};
_useLegacyCheckBox.CheckedChanged += (sender, e) =>
{
// "Fuzzy" not available when using new strategy
_fuzzyCheckBox.Enabled = !_useLegacyCheckBox.Checked;
};
configPanel.Controls.Add(_useLegacyCheckBox);
configPanel.Controls.Add(_fuzzyCheckBox);
return false;
}
// called by MusicBee when the user clicks Apply or Save in the MusicBee Preferences screen.
// It's up to you to figure out whether anything has changed and needs updating
[SuppressMessage("ReSharper", "UnusedMember.Global")]
public void SaveSettings()
{
if (_formatComboBox.SelectedIndex < 0 || _formatComboBox.SelectedIndex > 2)
_config.Format = NeteaseConfig.OutputFormat.Both;
else
_config.Format = (NeteaseConfig.OutputFormat)_formatComboBox.SelectedIndex;
_config.Fuzzy = _fuzzyCheckBox.Checked;
_config.UseLegacyMatch = _useLegacyCheckBox.Checked;
SaveSettingsInternal();
}
private void SaveSettingsInternal()
{
var configPath = Path.Combine(_mbApiInterface.Setting_GetPersistentStoragePath(), ConfigFilename);
var json = JsonConvert.SerializeObject(_config);
File.WriteAllText(configPath, json, Encoding.UTF8);
}
// MusicBee is closing the plugin (plugin is being disabled by user or MusicBee is shutting down)
[SuppressMessage("ReSharper", "UnusedMember.Global")]
[SuppressMessage("ReSharper", "UnusedParameter.Global")]
public void Close(PluginCloseReason reason)
{
}
// uninstall this plugin - clean up any persisted files
[SuppressMessage("ReSharper", "UnusedMember.Global")]
public void Uninstall()
{
var dataPath = _mbApiInterface.Setting_GetPersistentStoragePath();
var p = Path.Combine(dataPath, NoTranslateFilename);
if (File.Exists(p)) File.Delete(p);
var configPath = Path.Combine(_mbApiInterface.Setting_GetPersistentStoragePath(), ConfigFilename);
if (File.Exists(configPath)) File.Delete(configPath);
}
[SuppressMessage("ReSharper", "UnusedMember.Global")]
[SuppressMessage("ReSharper", "UnusedParameter.Global")]
public string RetrieveLyrics(string sourceFileUrl,
string artist, string trackTitle, string album,
bool synchronisedPreferred, string provider)
{
if (provider != ProviderName) return null;
var specifiedId = _mbApiInterface.Library_GetFileTag(sourceFileUrl, MetaDataType.Custom10)
?? _mbApiInterface.NowPlaying_GetFileTag(MetaDataType.Custom10);
var id = TryParseNeteaseUrl(specifiedId);
if (id == 0)
{
var realTitle = _mbApiInterface.Library_GetFileTag(sourceFileUrl, MetaDataType.TrackTitle);
var realArtist = _mbApiInterface.Library_GetFileTag(sourceFileUrl, MetaDataType.Artist);
var realAlbum = _mbApiInterface.Library_GetFileTag(sourceFileUrl, MetaDataType.Album);
var durationStr = _mbApiInterface.Library_GetFileProperty(sourceFileUrl, FilePropertyType.Duration);
id = !_config.UseLegacyMatch
? SearchMatch.SearchAndMatch(realTitle, realArtist, realAlbum, ParseDurationString(durationStr))
: SearchMatchLegacy.QueryWithFeatRemoved(realTitle, realArtist, _config.Fuzzy);
}
if (id == 0)
return null;
var lyricResult = NeteaseApi.RequestLyric(id);
if (lyricResult.lrc?.lyric == null) return null;
if (lyricResult.tlyric?.lyric == null || _config.Format == NeteaseConfig.OutputFormat.Original)
return lyricResult.lrc.lyric; // No need to process translation
if (_config.Format == NeteaseConfig.OutputFormat.Translation)
return lyricResult.tlyric?.lyric ?? lyricResult.lrc.lyric;
// translation
return LyricProcessor.InjectTranslation(lyricResult.lrc.lyric, lyricResult.tlyric.lyric);
}
private void ReadConfig()
{
var configPath = Path.Combine(_mbApiInterface.Setting_GetPersistentStoragePath(), ConfigFilename);
if (!File.Exists(configPath))
return;
try
{
_config = JsonConvert.DeserializeObject<NeteaseConfig>(File.ReadAllText(configPath, Encoding.UTF8));
}
catch (Exception ex)
{
_mbApiInterface.MB_Trace("[NeteaseMusic] Failed to load config" + ex);
}
}
private void MigrateLegacySetting()
{
var noTranslatePath = Path.Combine(_mbApiInterface.Setting_GetPersistentStoragePath(), NoTranslateFilename);
if (!File.Exists(noTranslatePath))
return;
File.Delete(noTranslatePath);
_config.Format = NeteaseConfig.OutputFormat.Original;
SaveSettingsInternal();
}
private static long TryParseNeteaseUrl(string input)
{
if (input == null)
return 0;
if (input.StartsWith("netease="))
{
input = input.Substring("netease=".Length);
long.TryParse(input, out var id);
return id;
}
if (!input.Contains("music.163.com"))
return 0;
var matches = Regex.Matches(input, "id=(\\d+)");
if (matches.Count <= 0)
return 0;
var groups = matches[0].Groups;
if (groups.Count <= 1)
return 0;
var idString = groups[1].Captures[0].Value;
long.TryParse(idString, out var id2);
return id2;
}
private static long ParseDurationString(string durationStr)
{
var multiplier = 1000L;
var sum = 0L;
foreach (var part in durationStr.Split(':').Reverse())
{
if (part.Length > 0)
sum += multiplier * long.Parse(part);
multiplier *= 60;
}
return sum;
}
[SuppressMessage("ReSharper", "UnusedMember.Global")]
public string[] GetProviders()
{
return new []{ProviderName};
}
[SuppressMessage("ReSharper", "UnusedMember.Global")]
public void ReceiveNotification(string sourceFileUrl, NotificationType type)
{
}
}
}
================================================
FILE: NeteaseLyrics.csproj
================================================
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{F5D46BA1-6F21-40EF-9695-46105CCACD08}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MusicBeePlugin</RootNamespace>
<AssemblyName>mb_NeteaseLyrics</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Costura, Version=3.2.2.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL">
<HintPath>packages\Costura.Fody.3.2.2\lib\net40\Costura.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Numerics" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="DataStucture.cs" />
<Compile Include="LyricProcessor.cs" />
<Compile Include="MusicBeeInterface.cs" />
<Compile Include="NeteaseLyrics.cs" />
<Compile Include="NeteaseApi.cs" />
<Compile Include="SearchMatch.cs" />
<Compile Include="SearchMatchLegacy.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<Compile Include="NeteaseMusicEncryptionHandler.cs" />
<None Include="LICENSE-Zony" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.0">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Costura.Fody">
<Version>6.0.0</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="F23.StringSimilarity">
<Version>6.0.0</Version>
</PackageReference>
<PackageReference Include="MSBuildTasks">
<Version>1.5.0.235</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>13.0.4</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="AfterBuild" Condition="'$(Configuration)'=='Release'">
<ItemGroup>
<ZipFiles Include="pkgtemp\" />
</ItemGroup>
<PropertyGroup>
<MyAssemblies>$(TargetPath)</MyAssemblies>
</PropertyGroup>
<GetAssemblyIdentity AssemblyFiles="$(MyAssemblies)">
<Output TaskParameter="Assemblies" ItemName="MyAssemblyIdentities" />
</GetAssemblyIdentity>
<RemoveDir Directories="@(ZipFiles)" />
<Copy SourceFiles="$(TargetPath)" DestinationFolder="pkgtemp\" />
<Zip ZipFileName="pkg\$(ProjectName)_%(MyAssemblyIdentities.Version).zip" WorkingDirectory="pkg" Files="@(ZipFiles)" Flatten="true" Quiet="true" />
<RemoveDir Directories="@(ZipFiles)" />
</Target>
</Project>
================================================
FILE: NeteaseLyrics.sln
================================================
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 18
VisualStudioVersion = 18.0.11111.16 d18.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NeteaseLyrics", "NeteaseLyrics.csproj", "{F5D46BA1-6F21-40EF-9695-46105CCACD08}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F5D46BA1-6F21-40EF-9695-46105CCACD08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F5D46BA1-6F21-40EF-9695-46105CCACD08}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F5D46BA1-6F21-40EF-9695-46105CCACD08}.Debug|x86.ActiveCfg = Debug|x86
{F5D46BA1-6F21-40EF-9695-46105CCACD08}.Debug|x86.Build.0 = Debug|x86
{F5D46BA1-6F21-40EF-9695-46105CCACD08}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F5D46BA1-6F21-40EF-9695-46105CCACD08}.Release|Any CPU.Build.0 = Release|Any CPU
{F5D46BA1-6F21-40EF-9695-46105CCACD08}.Release|x86.ActiveCfg = Release|x86
{F5D46BA1-6F21-40EF-9695-46105CCACD08}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
================================================
FILE: NeteaseMusicEncryptionHandler.cs
================================================
using System.IO;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography;
using System.Text;
using System;
namespace MusicBeePlugin
{
/*
* Adopted from https://github.com/real-zony/ZonyLrcToolsX/blob/dev/src/ZonyLrcTools.Common/Infrastructure/Encryption/NetEaseMusicEncryptionHelper.cs
* (MIT License)
* and https://github.com/jitwxs/163MusicLyrics/blob/master/MusicLyricApp/Api/Music/NetEaseMusicNativeApi.cs
* and https://github.com/mos9527/pyncm/blob/ad0a84b2ed5f1affa9890d5f54f6170c2cf99bbb/pyncm/utils/crypto.py#L53
*/
internal static class NeteaseMusicEncryptionHelper
{
private const string Modulus =
"00e0b509f6259df8642dbc35662901477df22677ec152b5ff68ace615bb7b725152b3ab17a876aea8a5aa76d2e417629ec4ee341f56135fccf695280104e0312ecbda92557c93870114af6c9d05c4f7f0c3685b7a46bee255932575cce10b424d813cfe4875d3e82047b97ddef52741d546b8e289dc6935b3ece0462db0a22b8e7";
internal const string Nonce = "0CoJUm6Qyw8W8jud";
private const string PubKey = "010001";
private const string Vi = "0102030405060708";
private static readonly byte[] ID_XOR_KEY_1 = Encoding.UTF8.GetBytes("3go8&$8*3*3h0k(2)2");
public static string RsaEncode(string text)
{
var srText = new string(text.Reverse().ToArray());
var a = BCHexDec(BitConverter.ToString(Encoding.Default.GetBytes(srText)).Replace("-", string.Empty));
var b = BCHexDec(PubKey);
var c = BCHexDec(Modulus);
var key = BigInteger.ModPow(a, b, c).ToString("x");
key = key.PadLeft(256, '0');
return key.Length > 256 ? key.Substring(key.Length - 256, 256) : key;
}
public static BigInteger BCHexDec(string hex)
{
var dec = new BigInteger(0);
var len = hex.Length;
for (var i = 0; i < len; i++)
{
dec += BigInteger.Multiply(new BigInteger(Convert.ToInt32(hex[i].ToString(), 16)),
BigInteger.Pow(new BigInteger(16), len - i - 1));
}
return dec;
}
public static string AesEncode(string secretData, string secret = "TA3YiYCfY2dDJQgg")
{
byte[] encrypted;
var iv = Encoding.UTF8.GetBytes(Vi);
using (var aes = Aes.Create())
{
aes.Key = Encoding.UTF8.GetBytes(secret);
aes.IV = iv;
aes.Mode = CipherMode.CBC;
using (var encryptor = aes.CreateEncryptor())
{
using (var stream = new MemoryStream())
{
using (var cryptoStream = new CryptoStream(stream, encryptor, CryptoStreamMode.Write))
{
using (var sw = new StreamWriter(cryptoStream))
{
sw.Write(secretData);
}
encrypted = stream.ToArray();
}
}
}
}
return Convert.ToBase64String(encrypted);
}
public static string CreateSecretKey(int length)
{
const string str = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var sb = new StringBuilder(length);
var rnd = new Random();
for (var i = 0; i < length; ++i)
{
sb.Append(str[rnd.Next(0, str.Length)]);
}
return sb.ToString();
}
public static string CloudMusicDllEncode(string deviceId)
{
var xored = new byte[deviceId.Length];
for (var i = 0; i < deviceId.Length; i++)
{
xored[i] = (byte)(deviceId[i] ^ ID_XOR_KEY_1[i % ID_XOR_KEY_1.Length]);
}
using (var md5 = MD5.Create())
{
var digest = md5.ComputeHash(xored);
return Convert.ToBase64String(digest);
}
}
}
}
================================================
FILE: Properties/AssemblyInfo.cs
================================================
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("NeteaseLyrics")]
[assembly: AssemblyDescription("A plugin to retrieve lyrics from Netease Cloud Music.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NeteaseLyrics")]
[assembly: AssemblyCopyright("Copyright © chariri 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("34d2725e-ae30-4f65-ad54-9eade3bb5973")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.9.0.0")]
[assembly: AssemblyFileVersion("1.9.0.0")]
================================================
FILE: README.MD
================================================
# Netease Lyric
This is another lyrics retrieval plugin for music player MusicBee. It can get **synchronized** lyrics from Netease Cloud Music(网易云音乐, a cloud music service in China).
It can combine the translation to the lyrics if available, like:
Blalalala(Original)
Alalalala(Translation)
is wrapped to: Blalalala/Alalalalala
etc..
But if you don't want this function you can disable it in plugin settings.
## Usage
To use this plugin, download it from links below:
For users who is not in China:
[OneDrive](https://1drv.ms/f/s!AicHZ6DLvCtX6Qp6KQfEppoQtjLG)
For users who is in China:
[BaiduYun](https://pan.baidu.com/s/1ZL9dyrAczhPSMvMtvvG5yA?pwd=vede) , passcode: `vede`
Install(via "Add plugin" button) and enable it in the `Plugin` tab in the preferences.
And adjust the retrieving provider priority of "Netease Cloud Music" in the Tags(2) Tab.
If you want a specific song's lyric from NetEase Cloud Music to be matched, you may set the `custom10` tag to the song URL like `https://music.163.com/#/song?id=29126914` (You can directly copy URL like this from the Netease website or client) or `netease=123123` (where "123123" should be your song id) in the music and re-search lyrics.
## For non-Chinese users
And this plugin is also useful for people who aren't from China as Netease CloudMusic also has bunch of songs in other languages. You can disable the translation in the plugin settings.
# 网易云音乐歌词
这是MusicBee另一个获取歌词的插件。可以从网易云音乐获取**同步歌词**。
该插件可以合并歌词翻译(如果有的话)到歌词。例如:
巴拉巴拉巴拉巴(原句)
阿啦啦啦啦啦(翻译)
会被合并为:巴拉巴拉巴拉巴/阿啦啦啦啦啦
如果不想要这个功能可以在设置里面的插件设置中关闭。
如果想设置网易云音乐中特定的歌曲,可以在 `标签 (2)` 标签页给歌曲设定 `custom10` 标签,内容为曲目的 URL,比如 `https://music.163.com/#/song?id=29126914`(可以直接从网易云网站或客户端复制下来),或者 `netease=123123`,其中 123123 是曲目的 ID,并重新搜索歌词。
## 使用
从[度盘](https://pan.baidu.com/s/1ZL9dyrAczhPSMvMtvvG5yA?pwd=vede)下载(提取码 `vede`),并在首选项的 `插件` 中安装(“添加插件”按钮)、启用插件,在 `标签 (2)` 标签页调整歌词的提供者优先级。
================================================
FILE: SearchMatch.cs
================================================
using F23.StringSimilarity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace MusicBeePlugin
{
internal static class SearchMatch
{
/// <summary>
/// 有多个 artist 时,分割各 artist 的符号。
/// 部分圈子的人喜欢用比较有个性的分割符,比如“ x ”,此事在《みんなみくみくにしてあげる♪》中亦有记载
/// </summary>
private static readonly string[] Delimiters = {"/", "&", ",", ",", " x ", " * ", "\u00d7", "\u00B7"};
private static readonly Regex FeatPatternWithoutParenthesis = new Regex(@"\s+feat(.+)");
private static readonly Regex FeatPatternWithParenthesis = new Regex(@"\s*\(feat(.+)\)");
public static long SearchAndMatch(string title, string artist, string album, long duration)
{
var (titleWithoutArtist, artists) = SplitTitleArtist(title, artist);
var artistsStr = string.Join(" ", artists);
var results = new HashSet<SearchResultSong>(new IdOnlyEqualityComparer());
results.UnionWith(NeteaseApi.Search(titleWithoutArtist));
results.UnionWith(NeteaseApi.Search($"{titleWithoutArtist} {artistsStr}"));
results.UnionWith(NeteaseApi.Search($"{titleWithoutArtist} {artistsStr} {album}"));
if (results.Count <= 0)
return 0;
var ranked = results.Select(it => (
rank: CalculateMatchScore(it, titleWithoutArtist, artistsStr, album, duration),
it.id, // prevent comparer from checking `song`, because SearchResultSong is not comparable.
song: it)
).ToList();
ranked.Sort();
return ranked.Max().song.id;
}
private static double CalculateMatchScore(
SearchResultSong song, string titleWithoutArtist, string artistsStr,
string album, long duration)
{
var resultArtists = song.artists.Select(it => it.name).ToList();
resultArtists.Sort();
var resultArtistsStr = string.Join(" ", resultArtists);
// “距离”公式:
// 歌曲长度距离^2 + 标题距离 * 2 + 表演者距离 * 0.7 + 专辑距离 * 1
// 因为长度是比较重要的 metrics,并且当长度差得超过一定距离的时候应该起到“一票否决”的效果,因此使用了平方
var l = new Levenshtein();
var durationDiff = (duration / 1000.0 - song.duration / 1000.0);
var score = -(durationDiff * durationDiff);
score -= l.Distance(titleWithoutArtist, song.name) * 2;
score -= l.Distance(artistsStr, resultArtistsStr) * 0.7;
score -= l.Distance(album, song.album.name);
return score;
}
/// <summary>
/// 有些人会把 (feat. Somebody) 这样的信息写在曲目标题里面,
/// 并且网易云不会做特殊处理(网易云本身支持多 artist),因此会搜出来一堆奇怪的结果。
/// 因此需要先把这些 feat. 的子句提出来放到 artist 里面。
/// 当然 Artist 里面的也需要处理
/// </summary>
/// <returns></returns>
public static (string, IEnumerable<string>) SplitTitleArtist(string title, string artist)
{
var (artistsWithoutFeat, featArtists) = ExtractFeat(SanitizeString(artist));
var artists = artistsWithoutFeat.Split(Delimiters, StringSplitOptions.RemoveEmptyEntries)
.Select(it => it.Trim())
.ToList();
artists.AddRange(featArtists);
var (titleWithoutFeat, featArtists2) = ExtractFeat(SanitizeString(title));
artists.AddRange(featArtists2);
artists.Sort();
return (titleWithoutFeat, artists);
}
private static string SanitizeString(string str)
{
return str.Replace('(', '(').Replace(')', ')').Replace('\u00A0', ' ');
}
private static (string, IEnumerable<string>) ExtractFeat(string str)
{
var match = FeatPatternWithParenthesis.Match(str);
if (!match.Success)
match = FeatPatternWithoutParenthesis.Match(str);
if (!match.Success) return (str, Enumerable.Empty<string>());
str = str.Remove(match.Index, match.Length).Trim();
if (match.Groups.Count <= 0) return (str, Enumerable.Empty<string>());
var featClause = match.Groups[1].Captures[0].Value;
featClause = featClause.TrimStart('.', ' ');
if (featClause.EndsWith(")"))
featClause = featClause.Substring(0, featClause.Length - 1);
return (str, featClause.Split(Delimiters, StringSplitOptions.RemoveEmptyEntries).Select(it => it.Trim()));
}
private class IdOnlyEqualityComparer : EqualityComparer<SearchResultSong>
{
public override bool Equals(SearchResultSong x, SearchResultSong y)
{
if (ReferenceEquals(x, y)) return true;
if (x is null) return false;
if (y is null) return false;
if (x.GetType() != y.GetType()) return false;
return x.id == y.id;
}
public override int GetHashCode(SearchResultSong obj)
{
return obj.id.GetHashCode();
}
}
}
}
================================================
FILE: SearchMatchLegacy.cs
================================================
using System;
using System.Linq;
using System.Text.RegularExpressions;
namespace MusicBeePlugin
{
/// <summary>
/// 旧的匹配设置
/// </summary>
internal static class SearchMatchLegacy
{
public static long QueryWithFeatRemoved(string trackTitle, string artist, bool fuzzy)
{
var ret = Query(trackTitle, artist, fuzzy);
if (ret != null) return ret.id;
ret = Query(RemoveLeadingNumber(RemoveFeat(trackTitle)), artist, fuzzy);
return ret?.id ?? 0;
}
private static SearchResultSong Query(string trackTitle, string artist, bool fuzzy)
{
var ret = NeteaseApi.Search(trackTitle + " " + artist)?.Where(rst =>
fuzzy || string.Equals(GetFirstSeq(RemoveLeadingNumber(rst.name)), GetFirstSeq(trackTitle),
StringComparison.OrdinalIgnoreCase)).ToList();
if (ret != null && ret.Count > 0) return ret[0];
ret = NeteaseApi.Search(trackTitle)?.Where(rst =>
fuzzy || string.Equals(GetFirstSeq(RemoveLeadingNumber(rst.name)), GetFirstSeq(trackTitle),
StringComparison.OrdinalIgnoreCase)).ToList();
return ret != null && ret.Count > 0 ? ret[0] : null;
}
private static string GetFirstSeq(string s)
{
s = s.Replace("\u00A0", " ");
var pos = s.IndexOf(' ');
return s.Substring(0, pos == -1 ? s.Length : pos).Trim();
}
private static string RemoveFeat(string name)
{
return Regex.Replace(name, @"\s*\(feat.+\)", "", RegexOptions.IgnoreCase);
}
private static string RemoveLeadingNumber(string name)
{
return Regex.Replace(name, @"^\d+\.?\s*", "", RegexOptions.IgnoreCase);
}
}
}
================================================
FILE: app.config
================================================
<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration>
================================================
FILE: packages.config
================================================
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Costura.Fody" version="3.2.2" targetFramework="net40" />
<package id="Fody" version="3.3.5" targetFramework="net40" developmentDependency="true" />
<package id="MSBuildTasks" version="1.5.0.235" targetFramework="net40" developmentDependency="true" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net40" />
</packages>
gitextract_nwibctos/ ├── .gitattributes ├── .gitignore ├── DataStucture.cs ├── FodyWeavers.xml ├── FodyWeavers.xsd ├── LICENSE ├── LICENSE-Zony ├── LyricProcessor.cs ├── MusicBeeInterface.cs ├── NeteaseApi.cs ├── NeteaseLyrics.cs ├── NeteaseLyrics.csproj ├── NeteaseLyrics.sln ├── NeteaseMusicEncryptionHandler.cs ├── Properties/ │ └── AssemblyInfo.cs ├── README.MD ├── SearchMatch.cs ├── SearchMatchLegacy.cs ├── app.config └── packages.config
SYMBOL INDEX (95 symbols across 8 files)
FILE: DataStucture.cs
class SearchResult (line 8) | internal class SearchResult
class SearchResultResult (line 14) | internal class SearchResultResult
class SearchResultSong (line 20) | internal class SearchResultSong
class SearchResultAlbum (line 29) | internal class SearchResultAlbum
class SearchResultArtist (line 35) | internal class SearchResultArtist
class LyricResult (line 41) | internal class LyricResult
class LyricInner (line 48) | internal class LyricInner
FILE: LyricProcessor.cs
class LyricProcessor (line 9) | [SuppressMessage("ReSharper", "InconsistentNaming")]
method InjectTranslation (line 13) | public static string InjectTranslation(string originalLrc, string tran...
method Parse (line 28) | private static List<LyricEntry> Parse(string lrc)
method ExpandEntries (line 43) | private static List<LyricEntry> ExpandEntries(List<LyricEntry> entries)
class LyricEntry (line 49) | [SuppressMessage("ReSharper", "InconsistentNaming")]
method LyricEntry (line 57) | public LyricEntry(string timeLabel, string content)
method ToString (line 63) | public override string ToString()
method ExpandTimeLabel (line 68) | public IEnumerable<LyricEntry> ExpandTimeLabel()
method CompareTo (line 75) | public int CompareTo(LyricEntry other)
FILE: MusicBeeInterface.cs
class Plugin (line 9) | [SuppressMessage("ReSharper", "InconsistentNaming")]
type MusicBeeApiInterface (line 16) | [StructLayout(LayoutKind.Sequential)]
method Initialise (line 19) | public void Initialise(IntPtr apiInterfacePtr)
type MusicBeeVersion (line 249) | public enum MusicBeeVersion
type PluginType (line 260) | public enum PluginType
class PluginInfo (line 277) | [StructLayout(LayoutKind.Sequential)]
type ReceiveNotificationFlags (line 295) | [Flags()]
type NotificationType (line 305) | public enum NotificationType
type PluginCloseReason (line 344) | public enum PluginCloseReason
type CallbackType (line 351) | public enum CallbackType
type FilePropertyType (line 370) | public enum FilePropertyType
type MetaDataType (line 391) | public enum MetaDataType
type FileCodec (line 468) | public enum FileCodec
type EncodeQuality (line 490) | public enum EncodeQuality
type LibraryCategory (line 498) | [Flags()]
type DeviceIdType (line 507) | public enum DeviceIdType
type DataType (line 515) | public enum DataType
type SettingId (line 523) | public enum SettingId
type ComparisonType (line 555) | public enum ComparisonType
type LyricsType (line 561) | public enum LyricsType
type PlayState (line 568) | public enum PlayState
type RepeatMode (line 577) | public enum RepeatMode
type PlayButtonType (line 584) | public enum PlayButtonType
type PlaylistFormat (line 592) | public enum PlaylistFormat
type SkinElement (line 608) | public enum SkinElement
type ElementState (line 616) | public enum ElementState
type ElementComponent (line 622) | public enum ElementComponent
type PluginPanelDock (line 629) | public enum PluginPanelDock
type ReplayGainMode (line 639) | public enum ReplayGainMode
type PlayStatisticType (line 647) | public enum PlayStatisticType
type Command (line 654) | public enum Command
type DownloadTarget (line 659) | public enum DownloadTarget
type PictureLocations (line 666) | [Flags()]
type WindowState (line 676) | public enum WindowState
method CopyMemory (line 825) | [System.Security.SuppressUnmanagedCodeSecurity()]
FILE: NeteaseApi.cs
class NeteaseApi (line 15) | internal static class NeteaseApi
method Search (line 17) | public static IEnumerable<SearchResultSong> Search(string s)
method RequestLyric (line 35) | public static LyricResult RequestLyric(long id)
method RequestNewApi (line 51) | private static T RequestNewApi<T>(string url, Dictionary<string, objec...
method EncryptRequest (line 82) | private static Dictionary<string, string> EncryptRequest(object srcPar...
method SearchLegacy (line 100) | private static IEnumerable<SearchResultSong> SearchLegacy(string s)
method RequestLyricLegacy (line 129) | private static LyricResult RequestLyricLegacy(long id)
FILE: NeteaseLyrics.cs
class NeteaseConfig (line 17) | public class NeteaseConfig
type OutputFormat (line 19) | public enum OutputFormat
class Plugin (line 31) | public partial class Plugin
method Initialise (line 44) | [SuppressMessage("ReSharper", "UnusedMember.Global")]
method Configure (line 70) | [SuppressMessage("ReSharper", "UnusedMember.Global")]
method SaveSettings (line 123) | [SuppressMessage("ReSharper", "UnusedMember.Global")]
method SaveSettingsInternal (line 135) | private void SaveSettingsInternal()
method Close (line 143) | [SuppressMessage("ReSharper", "UnusedMember.Global")]
method Uninstall (line 150) | [SuppressMessage("ReSharper", "UnusedMember.Global")]
method RetrieveLyrics (line 160) | [SuppressMessage("ReSharper", "UnusedMember.Global")]
method ReadConfig (line 198) | private void ReadConfig()
method MigrateLegacySetting (line 213) | private void MigrateLegacySetting()
method TryParseNeteaseUrl (line 223) | private static long TryParseNeteaseUrl(string input)
method ParseDurationString (line 250) | private static long ParseDurationString(string durationStr)
method GetProviders (line 263) | [SuppressMessage("ReSharper", "UnusedMember.Global")]
method ReceiveNotification (line 268) | [SuppressMessage("ReSharper", "UnusedMember.Global")]
FILE: NeteaseMusicEncryptionHandler.cs
class NeteaseMusicEncryptionHelper (line 16) | internal static class NeteaseMusicEncryptionHelper
method RsaEncode (line 26) | public static string RsaEncode(string text)
method BCHexDec (line 38) | public static BigInteger BCHexDec(string hex)
method AesEncode (line 52) | public static string AesEncode(string secretData, string secret = "TA3...
method CreateSecretKey (line 82) | public static string CreateSecretKey(int length)
method CloudMusicDllEncode (line 96) | public static string CloudMusicDllEncode(string deviceId)
FILE: SearchMatch.cs
class SearchMatch (line 9) | internal static class SearchMatch
method SearchAndMatch (line 19) | public static long SearchAndMatch(string title, string artist, string ...
method CalculateMatchScore (line 39) | private static double CalculateMatchScore(
method SplitTitleArtist (line 66) | public static (string, IEnumerable<string>) SplitTitleArtist(string ti...
method SanitizeString (line 82) | private static string SanitizeString(string str)
method ExtractFeat (line 87) | private static (string, IEnumerable<string>) ExtractFeat(string str)
class IdOnlyEqualityComparer (line 105) | private class IdOnlyEqualityComparer : EqualityComparer<SearchResultSong>
method Equals (line 107) | public override bool Equals(SearchResultSong x, SearchResultSong y)
method GetHashCode (line 116) | public override int GetHashCode(SearchResultSong obj)
FILE: SearchMatchLegacy.cs
class SearchMatchLegacy (line 10) | internal static class SearchMatchLegacy
method QueryWithFeatRemoved (line 12) | public static long QueryWithFeatRemoved(string trackTitle, string arti...
method Query (line 21) | private static SearchResultSong Query(string trackTitle, string artist...
method GetFirstSeq (line 34) | private static string GetFirstSeq(string s)
method RemoveFeat (line 41) | private static string RemoveFeat(string name)
method RemoveLeadingNumber (line 46) | private static string RemoveLeadingNumber(string name)
Condensed preview — 20 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (121K chars).
[
{
"path": ".gitattributes",
"chars": 2518,
"preview": "###############################################################################\n# Set default behavior to automatically "
},
{
"path": ".gitignore",
"chars": 4869,
"preview": "## Ignore Visual Studio temporary files, build results, and\n## files generated by popular Visual Studio add-ons.\n##\n## G"
},
{
"path": "DataStucture.cs",
"chars": 1040,
"preview": "using System.Collections.Generic;\n#pragma warning disable 649 // Suppresses: ___ is never assigned to\n\n// ReSharper dis"
},
{
"path": "FodyWeavers.xml",
"chars": 202,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Weavers xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSc"
},
{
"path": "FodyWeavers.xsd",
"chars": 10833,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\n <!-- This file was gen"
},
{
"path": "LICENSE",
"chars": 11357,
"preview": " Apache License\n Version 2.0, January 2004\n "
},
{
"path": "LICENSE-Zony",
"chars": 1142,
"preview": "[Included due to adoption of code from ZonyLrcToolsX in the Netease API part.]\n\nMIT License\n\nCopyright (c) 2019 Zony\n\nPe"
},
{
"path": "LyricProcessor.cs",
"chars": 2983,
"preview": "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System."
},
{
"path": "MusicBeeInterface.cs",
"chars": 39974,
"preview": "// WARNING: This file is NOT a part of my work and it's from downloaded MusicBee API source!!!\n\nusing System;\nusing Sys"
},
{
"path": "NeteaseApi.cs",
"chars": 6274,
"preview": "using Newtonsoft.Json;\nusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Linq;\nusi"
},
{
"path": "NeteaseLyrics.cs",
"chars": 11198,
"preview": "using System;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Drawing;\nusing System.Windows.Forms;\nusing System.IO;\n"
},
{
"path": "NeteaseLyrics.csproj",
"chars": 7008,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"12.0\" DefaultTargets=\"Build\" xmlns=\"http://schemas.micros"
},
{
"path": "NeteaseLyrics.sln",
"chars": 1331,
"preview": "\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio Version 18\nVisualStudioVersion = 18.0.1111"
},
{
"path": "NeteaseMusicEncryptionHandler.cs",
"chars": 4128,
"preview": "using System.IO;\nusing System.Linq;\nusing System.Numerics;\nusing System.Security.Cryptography;\nusing System.Text;\nusing "
},
{
"path": "Properties/AssemblyInfo.cs",
"chars": 1458,
"preview": "using System.Reflection;\nusing System.Runtime.CompilerServices;\nusing System.Runtime.InteropServices;\n\n// General Inform"
},
{
"path": "README.MD",
"chars": 1908,
"preview": "# Netease Lyric\n\nThis is another lyrics retrieval plugin for music player MusicBee. It can get **synchronized** lyrics f"
},
{
"path": "SearchMatch.cs",
"chars": 5138,
"preview": "using F23.StringSimilarity;\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text.Regular"
},
{
"path": "SearchMatchLegacy.cs",
"chars": 1829,
"preview": "using System;\nusing System.Linq;\nusing System.Text.RegularExpressions;\n\nnamespace MusicBeePlugin\n{\n /// <summary>\n "
},
{
"path": "app.config",
"chars": 142,
"preview": "<?xml version=\"1.0\"?>\n<configuration>\n\t<startup><supportedRuntime version=\"v4.0\" sku=\".NETFramework,Version=v4.8\"/></sta"
},
{
"path": "packages.config",
"chars": 408,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<packages>\n <package id=\"Costura.Fody\" version=\"3.2.2\" targetFramework=\"net40\" "
}
]
About this extraction
This page contains the full source code of the cqjjjzr/MusicBee-NeteaseLyrics GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 20 files (113.0 KB), approximately 25.5k tokens, and a symbol index with 95 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.