Skip to content

Commit

Permalink
Merge pull request #19 from Initial-heart-1/master
Browse files Browse the repository at this point in the history
fix 网易云对API访问的限速导致的半失效
  • Loading branch information
ludoux authored Nov 28, 2022
2 parents d2304b4 + 4f4564a commit 50d5967
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 118 deletions.
2 changes: 1 addition & 1 deletion LrcHelper/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
</configuration>
238 changes: 130 additions & 108 deletions LrcHelper/LrcDownloader.Designer.cs

Large diffs are not rendered by default.

19 changes: 17 additions & 2 deletions LrcHelper/LrcDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ private void GETbutton_Click(object sender, EventArgs e)
private string DownloadLrc(string folderPath, string filenamePatern, Music music, int ModeIIndex, int DelayMsc, out LyricsStatus status,out string filePath, string fileEncoding = "UTF-8",string revisedsContentOriLyricsForUserReviseFunc = null, string revisedsContentTransLyricsForUserReviseFunc = null)
{
ExtendedLyrics l = new ExtendedLyrics(music.ID);
l.FetchOnlineLyrics(revisedsContentOriLyricsForUserReviseFunc, revisedsContentTransLyricsForUserReviseFunc);
l.FetchOnlineLyrics(revisedsContentOriLyricsForUserReviseFunc, revisedsContentTransLyricsForUserReviseFunc, LowDelaycheckBox.Checked);
string lyricText = l.GetCustomLyric(ModeIIndex, DelayMsc);
filePath = "";
if (lyricText != "")
Expand Down Expand Up @@ -322,7 +322,7 @@ private void Savelabel_Click(object sender, EventArgs e)
{
try
{
File.WriteAllText(".\\AdvancedSettings.txt", string.Format("Version:{0}\r\nTime:{1}\r\nLyricsStyle:{2}\r\nDelayMsec:{3}\r\nFilenamePattern:{4}\r\nEncoding:{5}\r\nCookie:{6}\r\n***DO NOT CHANGE ANY TEXT AND/OR ENCODING***\r\n***If you don't want to use these settings ever, just delete this file.***", FileVersionInfo.GetVersionInfo(Application.ExecutablePath).FileVersion, DateTime.Now.ToString(), LyricsStylenumericUpDown.Value.ToString(), DelayMsecnumericUpDown.Value.ToString(), FilenamePatterncomboBox.Text, EncodingcomboBox.Text,CookietextBox.Text), Encoding.UTF8);
File.WriteAllText(".\\AdvancedSettings.txt", string.Format("Version:{0}\r\nTime:{1}\r\nLyricsStyle:{2}\r\nDelayMsec:{3}\r\nFilenamePattern:{4}\r\nEncoding:{5}\r\nCookie:{6}\r\nLowDelay:{7}\r\n***DO NOT CHANGE ANY TEXT AND/OR ENCODING***\r\n***If you don't want to use these settings ever, just delete this file.***", FileVersionInfo.GetVersionInfo(Application.ExecutablePath).FileVersion, DateTime.Now.ToString(), LyricsStylenumericUpDown.Value.ToString(), DelayMsecnumericUpDown.Value.ToString(), FilenamePatterncomboBox.Text, EncodingcomboBox.Text,CookietextBox.Text, LowDelaycheckBox.Checked), Encoding.UTF8);
}
catch (Exception)
{
Expand All @@ -343,6 +343,7 @@ private void LrcDownloader_Load(object sender, EventArgs e)
FilenamePatterncomboBox.Text = Regex.Match(settings, @"(?<=FilenamePattern:).+?(?=\r\n)", RegexOptions.IgnoreCase).Value.ToString();
EncodingcomboBox.Text = Regex.Match(settings, @"(?<=Encoding:).+?(?=\r\n)", RegexOptions.IgnoreCase).Value.ToString();
CookietextBox.Text = Regex.Match(settings, @"(?<=Cookie:).+?(?=\r\n)", RegexOptions.IgnoreCase).Value.ToString();
LowDelaycheckBox.Checked = Convert.ToBoolean(Regex.Match(settings, @"(?<=LowDelay:).+?(?=\r\n)", RegexOptions.IgnoreCase).Value.ToString());
}
}

Expand All @@ -351,5 +352,19 @@ private void StatusInfolabel_MouseHover(object sender, EventArgs e)
toolTip1.SetToolTip(StatusInfolabel, StatusInfolabel.Text);//防止label显示不完文本,专门浮动出来
}

private void AdvancedSettingsgroupBox_Enter(object sender, EventArgs e)
{

}

private void ReviseRawcheckBox_CheckedChanged(object sender, EventArgs e)
{

}

private void LowDelaycheckBox_CheckedChanged(object sender, EventArgs e)
{

}
}
}
2 changes: 1 addition & 1 deletion LrcHelper/LrcHelper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>LrcHelper</RootNamespace>
<AssemblyName>163lrc</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<IsWebBootstrapper>false</IsWebBootstrapper>
Expand Down
12 changes: 10 additions & 2 deletions LrcHelper/NeteaseMusic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using ludoux.LrcHelper.SharedFramework;
using System.ComponentModel;
using Newtonsoft.Json;
using System.Threading;

namespace ludoux.LrcHelper.NeteaseMusic
{
Expand Down Expand Up @@ -69,7 +70,7 @@ public ExtendedLyrics(long ID)
/// 从云端取得该对象的歌词信息并记录
/// </summary>
/// <param name="userReviseFunc">用户是否介入修改 sContent,当软件自动下载歌词报错后,才应该在启用此选项</param>
internal void FetchOnlineLyrics(string revisedsContentOriLyricsForUserReviseFunc, string revisedsContentTransLyricsForUserReviseFunc)
internal void FetchOnlineLyrics(string revisedsContentOriLyricsForUserReviseFunc, string revisedsContentTransLyricsForUserReviseFunc, bool LowDelaycheckBoxChecked)
{
bool userReviseFunc = false;
if (revisedsContentOriLyricsForUserReviseFunc != null)
Expand All @@ -84,6 +85,7 @@ internal void FetchOnlineLyrics(string revisedsContentOriLyricsForUserReviseFunc

try
{
Start:
sContent = hr.GetContent("https://music.163.com/api/song/detail/?id=" + id + "&ids=[" + id + "]");//这个是仅对确定歌词状态有用的
if (Regex.IsMatch(sContent, @"^{""songs"":\[]") || Regex.IsMatch(sContent, @"^{""code"":400"))
{ ErrorLog += "<STATUS_ERR>"; Status = LyricsStatus.ERROR; return; }
Expand All @@ -106,7 +108,13 @@ internal void FetchOnlineLyrics(string revisedsContentOriLyricsForUserReviseFunc
sContent = revisedsContentOriLyricsForUserReviseFunc;

if (!Regex.IsMatch(sContent, @"""lyric"""))
{ ErrorLog += "<NO_LYRIC_LABEL>"; return; }
if (Regex.IsMatch(sContent, @"""操作频繁,请稍候再试"""))
if (!LowDelaycheckBoxChecked)
{ Thread.Sleep(10000);goto Start; }
else
{ Thread.Sleep(500); goto Start; }
else
{ ErrorLog += "<NO_LYRIC_LABEL>"; return; }
sLRC = Regex.Match(sContent, @"(?<=""lyric"":"").*?(?="",""code)").Value;
tempOriLyric.ArrangeLyrics(sLRC);
hasOriLyrics = true;
Expand Down
6 changes: 3 additions & 3 deletions LrcHelper/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion LrcHelper/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 50d5967

Please sign in to comment.