Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some value of returned JSON are malformed #53

Closed
markmccoid opened this issue Sep 22, 2023 · 4 comments
Closed

Some value of returned JSON are malformed #53

markmccoid opened this issue Sep 22, 2023 · 4 comments

Comments

@markmccoid
Copy link

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
Copy link
Owner

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
Copy link

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
Copy link
Owner

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
Copy link
Owner

sandreas commented Jun 2, 2024

@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.

@sandreas sandreas closed this as completed Jun 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants