about summary refs log tree commit diff
path: root/youtube_dl/extractor/common.py
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2020-12-13 20:24:13 +0700
committerSergey M․ <dstftw@gmail.com>2020-12-13 20:24:13 +0700
commit172754131578f6042efa7c47a57c6e8531e3d190 (patch)
treedca561e62d722c96e05ff57a43daba160a401257 /youtube_dl/extractor/common.py
parent45b0a0d11b9bc67895507629f8f0a81c5835f51f (diff)
downloadyoutube-dl-172754131578f6042efa7c47a57c6e8531e3d190.tar.gz
youtube-dl-172754131578f6042efa7c47a57c6e8531e3d190.tar.xz
youtube-dl-172754131578f6042efa7c47a57c6e8531e3d190.zip
[extractor/common] Improve JSON-LD interaction statistic extraction (refs #23306)
Diffstat (limited to 'youtube_dl/extractor/common.py')
-rw-r--r--youtube_dl/extractor/common.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/youtube_dl/extractor/common.py b/youtube_dl/extractor/common.py
index 460758ab8..79138f346 100644
--- a/youtube_dl/extractor/common.py
+++ b/youtube_dl/extractor/common.py
@@ -1237,8 +1237,16 @@ class InfoExtractor(object):
             'ViewAction': 'view',
         }
 
+        def extract_interaction_type(e):
+            interaction_type = e.get('interactionType')
+            if isinstance(interaction_type, dict):
+                interaction_type = interaction_type.get('@type')
+            return str_or_none(interaction_type)
+
         def extract_interaction_statistic(e):
             interaction_statistic = e.get('interactionStatistic')
+            if isinstance(interaction_statistic, dict):
+                interaction_statistic = [interaction_statistic]
             if not isinstance(interaction_statistic, list):
                 return
             for is_e in interaction_statistic:
@@ -1246,8 +1254,8 @@ class InfoExtractor(object):
                     continue
                 if is_e.get('@type') != 'InteractionCounter':
                     continue
-                interaction_type = is_e.get('interactionType')
-                if not isinstance(interaction_type, compat_str):
+                interaction_type = extract_interaction_type(is_e)
+                if not interaction_type:
                     continue
                 # For interaction count some sites provide string instead of
                 # an integer (as per spec) with non digit characters (e.g. ",")