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] TypeError: sequence item 0: expected str instance, NoneType found #209

Closed miminashii closed 1 year ago

miminashii commented 1 year ago

Basic information

Describe the bug

When trying to download a twitch chat, TypeError: sequence item 0: expected str instance, NoneType found occurs.

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.twitch.tv/videos/1822957278" -v --output "./output/1822957278.json"
  2. Output from the above command:
    [DEBUG] Session closed.
    Traceback (most recent call last):
    File "/Users/xxxxxxx/.pyenv/versions/3.10.4/bin/chat_downloader", line 8, in <module>
    sys.exit(main())
    File "/Users/xxxxxxx/.pyenv/versions/3.10.4/lib/python3.10/site-packages/chat_downloader/cli.py", line 194, in main
    run(**args.__dict__)
    File "/Users/xxxxxxx/.pyenv/versions/3.10.4/lib/python3.10/site-packages/chat_downloader/chat_downloader.py", line 361, in run
    callback(message)
    File "/Users/xxxxxxx/.pyenv/versions/3.10.4/lib/python3.10/site-packages/chat_downloader/chat_downloader.py", line 358, in callback
    chat.print_formatted(item)
    File "/Users/xxxxxxx/.pyenv/versions/3.10.4/lib/python3.10/site-packages/chat_downloader/sites/common.py", line 304, in print_formatted
    safe_print(self.format(item), flush=flush)
    File "/Users/xxxxxxx/.pyenv/versions/3.10.4/lib/python3.10/site-packages/chat_downloader/chat_downloader.py", line 260, in <lambda>
    chat.format = lambda x: formatter.format(
    File "/Users/xxxxxxx/.pyenv/versions/3.10.4/lib/python3.10/site-packages/chat_downloader/formatting/format.py", line 166, in format
    substitution = re.sub(self._INDEX_REGEX, lambda match: self._replace(
    File "/Users/xxxxxxx/.pyenv/versions/3.10.4/lib/python3.10/re.py", line 209, in sub
    return _compile(pattern, flags).sub(repl, string, count)
    File "/Users/xxxxxxx/.pyenv/versions/3.10.4/lib/python3.10/site-packages/chat_downloader/formatting/format.py", line 166, in <lambda>
    substitution = re.sub(self._INDEX_REGEX, lambda match: self._replace(
    File "/Users/xxxxxxx/.pyenv/versions/3.10.4/lib/python3.10/site-packages/chat_downloader/formatting/format.py", line 96, in _replace
    value = separator.join(
    TypeError: sequence item 0: expected str instance, NoneType found

    If the output is too long, you can attach a text file or remove output which does not constitute to the problem.

Otherwise, if using the python module, provide the following:

  1. A minimal reproducible example:
    # python code
  2. Output, traceback or other information relating to the bug:
    [output or description]

Expected behavior

A clear and concise description of what you expected to happen.

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 1 year ago

Thanks for the report. Fixing now.

miminashii commented 1 year ago

Thank you for dealing with it so quickly.

xenova commented 1 year ago

No worries :) Turns out you found a bug with twitch:

"userBadges":[
   {
      "id":"Ozs=",
      "setID":"",
      "version":"",
      "__typename":"Badge"
   },
   {
      "id":"Yml0czsxMDAwOw==",
      "setID":"bits",
      "version":"1000",
      "__typename":"Badge"
   }
],

is what is returned by their API. As you can see, the first badge is missing a version and an ID.

xenova commented 1 year ago

Fix is live in version 0.2.6 :)

pip install --upgrade chat-downloader