animetosho / Nyuu

Flexible usenet binary posting tool
215 stars 30 forks source link

Errors with special spaces and other special characters in the filename using -i (--input-file) option #91

Closed df-a closed 2 years ago

df-a commented 2 years ago

Hi there,

I'm trying to automate nyuu as much as possible. I'm trying to feed it a list of file(path)s so that it can do its thing.

So for the command % nyuu -C ~/Desktop/nyuu-config.json -i list-of-files I keep getting the following error

[ERR ] Error: ENOENT: no such file or directory, stat '/Volumes/Orion/Uploads/FinnixOS.\(2019\).01x04.Linus.Thorvalds.Is.Our.God.CLI-TR.Jump.10bit.SWING.\ \[WE\ Rule\]/14dc61f23410ce8ac7ce7e23f1d33f47b2a43e3bb1b53ee7.7z.001'

But I also got that same error on another file in the list when it was in a different location

[ERR ] Error: ENOENT: no such file or directory, stat '/Volumes/Orion/Uploads\ Temp/I.Love.Pizza.S99E254.Hawaiian.Without.Pineapple.Is.Blasphemy.200000p-TheHUT/9f49b95ee39a174fa34fc94d393a8016d2a22bc300155ca8.7z.001'

As you can see, other than the space in the filepath, there are no other special characters in that fileset.

Once I changed that file from /Volumes/Orion/Uploads\ Temp to /Volumes/Orion/Uploads and regenerated the paths with a script, it worked without a hitch. It uploaded every single file correctly. It still wouldn't upload the files belonging to '/Volumes/Orion/Uploads/FinnixOS.\(2019\).01x04.Linus.Thorvalds.Is.Our.God.CLI-TR.Jump.10bit.SWING.\ \[WE\ Rule\]/14dc61f23410ce8ac7ce7e23f1d33f47b2a43e3bb1b53ee7.7z.001'.

If I drag and drop all the files that would fail (therefore not using the -i option) it works as expected.

Thing is, I sanitize the possible special characters in the paths to look just as if I dragged and dropped it into the terminal. I take away every special character such as `,(),[]` etc. using sed

sed -e 's/ /\\ /g' -e 's/\[/\\[/g' -e 's/\]/\\]/g' -e 's/(/\\(/g' -e 's/)/\\)/g'

And yet it will still give me the ENOENT error then the file with spaces, parenthesis and brackets in the filename is present.

In what way do I have to format the filepaths containing possible special characters so that nyuu accepts them?

df-a commented 2 years ago

File list needs no sanitation, so it only needs the absolute paths to the files you want to upload.

Nyuu adds ' to beginning and end of every path.

This was a case of overthinking on my part  ;)

Closing as it works.

animetosho commented 2 years ago

Nyuu adds ' to beginning and end of every path.

Technically that's not quite right, though I suppose you could think of it that way.

If it helps with understanding, the shell requires escaping because it does a bunch of expansion logic (and uses spaces to delimit arguments).
When Nyuu reads a list of files, it's not comming through a shell, so will take anything specified literally.

Glad it's figured out though.