xenova / chat-downloader

A simple tool used to retrieve chat messages from livestreams, videos, clips and past broadcasts. No authentication needed!
https://chat-downloader.readthedocs.io/
MIT License
902 stars 127 forks source link

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

Open teadrinker2015 opened 7 months ago

teadrinker2015 commented 7 months ago

Basic information

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
  2. 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.

xenova commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 6 months ago

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