Repository: yt-dlp/yt-dlp

Issue:
[youtube:comments] Large comment like counts fail to be parsed and are incorrectly set to 0
<!--

######################################################################
  WARNING!
  IGNORING THE FOLLOWING TEMPLATE WILL RESULT IN ISSUE CLOSED AS INCOMPLETE
######################################################################

-->


## Checklist

<!--
Carefully read and work through this check list in order to prevent the most common mistakes and misuse of yt-dlp:
- First of, make sure you are using the latest version of yt-dlp. Run `yt-dlp --version` and ensure your version is 2021.07.07. If it's not, see https://github.com/yt-dlp/yt-dlp on how to update. Issues with outdated version will be REJECTED.
- Make sure that all provided video/audio/playlist URLs (if any) are alive and playable in a browser.
- Make sure that all URLs and arguments with special characters are properly quoted or escaped as explained in https://github.com/yt-dlp/yt-dlp.
- Search the bugtracker for similar issues: https://github.com/yt-dlp/yt-dlp. DO NOT post duplicates.
- Read bugs section in FAQ: https://github.com/yt-dlp/yt-dlp
- Finally, put x into all relevant boxes like this [x] (Dont forget to delete the empty space)
-->

- [ ] I'm reporting a broken site support issue
- [X] I've verified that I'm running yt-dlp version **2021.07.07**
- [X] I've checked that all provided URLs are alive and playable in a browser
- [X] I've checked that all URLs and arguments with special characters are properly quoted or escaped
- [X] I've searched the bugtracker for similar bug reports including closed ones
- [X] I've read bugs section in FAQ


## Verbose log

<!--
Provide the complete verbose output of yt-dlp that clearly demonstrates the problem.
Add the `-v` flag to your command line you run yt-dlp with (`yt-dlp -v <your command line>`), copy the WHOLE output and insert it below. It should look similar to this:
 [debug] System config: []
 [debug] User config: []
 [debug] Command-line args: [u'-v', u'http://www.youtube.com/watch?v=BaW_jenozKc']
 [debug] Encodings: locale cp1251, fs mbcs, out cp866, pref cp1251
 [debug] yt-dlp version 2021.07.07
 [debug] Python version 2.7.11 - Windows-2003Server-5.2.3790-SP2
 [debug] exe versions: ffmpeg N-75573-g1d0487f, ffprobe N-75573-g1d0487f, rtmpdump 2.4
 [debug] Proxy map: {}
 <more lines>
-->

