running tcd fails on a certain video because it seems the user the comment belongs to doesn't exist anymore or something, so the twitch api returns 'null' for that field, which twitch-python doesn't handle and throws a NPE
(tcd_venv) PS C:\Users\mark\Code\Personal\git\get_twitch_vod_chats> tcd --verbose --video 873505779 --format "json,default,irc,srt,ssa" --debug --output "tcd_output.log" --timezone "UTC"
NES speedruns
Downloading JSON data
Traceback (most recent call last):
File "C:\Python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Python39\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\mark\Temp\tcd_venv\Scripts\tcd.exe\__main__.py", line 7, in <module>
File "c:\users\mark\temp\tcd_venv\lib\site-packages\tcd\__init__.py", line 92, in main
Downloader().videos(Arguments().video_ids)
File "c:\users\mark\temp\tcd_venv\lib\site-packages\tcd\downloader.py", line 183, in videos
self.video(video)
File "c:\users\mark\temp\tcd_venv\lib\site-packages\tcd\downloader.py", line 100, in video
for comment in video.comments:
File "c:\users\mark\temp\tcd_venv\lib\site-packages\twitch\v5\resources\comments.py", line 27, in __iter__
yield v5.Comment(api=self._api, data=comment)
File "c:\users\mark\temp\tcd_venv\lib\site-packages\twitch\v5\models\comment.py", line 84, in __init__
self.commenter: Commenter = Commenter(data.get('commenter'))
File "c:\users\mark\temp\tcd_venv\lib\site-packages\twitch\v5\models\comment.py", line 18, in __init__
self.display_name: str = data.get('display_name')
AttributeError: 'NoneType' object has no attribute 'get'
i added logging to both tcd and twitch-python (which i feel you should add to both as an aside, would have made it easier to debug) and as the video will probably be aged out by the time you look at this, i have the full api response output if you want.
Here is the relevant api response (a python dict, not JSON), note the None as the value for commenter
its fixed by adding a check to see if data.get("commenter") is none, and if so, just set self.commenter = None in v5/models/commenter.py : Comment.__init__, however all of the formatters except for JSON expect a commenter, so those parts of the code need to handle a potential missing commenter
running
tcd
fails on a certain video because it seems the user the comment belongs to doesn't exist anymore or something, so the twitch api returns 'null' for that field, whichtwitch-python
doesn't handle and throws a NPEi added logging to both
tcd
andtwitch-python
(which i feel you should add to both as an aside, would have made it easier to debug) and as the video will probably be aged out by the time you look at this, i have the full api response output if you want.Here is the relevant api response (a python dict, not JSON), note the
None
as the value forcommenter
its fixed by adding a check to see if
data.get("commenter")
is none, and if so, just setself.commenter = None
inv5/models/commenter.py : Comment.__init__
, however all of the formatters except for JSON expect a commenter, so those parts of the code need to handle a potential missing commenter