Skip to content

Commit

Permalink
Merge pull request #232 from jitwxs/dev
Browse files Browse the repository at this point in the history
Release v6.5
  • Loading branch information
jitwxs authored Dec 29, 2024
2 parents 3b016fd + ceb60ba commit 1cdc5b8
Show file tree
Hide file tree
Showing 23 changed files with 435 additions and 191 deletions.
22 changes: 18 additions & 4 deletions MusicLyricApp/Api/Music/NetEaseMusicApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,24 @@ protected override ResultVo<PlaylistVo> GetPlaylistVo0(string playlistId)

if (resp.Code == 200)
{
// cache song
GlobalCache.DoCache(Source(), CacheType.NET_EASE_SONG, value => value.Id, resp.Playlist.Tracks);
var songIds = resp.Playlist.TrackIds.Select(e => e.Id.ToString()).ToArray();

return new ResultVo<PlaylistVo>(resp.Convert());
SimpleSongVo[] simpleSongVos;
if (songIds.Length > 0)
{
simpleSongVos = new SimpleSongVo[songIds.Length];
var songVo = GetSongVo0(songIds);
for (var i = 0; i < songIds.Length; i++)
{
simpleSongVos[i] = songVo[songIds[i]].Data;
}
}
else
{
simpleSongVos = Array.Empty<SimpleSongVo>();
}

return new ResultVo<PlaylistVo>(resp.Convert(simpleSongVos));
}
else if (resp.Code == 20001)
{
Expand Down Expand Up @@ -88,7 +102,7 @@ protected override Dictionary<string, ResultVo<SongVo>> GetSongVo0(string[] song
DisplayId = songId,
Pics = song.Al.PicUrl,
Name = song.Name,
Singer = string.Join(",", song.Ar.Select(e => e.Name)),
Singer = song.Ar.Select(e => e.Name).ToArray(),
Album = song.Al.Name,
Duration = song.Dt
});
Expand Down
2 changes: 1 addition & 1 deletion MusicLyricApp/Api/Music/QQMusicApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected override Dictionary<string, ResultVo<SongVo>> GetSongVo0(string[] song
Pics = $"https://y.qq.com/music/photo_new/T002R800x800M000{songRes.Data.Album.Pmid}.jpg",
// #212 QQ music need use title attribute as song name
Name = GlobalUtils.GetOrDefault(songRes.Data.Title, songRes.Data.Name),
Singer = string.Join(",", songRes.Data.Singer.Select(e => e.Name)),
Singer = songRes.Data.Singer.Select(e => e.Name).ToArray(),
Album = songRes.Data.Album.Name,
Duration = songRes.Data.Interval * 1000
});
Expand Down
2 changes: 1 addition & 1 deletion MusicLyricApp/Bean/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace MusicLyricApp.Bean
{
public static class Constants
{
public const string Version = "v6.4";
public const string Version = "v6.5";

public static readonly string SettingPath = Environment.CurrentDirectory + "\\MusicLyricAppSetting.json";

Expand Down
2 changes: 1 addition & 1 deletion MusicLyricApp/Bean/MusicLyricsVO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public class SimpleSongVo
/// <summary>
/// 歌手名
/// </summary>
public string Singer { get; set; }
public string[] Singer { get; set; }
}

/// <summary>
Expand Down
35 changes: 23 additions & 12 deletions MusicLyricApp/Bean/NetEaseMusicBean.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,15 @@ public class PlaylistResult
/// </summary>
public Privilege[] Privileges { get; set; }

public PlaylistVo Convert()
public PlaylistVo Convert(SimpleSongVo[] simpleSongVos)
{
var creator = Playlist.Creator;
return new PlaylistVo
{
Name = Playlist.Name,
AuthorName = Playlist.Creator.Nickname,
AuthorName = creator == null ? "" : creator.Nickname,
Description = Playlist.Description,
SimpleSongVos = Playlist.Tracks.Select(e => e.ConvertSimple()).ToArray()
SimpleSongVos = simpleSongVos
};
}
}
Expand Down Expand Up @@ -276,6 +277,16 @@ public class SimplePlaylist
/// </summary>
public class Playlist : SimplePlaylist
{
/// <summary>
/// 歌单名
/// </summary>
public string Name { get; set; }

/// <summary>
/// 歌单创建者
/// </summary>
public Creator Creator { get; set; }

/// <summary>
/// 歌单封面 ID
/// </summary>
Expand All @@ -286,8 +297,6 @@ public class Playlist : SimplePlaylist
/// </summary>
public long CreateTime { get; set; }

public int Status { get; set; }

/// <summary>
/// 订阅数量
/// </summary>
Expand All @@ -303,15 +312,17 @@ public class Playlist : SimplePlaylist
/// </summary>
public long CommentCount { get; set; }

/// <summary>
/// 歌单标签
/// </summary>
public string[] Tags { get; set; }

/// <summary>
/// 歌单歌曲列表信息
/// </summary>
public Song[] Tracks { get; set; }
public SimpleTrack[] TrackIds { get; set; }
}

public class SimpleTrack
{
public long Id { get; set; }

public long Uid { get; set; }
}

/// <summary>
Expand Down Expand Up @@ -396,7 +407,7 @@ public SimpleSongVo ConvertSimple()
Id = Id,
DisplayId = Id,
Name = Name,
Singer = string.Join(",", Ar.Select(e => e.Name))
Singer = Ar.Select(e => e.Name).ToArray()
};
}
}
Expand Down
4 changes: 2 additions & 2 deletions MusicLyricApp/Bean/QQMusicBean.cs
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ public SimpleSongVo ConvertSimple()
Id = Id,
DisplayId = Mid,
Name = Name,
Singer = string.Join(",", Singer.Select(e => e.Name))
Singer = Singer.Select(e => e.Name).ToArray()
};
}
}
Expand Down Expand Up @@ -560,7 +560,7 @@ public SimpleSongVo ConvertSimple()
Id = Songid.ToString(),
DisplayId = Songmid,
Name = Songname,
Singer = string.Join(",", singer.Select(e => e.Name))
Singer = singer.Select(e => e.Name).ToArray()
};
}
}
Expand Down
78 changes: 78 additions & 0 deletions MusicLyricApp/Bean/ScalingFormConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
using System;
using System.Drawing;
using System.Windows.Forms;

namespace MusicLyricApp.Bean
{
public class ScalingFormConfig
{
/// <summary>
/// 定义当前窗体的宽度
/// </summary>
public float X;

/// <summary>
/// 定义当前窗体的高度
/// </summary>
public float Y;

public ScalingFormConfig(Control cons)
{
X = cons.Width;
Y = cons.Height;

SetTag(cons);
}

public void SetControls(Control cons)
{
var newX = cons.Width / X; //获取当前宽度与初始宽度的比例
var newY = cons.Height / Y; //获取当前高度与初始高度的比例
SetControls(newX, newY, cons);
}

private static void SetControls(float newx, float newy, Control cons)
{
//遍历窗体中的控件,重新设置控件的值
foreach(Control con in cons.Controls)
{
//获取控件的Tag属性值,并分割后存储字符串数组
if(con.Tag != null)
{
var mytag = con.Tag.ToString().Split(';');

//根据窗体缩放的比例确定控件的值
con.Width = Convert.ToInt32(Convert.ToSingle(mytag[0]) * newx); //宽度
con.Height = Convert.ToInt32(Convert.ToSingle(mytag[1]) * newy); //高度
con.Left = Convert.ToInt32(Convert.ToSingle(mytag[2]) * newx); //左边距
con.Top = Convert.ToInt32(Convert.ToSingle(mytag[3]) * newy); //顶边距

var currentSize = Convert.ToSingle(mytag[4]) * newy; //字体大小
con.Font = new Font(con.Font.Name, currentSize, con.Font.Style, con.Font.Unit);

if(con.Controls.Count > 0)
{
SetControls(newx, newy, con);
}
}
}
}

/// <summary>
/// 控件大小随窗体大小等比例缩放,
/// 在窗体重载中使用
/// </summary>
/// <param name="cons"></param>
private static void SetTag(Control cons)
{
foreach(Control con in cons.Controls)
{
con.Tag = con.Width + ";" + con.Height + ";" + con.Left + ";" + con.Top + ";" + con.Font.Size;
if(con.Controls.Count > 0)
{
SetTag(con);
}
}
}
}
}
55 changes: 30 additions & 25 deletions MusicLyricApp/Bean/SettingBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,36 @@ public class SettingBean

public class ConfigBean
{
/// <summary>
/// LRC 歌词时间戳格式
/// </summary>
public string LrcTimestampFormat = "[mm:ss.SSS]";

/// <summary>
/// SRT 歌词时间戳格式
/// </summary>
public string SrtTimestampFormat = "HH:mm:ss,SSS";

/// <summary>
/// 启用逐字歌词模式
/// </summary>
public bool EnableVerbatimLyric = false;

/// <summary>
/// 忽略空的歌词行
/// </summary>
public bool IgnoreEmptyLyric = true;

/// <summary>
/// 小数位处理策略
/// </summary>
public DotTypeEnum DotType = DotTypeEnum.DOWN;

/// <summary>
/// 多个歌手的分隔符
/// </summary>
public string SingerSeparator = ",";

/// <summary>
/// 参数记忆
/// </summary>
Expand Down Expand Up @@ -132,31 +162,6 @@ public class PersistParamBean
/// 指定歌词合并的分隔符
/// </summary>
public string LrcMergeSeparator = string.Empty;

/// <summary>
/// LRC 歌词时间戳格式
/// </summary>
public string LrcTimestampFormat = "[mm:ss.SSS]";

/// <summary>
/// SRT 歌词时间戳格式
/// </summary>
public string SrtTimestampFormat = "HH:mm:ss,SSS";

/// <summary>
/// 启用逐字歌词模式
/// </summary>
public bool EnableVerbatimLyric = false;

/// <summary>
/// 忽略空的歌词行
/// </summary>
public bool IgnoreEmptyLyric = true;

/// <summary>
/// 小数位处理策略
/// </summary>
public DotTypeEnum DotType = DotTypeEnum.DOWN;

/// <summary>
/// 输出文件格式
Expand Down
4 changes: 3 additions & 1 deletion MusicLyricApp/MainForm.Designer.cs

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

Loading

0 comments on commit 1cdc5b8

Please sign in to comment.