egbertbouman / youtube-comment-downloader

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

JSONDecodeError: Expecting value: line 1 column 1 (char 0) #122

Closed epireve closed 10 months ago

epireve commented 2 years ago

Hi there,

Yesterday it was all fine. Been running about half a day before it spitted out JSONDecodeError.

At first, I thought it was the Pandas dataframe issues. I tried to diagnose the root. Even when I tried the example code also produced the same error.

JSONDecodeError                           Traceback (most recent call last)
  [<ipython-input-95-761e26dba270>](https://localhost:8080/#) in <module>
        3 downloader = YoutubeCommentDownloader()
        4 comments = downloader.get_comments_from_url('https://www.youtube.com/watch?v=ScMzIvxBSi4', sort_by=SORT_BY_POPULAR)
  ----> 5 for comment in islice(comments, 10):
        6     print(comment)

  3 frames
  [/usr/lib/python3.7/json/decoder.py](https://localhost:8080/#) in raw_decode(self, s, idx)
      353             obj, end = self.scan_once(s, idx)
      354         except StopIteration as err:
  --> 355             raise JSONDecodeError("Expecting value", s, err.value) from None
      356         return obj, end

  JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Is it because of the generator?

andyg2 commented 1 year ago

Did you add: from itertools import islice

jasperbw commented 1 year ago

I do not know if this is still relevant, but I had the same problem. Uninstalling and then reinstalling solved it for me.

JaredJoss commented 11 months ago

Hi.

I have used this tool many times and absolutely love it. Thank you. However, I have tried to scrape comments today (15/11/2023) and I ran into this error "JSONDecodeError: Expecting value: line 1 column 1 (char 0)", with the following code (taken from the README)

from itertools import islice
from youtube_comment_downloader import *

downloader = YoutubeCommentDownloader()
comments = downloader.get_comments_from_url('https://www.youtube.com/watch?v=ScMzIvxBSi4', sort_by=SORT_BY_POPULAR)
for comment in islice(comments, 10):
    print(comment)

I have tried uninstalling and re-installing the tool however, this did not solve the problem.

egbertbouman commented 10 months ago

This error appears when the script can't parse the response that's coming from the Youtube server. This is usually because either Youtube made changes to their server, or because Youtube is blocking you. Since the script seems to work fine for me, I'm guessing Youtube is blocking your IP.