egbertbouman / youtube-comment-downloader

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

'Failed to set sorting' error #105

Closed raelb closed 2 years ago

raelb commented 2 years ago

Hi, I run the following command line:

youtube-comment-downloader --youtubeid YTbCpfFlNAo --output YTbCpfFlNAo.json --sort 1

On second run, I get this error: image

It seems to be because of existing ouput file, since If i delete the output file then it will run again without error.

egbertbouman commented 2 years ago

It seems to be working fine for me. Are you sure you're running the latest version? You can upgrade using pip install youtube-comment-downloader -U.

raelb commented 2 years ago

Yes, I am using latest version (0.1.60). After further testing I see it does not depend on existence of output file. The error occurs intermittently.

https://user-images.githubusercontent.com/13108198/165090943-9bbfdb0d-4377-46ad-91b0-ffdd9e4b4a7d.mp4

Perhaps related to #93

raelb commented 2 years ago

I did a bit more investigation.

On some occasions the response does not contain any sortMenu key (see attached sample), so the reported error is correct. From my side i can try again or run with sort set to 0 (which will not run the sorting code block), which will always succeed.

By the way on some occasions the "action" json contains the key engagement-panel-comments-section in stead of comments-section, so this line of code will work in both cases:

if (action['targetId'] == 'comments-section' or action['targetId'] == 'engagement-panel-comments-section'):

Attached are some sample responses sample responses.zip

From my side you can close the issue

egbertbouman commented 2 years ago

Thanks for investigating this! I tried to reproduce the issue a couple of days ago, but couldn't.

When I have some time I'll try again and see if I can find a workaround in case the sortmenu is missing.

mazayomaza commented 2 years ago

I'm experiencing the same problem. I hope this problem gets addressed as soon as possible

raelb commented 2 years ago

As I say in previous comment, I do not think this can be resolved, since in some cases the required sort info is not available in the json response. What happens if you set sort to 0, i.e. --sort 0? It should always work.

mazayomaza commented 2 years ago

the sort 0 option does work but I did want to use the other option. thank you

ujifgc commented 2 years ago

Same issue here. On some old videos with just one comment the script can fail 20 times, then on 21st will work randomly.

Setting --sort=0 always works

qboriskr commented 2 years ago

With option --sort=0 utility returns less comments than expected, for example only 20 of 1000.

estebanpdl commented 2 years ago

I have been facing the same issue here. While --sort=0 worked well (when --sort=1 fails) I only received up to 20 comments. The video has more than 1,000. I included the limit flag (youtube-comment-downloader --youtubeid JwjwnSdI4Yw -o ./data/data2.json -s 0 -l 5000), but still got only 20 comments.

Thanks so much in advance. Such a great tool.

EDIT

Just saw the new version.

https://github.com/egbertbouman/youtube-comment-downloader/pull/108

By updating, --sort=0 now works great. pip install youtube-comment-downloader -U