]> git.bitcoin.ninja Git - youtube-dl/commitdiff
[extractor/common] Relax interaction count extraction in _json_ld
authorSergey M․ <dstftw@gmail.com>
Fri, 18 Sep 2020 23:33:17 +0000 (06:33 +0700)
committerSergey M․ <dstftw@gmail.com>
Fri, 18 Sep 2020 23:33:17 +0000 (06:33 +0700)
youtube_dl/extractor/common.py

index c9b8b63377f1fac16ca35812b944274da7cebe14..021945a89e16c80262728a4a9a400674735389a7 100644 (file)
@@ -68,6 +68,7 @@ from ..utils import (
     sanitized_Request,
     sanitize_filename,
     str_or_none,
+    str_to_int,
     strip_or_none,
     unescapeHTML,
     unified_strdate,
@@ -1248,7 +1249,10 @@ class InfoExtractor(object):
                 interaction_type = is_e.get('interactionType')
                 if not isinstance(interaction_type, compat_str):
                     continue
-                interaction_count = int_or_none(is_e.get('userInteractionCount'))
+                # For interaction count some sites provide string instead of
+                # an integer (as per spec) with non digit characters (e.g. ",")
+                # so extracting count with more relaxed str_to_int
+                interaction_count = str_to_int(is_e.get('userInteractionCount'))
                 if interaction_count is None:
                     continue
                 count_kind = INTERACTION_TYPE_MAP.get(interaction_type.split('/')[-1])