Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Filename string after --output cannot begin with dash(-) due to mis-interpretated as option #236

Open
teadrinker2015 opened this issue Jan 19, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@teadrinker2015
Copy link

teadrinker2015 commented Jan 19, 2024

Basic information

  • Program version: 0.2.8
  • Python version: Python 3.10.8
  • Operating system: Windows 10 22H2

Describe the bug

Filename string after --output cannot begin with dash(-) due to mis-interpretated as option.

Command/Code used

If running from the command line, provide the following:

  1. The command used (including the verbose tag, -v):
chat_downloader https://www.youtube.com/watch?v=-ZLltnPt5WM -o '-ZLltnPt5WM.json' -q
  1. Output from the above command:
usage: chat_downloader [-h] [--version] [--start_time START_TIME] [--end_time END_TIME]
                       [--message_types MESSAGE_TYPES | --message_groups MESSAGE_GROUPS] [--max_attempts MAX_ATTEMPTS]
                       [--retry_timeout RETRY_TIMEOUT] [--interruptible_retry [INTERRUPTIBLE_RETRY]]
                       [--max_messages MAX_MESSAGES] [--inactivity_timeout INACTIVITY_TIMEOUT] [--timeout TIMEOUT]
                       [--format FORMAT] [--format_file FORMAT_FILE] [--chat_type {live,top}] [--ignore IGNORE]
                       [--message_receive_timeout MESSAGE_RECEIVE_TIMEOUT] [--buffer_size BUFFER_SIZE]
                       [--output OUTPUT] [--overwrite [OVERWRITE]] [--sort_keys [SORT_KEYS]] [--indent INDENT]
                       [--pause_on_debug | --exit_on_debug]
                       [--logging {none,debug,info,warning,error,critical} | --testing | --verbose | --quiet]
                       [--cookies COOKIES] [--proxy PROXY]
                       url
chat_downloader: error: argument --output/-o: expected one argument

Expected behavior

silently exits (success)

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context/information

Add any other context or information about the problem here.

@teadrinker2015 teadrinker2015 added the bug Something isn't working label Jan 19, 2024
@xenova
Copy link
Owner

xenova commented Jan 19, 2024

Can you try surrounding the arguments with double quotes? e.g.,

chat_downloader "https://www.youtube.com/watch?v=-ZLltnPt5WM" -o "-ZLltnPt5WM.json" -q

@teadrinker2015
Copy link
Author

Forgot to mention, I'm using powershell. Neither single nor double quotes work.
Only single quotes on windows command-line shell worked as expected.

PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.3.10
PSEdition                      Core
GitCommitId                    7.3.10
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

@xenova
Copy link
Owner

xenova commented Jan 19, 2024

In that case, can you try:

  1. appending a space to the beginning of the video id: ' -ZLltnPt5WM.json'
  2. escape the dash (I'm not sure how, perhaps \?

@teadrinker2015
Copy link
Author

In that case, can you try:

  1. appending a space to the beginning of the video id: ' -ZLltnPt5WM.json'

Adding space will result in a space in actual filename, but bypass this problem successfully. My version of Windows dosen't trim leading space in filenames perhaps.

  1. escape the dash (I'm not sure how, perhaps \?

After test, '`-ZLltnPt5WM.json' will also result in a leading `, And other pattern "`-ZLltnPt5WM.json" will fail.

@9001
Copy link
Contributor

9001 commented Feb 13, 2024

I think we're hitting a limitation in argparse... The best approach is probably to use one of the following alternatives instead:

  • --output=-ZLltnPt5WM.json
  • -o=-ZLltnPt5WM-2.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants