egbertbouman / youtube-comment-downloader

Simple script for downloading Youtube comments without using the Youtube API
MIT License
881 stars 223 forks source link

[BUG] dateparser.parse doesn't work for some languages #101

Closed minamotorin closed 2 years ago

minamotorin commented 2 years ago

Issue description

After https://github.com/egbertbouman/youtube-comment-downloader/commit/87c4f908b5c6cc0610c4d708cf5aa2b7a851d066, sometimes 'NoneType' object has no attribute 'timestamp' occur for some languages.

> youtube-comment-downloader --youtubeid _LHnduxb0YQ -o test.json --language en
Downloading Youtube comments for video: _LHnduxb0YQ
Downloaded 415 comment(s)
[44.13 seconds] Done!
>
> youtube-comment-downloader --youtubeid _LHnduxb0YQ -o test.json --language ar
Downloading Youtube comments for video: _LHnduxb0YQ
Error: 'NoneType' object has no attribute 'timestamp'
>
> youtube-comment-downloader --youtubeid _LHnduxb0YQ -o test.json --language zh
Downloading Youtube comments for video: _LHnduxb0YQ
Error: 'NoneType' object has no attribute 'timestamp'

The following minimal code will help understanding what is wrong.

import dateparser
dateparser.parse('1个月前(修改过)'.split('(')[0].strip()).timestamp()
dateparser.parse('قبل 3 أسابيع'.split('(')[0].strip()).timestamp()

Environments

Thanks.

egbertbouman commented 2 years ago

Thanks for letting me know! I guess the best way to deal with this is to just ignore the error and move on. It should work now.

minamotorin commented 2 years ago

Thanks for fixing!