egbertbouman / youtube-comment-downloader

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

Error: No JSON object could be decoded #27

Closed ediowar closed 4 years ago

ediowar commented 5 years ago

OS version: Ubuntu 16.04.6 LTS Python 2.7 requests version: 2.9.1-3ubuntu0.1 lxml version: 3.5.0-1ubuntu0.1 cssselect version: 0.9.1+git90c72b0-1

d0tN3t commented 5 years ago

Line: 154 try removing .decode('utf-8') and you might have to remove the bytes portion as well. This isn't an error of the script, as it is more encoding/decoding issue for the serialization.

You can also look into simplejson if you don't want to deal with encoding/decoding issues.

Other than that, that's my best guess based on your title, and I don't ever use 2.7 unfortunately.

ediowar commented 5 years ago

There is no error right now.

milahu commented 4 years ago

line 34 old

        if response.status_code == 200:
            return response.json()

new

        if response.status_code == 200:
            if len(response.text) == 0:
                print("response is empty")
                return {}
            return response.json()