sandreas / tone

tone is a cross platform audio tagger and metadata editor to dump and modify metadata for a wide variety of formats, including mp3, m4b, flac and more. It has no dependencies and can be downloaded as single binary for Windows, macOS, Linux and other common platforms.
https://pilabor.com
Apache License 2.0
418 stars 17 forks source link

Some value of returned JSON are malformed #53

Closed markmccoid closed 4 months ago

markmccoid commented 1 year ago

I'm using Tone to read m4b and mp3 audiobook files and pull the metadata out.

First off, it is a truly awesome tool!!

However, I did find that most of the Description and Comments won't get past JavaScriptt's JSON.parse() .

This is because there are unescaped quotes as well as line returns. the line returns I can remove easily, but the embedded quotes are a bit more problematic.

This is the statement I'm using: tone dump "${pathPlusFilename}" --format json --exclude-property=description --exclude-property=comment --exclude-property=embeddedPictures

I'm excluding the keys that had the most issues.

Thanks for all your work on this project!!

sandreas commented 1 year ago

This is because there are unescaped quotes as well as line returns. the line returns I can remove easily, but the embedded quotes are a bit more problematic.

Thanks for reporting... this is strange, because I use JsonSerializer. Could you give me an example for a value that fails? Thank you.

euphoria0 commented 1 year ago

Similar case, that's why I'm commenting on this issue. Using tone-0.1.5-linux-x64, but similar behaviour was observed on windows as well. It seems like tone is inserting custom word breaks into the json output, for me it would insert a word break if the line would exceed 80 characters. Usually printing lines that exceed the consoles text width will wrap to the next line. I've encountered this issue wile working with an audiobook that contained a lengthy description / long chapter titles.

Example output:

tone dump file.mp3 --format json  > tone.json

[...]
    "additionalFields": {
      "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, 
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut etiam sit 
amet nisl purus in mollis nunc. Morbi quis commodo odio aenean sed adipiscing 
diam. Porta nibh venenatis cras sed felis eget velit aliquet. Urna et pharetra 
pharetra massa massa ultricies. In nisl nisi scelerisque eu ultrices vitae. Elit
at imperdiet dui accumsan sit amet. Massa tempor nec feugiat nisl pretium fusce 
id velit. Odio facilisis mauris sit amet massa. Mauris pellentesque pulvinar 
pellentesque habitant morbi tristique senectus. Quam lacus suspendisse faucibus 
interdum. Ultricies leo integer malesuada nunc vel risus commodo viverra. Etiam 
dignissim diam quis enim lobortis scelerisque. Quis enim lobortis scelerisque 
fermentum dui faucibus. Sodales ut etiam sit amet nisl purus. Ac tincidunt vitae
semper quis lectus. Et odio pellentesque diam volutpat commodo. Semper auctor 
neque vitae tempus quam pellentesque nec nam aliquam. Ut lectus arcu bibendum at
varius. Donec ac odio tempor orci dapibus ultrices in."
    }
[...]

How it should look like (more or less, console will wrap automatically):

cat test.json

[...]
    "additionalFields": {
      "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut etiam sit amet nisl purus in mollis nunc. Morbi quis commodo odio aenean sed adipiscing diam. Porta nibh venenatis cras sed felis eget velit aliquet. Urna et pharetra pharetra massa massa ultricies. In nisl nisi scelerisque eu ultrices vitae. Elit at imperdiet dui accumsan sit amet. Massa tempor nec feugiat nisl pretium fusce id velit. Odio facilisis mauris sit amet massa. Mauris pellentesque pulvinar pellentesque habitant morbi tristique senectus. Quam lacus suspendisse faucibus interdum. Ultricies leo integer malesuada nunc vel risus commodo viverra. Etiam dignissim diam quis enim lobortis scelerisque. Quis enim lobortis scelerisque fermentum dui faucibus. Sodales ut etiam sit amet nisl purus. Ac tincidunt vitae semper quis lectus. Et odio pellentesque diam volutpat commodo. Semper auctor neque vitae tempus quam pellentesque nec nam aliquam. Ut lectus arcu bibendum at varius. Donec ac odio tempor orci dapibus ultrices in."
}
[...]
sandreas commented 1 year ago

How it should look like (more or less, console will wrap automatically):

@euphoria0 This might be an issue with the Spectre.Console lib. Currently I'm busy with another project but in November I'll be able to fix some things. Sorry for the delay.

sandreas commented 4 months ago

@euphoria0 Since tone 0.1.6 there is an --export option to export into a file without output redirection. Should solve the problem. Feel free to reopen the issue, if the issue still exists.