philbot9 / youtube-comment-scraper-cli

Command line utility for scraping YouTube comments.
ISC License
80 stars 19 forks source link

Video IDs starting with dash = 'unknown option' error #29

Closed BenjaminNelan closed 4 years ago

BenjaminNelan commented 4 years ago

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.

philbot9 commented 4 years ago

@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 https://github.com/philbot9/youtube-comment-scraper-cli/issues/19

BenjaminNelan commented 4 years ago

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

quark67 commented 4 years ago

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

philbot9 commented 4 years ago

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