egbertbouman / youtube-comment-downloader

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

Added UTF-8 support #15

Closed Daruko0 closed 6 years ago

Daruko0 commented 6 years ago

Small tweek to add UTF-8 support

egbertbouman commented 6 years ago

Thanks for your pull request! I've tested your solution and unfortunately it doesn't work on Python 2 since it doesn't support the encoding argument in the open function.

To support both Python 2 and 3, maybe you could try dropping the encoding argument, and write the changes to the file as follows: print(json.dumps(comment, ensure_ascii=False).encode('utf8'), file=fp).

Daruko0 commented 6 years ago

I took the liberty of importing the io module and changing open to io.open, which are exactly the same thing in python 3. That seems to have solved the python 2 compatibility. What do you think about this?

egbertbouman commented 6 years ago

Great, that works too. Thanks again!