youtube-comment-scraper-cli icon indicating copy to clipboard operation
youtube-comment-scraper-cli copied to clipboard

Resume/retry capabilities

Open maliayas opened this issue 4 years ago • 2 comments

Youtube API sometimes may return error pages (such as #47) or simply a network error may break the whole fetching process.

To overcome this, I'll kindly propose the below approach:

  1. Turn the scheme into something like this:

    {
        "comments": [
            // ...
        ],
        "numberOfTotalComments": 2300,
        "nextPageToken": null
    }
    
  2. If an error is encountered at some point, save the partial data to the file with "nextPageToken" being set.

  3. If the user runs the same command again, check if the "nextPageToken" is not empty, and if so resume the operation using it.

And some notes about this approach:

  • "nextPageToken": null means everything is successfully downloaded.
  • On step 2 above, when there is an error, the script can actually make a second try before failing and saving partial data.
  • To decrease the chance of error, there may be delay between requests (in fact I looked at the source code to see if this is already done but failed; because JS code, to me, is very hard to follow)

maliayas avatar Jun 29 '20 20:06 maliayas

@maliayas can you download youtube data using this code?. can you help me to get the data from youtube?. because I gave an error Error API response does not contain a "content_html" field #47. I want to get some data for my final year project. previously I have got data using this program. please help me.

LakshanSaranga avatar Jul 12 '20 07:07 LakshanSaranga

This is just a proposal; there is no code yet. Unfortunately I'm not a JS dev, but I guess @philbot9 or someone else can easily implement this and then yes, it will fix #47.

maliayas avatar Jul 12 '20 07:07 maliayas