SMAPPNYU / youtube-data-api

A Python Client for collect and parse public data from the Youtube Data API
https://youtube-data-api.readthedocs.io/en/latest/index.html
MIT License
79 stars 31 forks source link

fixed bug to retrieve commenter_channel_id with None authorChannelId #28

Closed cramdoulfa closed 3 years ago

cramdoulfa commented 4 years ago

get_video_comments() would crash when trying to retrieve channel Id on a comment that has an empty authorChannelId. (trying to do .get() on a NoneType, see error bellow)

Error can be reproduced on comment UgwmA6Y3pOHcTs39GEx4AaABAg of the video RCXGpEmFbOw

/data/home/ec2-user/anaconda3/lib/python3.7/site-packages/youtube_api/parsers.py in parse_comment_metadata(item)
    225         "video_id" : item["snippet"].get("videoId"),
    226         "commenter_channel_url" : item["snippet"].get("authorChannelUrl"),
--> 227         "commenter_channel_id" : item['snippet'].get('authorChannelId').get('value', None),
    228         "commenter_channel_display_name" : item['snippet'].get('authorDisplayName'),
    229         "comment_id" : item.get("id"),

AttributeError: 'NoneType' object has no attribute 'get'
mabrownnyu commented 4 years ago

Hi @cramdoulfa, I was unable to replicate this error on the video specified. Please run the same request with the most recent version of the wrapper and submit all input variables for the method and the full traceback.

yinleon commented 3 years ago

fixed in https://github.com/SMAPPNYU/youtube-data-api/pull/42