animetosho / Nyuu

Flexible usenet binary posting tool
221 stars 32 forks source link

Question regarding subject #111

Closed Ravencentric closed 1 year ago

Ravencentric commented 1 year ago

This isn't really an issue, just a question since I'm trying to understand it

The default subject is {comment} [{0filenum}/{files}] - "{filename}" yEnc ({part}/{parts}) {filesize} {comment2} according to help-full.txt

Are the double quotes around {filename} important? From what I've tested it's making no difference. My filename was helck - Copy.mkv.

Passing '[{0filenum}/{files}] - "{filename}" yEnc ({part}/{parts}) {filesize}' gets me [1/7] - helck - Copy.mkv yEnc (1/483) 346054287 Passing "[{0filenum}/{files}] - {filename} yEnc ({part}/{parts}) {filesize}" also gets me [1/7] - helck - Copy.mkv yEnc (1/483) 346054287

Am I missing something? or not understanding it?

animetosho commented 1 year ago

Are the double quotes around {filename} important?

It is the suggested subject format in the yEnc spec. The double quotes helps with filenames containing spaces (like in your example).

Passing '[{0filenum}/{files}] - "{filename}" yEnc ({part}/{parts}) {filesize}' gets me [1/7] - helck - Copy.mkv yEnc (1/483) 346054287

I am not reproducing this. Are you sure that, however you're checking this, the viewer isn't stripping the quotes out?
If so, if you could provide a full command that can reproduce your issue, I can try to do so myself.

Ravencentric commented 1 year ago

Using the git master build

Test 1: http://al.howardknight.net/?STYPE=msgid&MSGI=%3CFdFtLlEvQzSbVzEpQiBpCcSb-1691582951579@nyuu%3E CLI: nyuu -C account.json --subject "[{0filenum}/{files}] - "{filename}" yEnc ({part}/{parts}) {filesize}" --nzb-subject "[{0filenum}/{files}] - "{filename}" yEnc ({part}/{parts}) {filesize}" --yenc-name "[{0filenum}/{files}] - "{filename}" yEnc ({part}/{parts}) {filesize}" -o "helck - Copy.nzb" "helck - Copy" Inside the NZB file itself: <file poster="zonYWuNFs2@jahhk.ZXv" date="1691582951" subject="[1/7] - helck - Copy.mkv yEnc (1/483) 346054287">

Test 2: http://al.howardknight.net/?STYPE=msgid&MSGI=%3CPpIuSiLsJmRlUsQbKuViHyBp-1691583252239@nyuu%3E CLI: nyuu -C account.json --subject "[{0filenum}/{files}] - {filename} yEnc ({part}/{parts}) {filesize}" --nzb-subject "[{0filenum}/{files}] - {file name} yEnc ({part}/{parts}) {filesize}" --yenc-name "[{0filenum}/{files}] - {filename} yEnc ({part}/{parts}) {filesize}" -o "helck - Copy2.nzb" "helck - Copy" Inside the NZB file itself: <file poster="BWrLgg1b37@jtTpr.I7H" date="1691583252" subject="[1/7] - helck - Copy.mkv yEnc (1/483) 346054287">

helck - Copy.nzb.txt helck - Copy2.nzb.txt

animetosho commented 1 year ago

If you're running that verbatim from a bash shell or similar, you may need to escape the double quotes (or enclose the subject in single quotes).

$ echo "abc "def" ghi"
abc def ghi
$ echo 'abc "def" ghi'
abc "def" ghi
$ echo "abc \"def\" ghi"
abc "def" ghi
Ravencentric commented 1 year ago

I'm using the commands stated in my post verbatim in Windows Terminal. Echo behaves differently on Windows so I can't test it via echo

> echo '[{0filenum}/{files}] - "{filename}" yEnc ({part}/{parts}) {filesize}'
'[{0filenum}/{files}] - "{filename}" yEnc ({part}/{parts}) {filesize}'

> echo [{0filenum}/{files}] - "{filename}" yEnc ({part}/{parts}) {filesize}
[{0filenum}/{files}] - "{filename}" yEnc ({part}/{parts}) {filesize}

> echo "[{0filenum}/{files}] - "{filename}" yEnc ({part}/{parts}) {filesize}"
"[{0filenum}/{files}] - "{filename}" yEnc ({part}/{parts}) {filesize}"

> echo "[{0filenum}/{files}] - \"{filename}\" yEnc ({part}/{parts}) {filesize}"
"[{0filenum}/{files}] - \"{filename}\" yEnc ({part}/{parts}) {filesize}"

Test 3: Using \ to escape http://al.howardknight.net/?STYPE=msgid&MSGI=%3CKcXwMzCrNiCyGdAwKyHpMbLy-1691584952793@nyuu%3E CLI: nyuu -C account.json --subject "[{0filenum}/{files}] - \"{filename}\" yEnc ({part}/{parts}) {filesize}" --nzb-subject "[{0filenum}/{files}] - \"{filename}\" yEnc ({part}/{parts}) {filesize}" --yenc-name "[{0filenum}/{files}] - \"{filename}\" yEnc ({part}/{parts}) {filesize}" -o "helck - Copy3.nzb" "helck - Copy" Inside the NZB file itself: <file poster="phB31AKX5k@WYjhO.Ubh" date="1691584952" subject="[1/7] - &quot;helck - Copy.mkv&quot; yEnc (1/483) 346054287">

Test 4: Using surrounding the parameter in single quotes with {filename} in double quotes nyuu -C account.json --subject '[{0filenum}/{files}] - "{filename}" yEnc ({part}/{parts}) {filesize}' --nzb-subject '[{0filenum}/{files}] - "{filename}" yEnc ({part}/{parts}) {filesize}' --yenc-name '[{0filenum}/{files}] - "{filename}" yEnc ({part}/{parts}) {filesize}' -o "helck - Copy4.nzb" "helck - Copy"

[2023-08-09 18:19:17.355][ERR ] Error: ENOENT: no such file or directory, stat 'C:\Users\user\Downloads\nyuu-master-win32.7z\{filename}'

helck - Copy3.nzb.txt

animetosho commented 1 year ago

Your test 3 looks correct.

On Windows, quotes can be escaped with \ or doubling the quotes ("" or \" -> ").

Ravencentric commented 1 year ago

Hmm I see, but what about the --nzb-subject? Since that's resulting in <file poster="phB31AKX5k@WYjhO.Ubh" date="1691584952" subject="[1/7] - &quot;helck - Copy.mkv&quot; yEnc (1/483) 346054287"> Is this correct and how it's supposed to be?

animetosho commented 1 year ago

Yes.

Read this if you're confused: https://stackoverflow.com/questions/1091945/what-characters-do-i-need-to-escape-in-xml-documents

Ravencentric commented 1 year ago

Okay, I understand now. Thank you for being patient with me!