philbot9/youtube-comment-scraper-cli

Video IDs starting with dash = 'unknown option' error

Closed this issue · 4 comments

Fantastic script!

Have been backing up my video comments with it and discovered that video IDs prefixed with a dash are mistaken as a group of short flag options and result in an error.

The command:
npx youtube-comment-scraper "-e5PICdUp44"

Results in the error message:
error: unknown option '-e'

Upon investigation I found that a solution is to add an option terminator:
npx youtube-comment-scraper -- "-e5PICdUp44"

Just wanted to note this here for anyone else writing scraper scripts like myself.

For future reference though, the culprit is in node_modules\commander\index.js in the Command.prototype.normalize function, where the short flag split occurs.

@BenjaminNelan Thanks, this is the expected behaviour and has been brought up before.

As per the POSIX specification, the double dash (--) terminates the list of command line options and needs to be used when command line arguments start with a dash. The quotes around the video ID are optional.

See #19

@philbot9 Ah nuts, I should've checked closed issues. Sorry for the repeat!

@philbot9 Why not adding this useful information in the file README.md? This will reduce future issues.

Good idea @quark67. Please feel free to submit a Pull Request to that effect.