Skip to content

[BUG] Argparse interprets video IDs starting with - as options in CLI; propose quoted string workaround or better solution #5

@vabe44

Description

@vabe44

CLI: Video IDs starting with - are interpreted as options, causing errors

Description

When using the from_video_ids command, if any video ID starts with a dash (-), argparse interprets it as an option/flag, resulting in an error like:

ytfetcher: error: unrecognized arguments: -WwShcgXz08 ...

Current workaround

A possible workaround is to pass the video IDs as a single quoted string with the -v option, for example:

ytfetcher from_video_ids ... -v "OjooPjtlSr0 ... -WwShcgXz08 ..."

and then split the string in the code.

and then split the string in the code.

Proposal

Update the CLI to accept a single quoted string for video IDs and split it internally, so users can include IDs starting with - without special handling.

I have implemented this quoted string change locally and can create a pull request if this solution is acceptable.

Open question

Is this the best solution, or is there a more argparse-native way to allow a list of values (some starting with -) without requiring quoting or --? Feedback and alternative suggestions are welcome!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions