Zeugma440 / atldotnet

Fully managed, portable and easy-to-use C# library to read and edit audio data and metadata (tags) from various audio formats, playlists and CUE sheets
MIT License
440 stars 60 forks source link

When LRC formatting fails, it results in other fields being incorrect. #268

Closed j4587698 closed 1 month ago

j4587698 commented 1 month ago

The problem

When the LRC lyrics format is incorrect, using UnsynchronizedLyrics to accept the value does not cause an error. Currently, I have some lyrics with an incorrect format, which is [00:00:00-1], and this leads to an error:

The input string '00-1' was not in a correct format.
   at System.Number.ThrowFormatException[TChar](ReadOnlySpan`1 value)
   at System.Int32.Parse(String s)
   at Commons.Utils.DecodeTimecodeToMs(String timeCode)
   at ATL.LyricsInfo.LyricsPhrase..ctor(String timestamp, String text)
   at ATL.LyricsInfo.ParseLRC(String data)
   at ATL.TagData.IntegrateValue(Field key, String value)
   at ATL.AudioData.IO.MetaDataIO.setMetaField(Field ID, String dataIn)
   at ATL.AudioData.IO.ID3v2.readFrame(BufferedBinaryReader source, TagInfo tag, ReadTagParams readTagParams, IList`1& comments, Boolean inChapter)
   at ATL.AudioData.IO.ID3v2.readFrames(BufferedBinaryReader source, TagInfo tag, Int64 offset, ReadTagParams readTagParams)
   at ATL.AudioData.IO.ID3v2.Read(Stream source, Int64 offset, ReadTagParams readTagParams)
   at ATL.AudioData.IO.ID3v2.read(Stream source, ReadTagParams readTagParams)
   at ATL.AudioData.IO.MetaDataIO.Read(Stream source, ReadTagParams readTagParams)
   at ATL.AudioData.AudioDataManager.read(Stream source, ReadTagParams readTagParams)
   at ATL.AudioData.AudioDataManager.read(Stream source, Boolean readEmbeddedPictures, Boolean readAllMetaFrames, Boolean prepareForWriting)
   at ATL.AudioData.AudioDataManager.ReadFromFile(Boolean readEmbeddedPictures, Boolean readAllMetaFrames)

However, the program does not crash; it only causes fields like Duration to be incorrect.

Environment

Details

Code To Reproduce Issue [ Good To Have ]

rack theTrack = new Track("test.mp3");

demo mp3 is: test.zip