```
$ yt-dlp --skip-download --get-comments --verbose --extractor-args "youtube:max_comments=10" "https://www.youtube.com/watch?v=RErdSr0iAcs"
[debug] Command-line config: ['--skip-download', '--get-comments', '--verbose', '--extractor-args', 'youtube:max_comments=10', 'https://www.youtube.com/watch?v=RErdSr0iAcs']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8
[debug] yt-dlp version 2021.07.07 
[debug] Python version 3.9.5 (CPython 64bit) - Linux-5.12.9-1-MANJARO-x86_64-with-glibc2.33
[debug] exe versions: ffmpeg 4.4, ffprobe 4.4, rtmpdump 2.4
[debug] Proxy map: {}
[debug] [youtube] Extracting URL: https://www.youtube.com/watch?v=RErdSr0iAcs
[youtube] RErdSr0iAcs: Downloading webpage
[youtube] RErdSr0iAcs: Downloading android player API JSON
[debug] Formats sorted by: hasvid, ie_pref, lang, quality, res, fps, vcodec:vp9.2(10), acodec, filesize, fs_approx, tbr, vbr, abr, asr, proto, vext, aext, hasaud, source, id
[debug] Default format spec: bestvideo*+bestaudio/best
[info] RErdSr0iAcs: Downloading 1 format(s): 248+251
[debug] [youtube] Detected old API continuation token. Generating new API compatible token.
[youtube] Downloading comment section API JSON
[youtube] Downloading ~44048 comments
[youtube] Sorting comments by newest first
[youtube] Downloading comment API JSON page 1 (0/44048)
[youtube]     Downloading comment API JSON reply thread 1 (1/44048)
[youtube] Downloaded 10/44048 comments
[info] Writing video metadata as JSON to: 'And I think to myself, what a wonderful world.' [RErdSr0iAcs].info.json

$ jq ".comments[0]" \'And\ I\ think\ to\ myself,\ what\ a\ wonderful\ world.\'\ \[RErdSr0iAcs\].info.json  
{
  "id": "UgyeP5xBb5VT5N_eODB4AaABAg",
  "text": "I'm genuinely touched by the sudden influx of attention, but I want to humbly remind everyone that each protester you see in this video is now either in jail, in exile or in some form of hiding. Most can't escape, and now that the decades-old Hong Kong democracy movement has been completely crushed, they'll likely live the rest of their lives under Beijing's authoritarian rule. The protesters knew it would probably end like this, but they did it anyways, hence the rallying cry of \"攬炒\"... \"if we burn, you burn with us\". \n\nMost of my friends now suffer from PTSD, depression or perpetual anxiety. Words and ideas that were once debated in public are now whispered in private - or not at all - out of fear that a neighbour or co-worker or family member overhears and decides to report you. I don't think calling Hong Kong a police state is an exaggeration anymore, and it's only the beginning.\n\nMaybe it's too late for Hong Kong, but you can still learn from what happened here. I hope you realise that you're not alone, that your pain and yearning is shared by countless silent strangers, and that when enough people speak as one, you can move the needle of history. I've seen it happen. \n\nMost of all, I hope you remember us.",
  "timestamp": 1621036800,
  "time_text": "2 months ago (edited)",
  "like_count": 0,
  "is_favorited": false,
  "author": "thelastpeanut",
  "author_id": "UCZM4rEEqUyyW49JBTVL8bqg",
  "author_thumbnail": "https://yt3.ggpht.com/ytc/AKedOLSf-uGptFbKX1e3uH6Lrc80y73C7NfBHD68PQ=s176-c-k-c0x00ffffff-no-rj",
  "author_is_uploader": true,
  "parent": "root"
}

```
<!--
Do not remove the above ```
-->


## Description

<!--
Provide an explanation of your issue in an arbitrary form. Please make sure the description is worded well enough to be understood, see https://github.com/ytdl-org/youtube-dl#is-the-description-of-the-issue-itself-sufficient. Provide any additional information, suggested solution and as much context and examples as possible.
If work on your issue requires account credentials please provide them or explain how one can obtain them.
-->

YouTube simplifies large counts into strings that cannot be directly converted into integers. This applies for comment likes. Here we have a comment with "201K" likes, in which that string fails to be parsed and hence defaults to a like count of 0.

We need to add extra parsing for these strings.

Comment link for reference: https://www.youtube.com/watch?v=RErdSr0iAcs&lc=UgyeP5xBb5VT5N_eODB4AaABAg


Discussion:

Resolving patch:
diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py
--- a/yt_dlp/extractor/youtube.py
+++ b/yt_dlp/extractor/youtube.py
@@ -40,6 +40,7 @@
     intlist_to_bytes,
     mimetype2ext,
     parse_codecs,
+    parse_count,
     parse_duration,
     qualities,
     remove_start,
@@ -1992,12 +1993,13 @@ def _extract_comment(self, comment_renderer, parent=None):
         text = self._join_text_entries(comment_text_runs) or ''
         comment_time_text = try_get(comment_renderer, lambda x: x['publishedTimeText']['runs']) or []
         time_text = self._join_text_entries(comment_time_text)
+        # note: timestamp is an estimate calculated from the current time and time_text
         timestamp = calendar.timegm(self.parse_time_text(time_text).timetuple())
         author = try_get(comment_renderer, lambda x: x['authorText']['simpleText'], compat_str)
         author_id = try_get(comment_renderer,
                             lambda x: x['authorEndpoint']['browseEndpoint']['browseId'], compat_str)
-        votes = str_to_int(try_get(comment_renderer, (lambda x: x['voteCount']['simpleText'],
-                                                      lambda x: x['likeCount']), compat_str)) or 0
+        votes = parse_count(try_get(comment_renderer, (lambda x: x['voteCount']['simpleText'],
+                                                       lambda x: x['likeCount']), compat_str)) or 0
         author_thumbnail = try_get(comment_renderer,
                                    lambda x: x['authorThumbnail']['thumbnails'][-1]['url'], compat_str)
 


Test patch: