diff options
author | Jesus <heckyel@hyperbola.info> | 2025-03-08 16:37:33 -0500 |
---|---|---|
committer | Jesus <heckyel@hyperbola.info> | 2025-03-08 16:37:33 -0500 |
commit | 1153ac8f24fa775c367eec13a235b5cfca530a12 (patch) | |
tree | 744748cac4982d5c78a97082c22f37a24bff748b /youtube/util.py | |
parent | c256a045f91d36463642af2f285d0b77cc3e9d3e (diff) | |
download | yt-local-1153ac8f24fa775c367eec13a235b5cfca530a12.tar.lz yt-local-1153ac8f24fa775c367eec13a235b5cfca530a12.tar.xz yt-local-1153ac8f24fa775c367eec13a235b5cfca530a12.zip |
Fix NoneType inside comments.py
Bug:
Traceback (most recent call last):
File "/home/rusian/yt-local/youtube/comments.py", line 180, in video_comments
post_process_comments_info(comments_info)
File "/home/rusian/yt-local/youtube/comments.py", line 81, in post_process_comments_info
comment['author'] = strip_non_ascii(comment['author'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/rusian/yt-local/youtube/util.py", line 843, in strip_non_ascii
stripped = (c for c in string if 0 < ord(c) < 127)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not iterable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "src/gevent/greenlet.py", line 900, in gevent._gevent_cgreenlet.Greenlet.run
File "/home/rusian/yt-local/youtube/comments.py", line 195, in video_comments
comments_info['error'] = 'YouTube blocked the request. IP address: %s' % e.ip
^^^^
AttributeError: 'TypeError' object has no attribute 'ip'
2025-03-08T01:25:47Z <Greenlet at 0x7f251e5279c0: video_comments('hcm55lU9knw', 0, lc='')> failed with AttributeError
Diffstat (limited to 'youtube/util.py')
-rw-r--r-- | youtube/util.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/youtube/util.py b/youtube/util.py index 356a795..c59fae8 100644 --- a/youtube/util.py +++ b/youtube/util.py @@ -840,6 +840,8 @@ def call_youtube_api(client, api, data): def strip_non_ascii(string): ''' Returns the string without non ASCII characters''' + if string is None: + return "" stripped = (c for c in string if 0 < ord(c) < 127) return ''.join(stripped) |