]> jfr.im git - yt-dlp.git/commitdiff
[youtube:comments] Improve comment vote count parsing (fixes #506) (#508)
authorcoletdjnz <redacted>
Wed, 14 Jul 2021 23:24:42 +0000 (11:24 +1200)
committerGitHub <redacted>
Wed, 14 Jul 2021 23:24:42 +0000 (23:24 +0000)
Authored by: colethedj

yt_dlp/extractor/youtube.py

index 1b4f3960b275f459d3abb831bf5a383f8c4968e5..a2abdc5036393feb9bfddc9bc8bb077adec5fb31 100644 (file)
@@ -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)