Fix song names with invalid characters on online lounge and limit the new filename length to avoid failed downloads due to path_max exceeded
This commit is contained in:
parent
9bc9b1d465
commit
52a0680bfa
@ -110,6 +110,7 @@ namespace TJAPlayer3
|
||||
Menu_Title = TxC(@"Menu_Title.png");
|
||||
Menu_Highlight = TxC(@"Menu_Highlight.png");
|
||||
Enum_Song = TxC(@"Enum_Song.png");
|
||||
Loading = TxC(@"Loading.png");
|
||||
Scanning_Loudness = TxC(@"Scanning_Loudness.png");
|
||||
Overlay = TxC(@"Overlay.png");
|
||||
Network_Connection = TxC(@"Network_Connection.png");
|
||||
@ -1646,6 +1647,7 @@ namespace TJAPlayer3
|
||||
Menu_Title,
|
||||
Menu_Highlight,
|
||||
Enum_Song,
|
||||
Loading,
|
||||
Scanning_Loudness,
|
||||
NamePlateBase,
|
||||
Overlay,
|
||||
|
@ -529,6 +529,8 @@ namespace TJAPlayer3
|
||||
|
||||
else if (iCurrentMenu == 1)
|
||||
{
|
||||
//TJAPlayer3.Tx.Loading?.t2D描画(TJAPlayer3.app.Device, 18, 7);
|
||||
|
||||
// Reload character, a bit time expensive but with a O(N) memory complexity instead of O(N * M)
|
||||
TJAPlayer3.Tx.ReloadCharacter(TJAPlayer3.NamePlateConfig.data.Character[iPlayer], iCharacterCurrent, iPlayer);
|
||||
TJAPlayer3.NamePlateConfig.data.Character[iPlayer] = iCharacterCurrent;
|
||||
|
@ -456,7 +456,7 @@ namespace TJAPlayer3
|
||||
if (this.cdnSongListIndex < apiMethods.FetchedSongsList.Length)
|
||||
{
|
||||
var song = apiMethods.FetchedSongsList[this.cdnSongListIndex - 1];
|
||||
var zipPath = $@"Cache\{song.Md5}.zip";
|
||||
//var zipPath = $@"Cache\{song.Md5}.zip";
|
||||
var downloadLink = GetDownloadLink(song);
|
||||
|
||||
if (CSongDict.tContainsSongUrl(downloadLink))
|
||||
@ -532,6 +532,16 @@ namespace TJAPlayer3
|
||||
|
||||
#region [Song Downloading]
|
||||
|
||||
public string ReplaceInvalidChars(string filename, string substitute = "_")
|
||||
{
|
||||
return string.Join(substitute, filename.Split(Path.GetInvalidFileNameChars()));
|
||||
}
|
||||
|
||||
public string TruncateString(string s, int length)
|
||||
{
|
||||
return s.Substring(0, Math.Min(length, s.Length));
|
||||
}
|
||||
|
||||
private string GetAssignedLanguageValue(Dictionary<string, string> ens)
|
||||
{
|
||||
if (ens.ContainsKey(TJAPlayer3.ConfigIni.sLang))
|
||||
@ -551,8 +561,10 @@ namespace TJAPlayer3
|
||||
// Create Cache folder if does not exist
|
||||
Directory.CreateDirectory($@"Cache\");
|
||||
|
||||
|
||||
var song = apiMethods.FetchedSongsList[this.cdnSongListIndex - 1];
|
||||
var zipPath = $@"Cache\{song.SongTitle}-{song.Md5}.zip";
|
||||
var zipName = ReplaceInvalidChars($@"{TruncateString(song.SongTitle, 16)}-{TruncateString(song.Md5, 10)}");
|
||||
var zipPath = $@"Cache\{zipName}.zip";
|
||||
var downloadLink = GetDownloadLink(song);
|
||||
|
||||
try
|
||||
@ -633,7 +645,7 @@ namespace TJAPlayer3
|
||||
}
|
||||
|
||||
|
||||
var songPath = $@"{genredPath}{song.SongTitle}-{song.Md5}";
|
||||
var songPath = $@"{genredPath}{zipName}";
|
||||
|
||||
System.IO.Compression.ZipFile.ExtractToDirectory(zipPath, songPath);
|
||||
|
||||
|
BIN
Test/System/SimpleStyle/Graphics/Loading.png
Normal file
BIN
Test/System/SimpleStyle/Graphics/Loading.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
Loading…
Reference in New Issue
Block a user