TheDrHax / Twitch-Chat-Downloader

Download chat messages from past broadcasts on Twitch
MIT License
47 stars 10 forks source link

TypeError: 'NoneType' object is not subscriptable #13

Closed massivedynamics1 closed 1 year ago

massivedynamics1 commented 1 year ago

I am on windows 10 pro 22H2 OS build 19045.2846 python -V - Python 3.11.3 pip3 show tdh-tcd Name: tdh-tcd Version: 2.5.2 Summary: Twitch Chat Downloader Home-page: https://github.com/TheDrHax/Twitch-Chat-Downloader Location: C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages Requires: iso8601, progressbar2, requests

Error:

python -m tcd 1813289267
100% (15320 of 15320) |##############################################################| Elapsed Time: 0:00:10 ETA:  00:00:00Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\tcd\__main__.py", line 4, in <module>
    main()
  File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\tcd\__init__.py", line 44, in main
    download(args.video or args.video_id)
  File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\tcd\__init__.py", line 19, in download
    for comment in messages:
  File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\tcd\twitch.py", line 187, in __iter__
    hasNextPage = comments['pageInfo']['hasNextPage']
                  ~~~~~~~~^^^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable
100% (15320 of 15320) |##############################################################| Elapsed Time: 0:00:11 Time:  0:00:11

In the same folder as I am running this program I have settings.json it's default that you generate with python -m tcd --generate-config the only thing I changed subtitle_duration is to increase the time to 4 seconds between each chat.

Here is the settings.json

{
  "version": "2.4.4",
  "client_id": "jzkbprff40iqj646a697cyrvl0zt2m6",
  "cooldown": 0,
  "display_progress": true,
  "formats": [
    "ass",
    "srt",
    "irc"
  ],
  "directory": "chats",
  "filename_format": "{directory}/v{video_id}.{format}",
  "max_width": -1,
  "subtitle_duration": 4,
  "dynamic_duration": {
    "enabled": false,
    "max": 5,
    "max_length": 100
  },
  "millisecond_separator": ",",
  "ssa_style_format": "Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, TertiaryColour, BackColour, Bold, Italic, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, AlphaLevel, Encoding",
  "ssa_style_default": "Style: Default,Arial,20,16777215,16777215,16777215,-2147483640,-1,0,1,3,0,1,5,0,5,0,0",
  "ssa_events_format": "Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text",
  "ssa_events_line_format": "Dialogue: Marked=0, {start}, {end}, Default, {user}, 0000, 0000, 0000, , {user}: {message}",
  "group_repeating_emotes": {
    "enabled": false,
    "threshold": 3,
    "collocations": 5,
    "collocations_threshold": 2,
    "format": "{emote} x{count}"
  },
  "badges": {
    "enabled": false,
    "max_count": 1,
    "map": {
      "broadcaster": "~",
      "vip": "^",
      "staff": "&",
      "admin": "!",
      "global_mod": "*",
      "moderator": "@",
      "artist-badge": "|",
      "game-developer": "}",
      "founder": "#",
      "sub-gift-leader": "=",
      "sub-gifter": "-",
      "partner": ")",
      "bits": "$",
      "bits-charity": "$",
      "twitchbot": "?",
      "subscriber": "%",
      "premium": "+",
      "turbo": "+",
      "hype-train": "+",
      "no_video": "/",
      "no_audio": "/"
    }
  },
  "video_types": "archive"
}

It looks like the chat was downloaded successfully but it's still weird why I am getting this error. Any idea? Thanks for your hard work on this fork it's essential for my twitch chat processing.

TheDrHax commented 1 year ago

Thank you for a detailed report! This problem should be fixed in 588911a92c95d437ab38fc5c1e52bafa2998a368. Version 2.5.3 will be out soon :)

massivedynamics1 commented 1 year ago

Thank you for a detailed report! This problem should be fixed in 588911a. Version 2.5.3 will be out soon :)

Thank you for quick fix. I have upgraded and I am getting a WARN on different downloads. It does not seem to effect the output, but it is strange that it's happening:

python -m tcd 1813188124
  0% (0 of 6420) |                                                               | Elapsed Time: 0:00:00 ETA:  --:--:--WARN: Cursors are not working, falling back to content offset
100% (6420 of 6420) |############################################################| Elapsed Time: 0:00:01 Time:  0:00:01
python -m tcd 1813289267
  0% (0 of 15320) |                                                              | Elapsed Time: 0:00:00 ETA:  --:--:--WARN: Cursors are not working, falling back to content offset
100% (15320 of 15320) |##########################################################| Elapsed Time: 0:00:12 Time:  0:00:12
python -m tcd 1813482091
  0% (0 of 1840) |                                                               | Elapsed Time: 0:00:00 ETA:  --:--:--WARN: Cursors are not working, falling back to content offset
100% (1840 of 1840) |############################################################| Elapsed Time: 0:00:01 Time:  0:00:01
python -m tcd 1813532625
  0% (0 of 7090) |                                                               | Elapsed Time: 0:00:00 ETA:  --:--:--WARN: Cursors are not working, falling back to content offset
100% (7090 of 7090) |############################################################| Elapsed Time: 0:00:01 Time:  0:00:01

Thanks again!

TheDrHax commented 1 year ago

This is normal. It tries to use the old and more precise method before falling back to the new one. The website is doing the same thing occasionally. Right now you can get rid of the warning by using this Client-ID, but it may break in the future.

I still hope that this is a bug on Twitch's side and they will fix it in the future. There is no real reason to block cursors but allow getting comments by a time offset. That's why I decided to use both methods at the same time.