From d8c00579d0c95c48342ac6b10ccd4340df086e21 Mon Sep 17 00:00:00 2001 From: Fijxu Date: Fri, 27 Nov 2026 00:36:19 -0300 Subject: [PATCH] fix: extraction of metadata_parts in fundraiser videos (#6181) Videos that have fundraiser in their data contain a `badges` element with their badge data as the last item of the metadata_rows, `row.dig()` tried to read `badges` but since it doensn't match `metadataParts` it just fails. using `dig?()` fixes it because it just skips `badges` as it should be. This is how the structure of metadataRows looks like in a fundraiser video ``` "metadataRows": [ { "metadataParts": [ { "text": { "content": "NPR Music", "commandRuns": [ { "startIndex": 0, "length": 9, "onTap": { "innertubeCommand": { "clickTrackingParams": "CI0IENTEDBgAIhMI_OOy14-nmAMVykO4BB0ZvzDGygEEcKuVmA==", "commandMetadata": { "webCommandMetadata": { "url": "/@nprmusic", "webPageType": "WEB_PAGE_TYPE_CHANNEL", "rootVe": 3611, "apiUrl": "/youtubei/v1/browse" } }, "browseEndpoint": { "browseId": "UC4eYXhJI4-7wSWc8UNRwD4A", "canonicalBaseUrl": "/@nprmusic" } } } } ], "styleRuns": [ { "startIndex": 0, "length": 9, "weightLabel": "FONT_WEIGHT_NORMAL" }, { "startIndex": 9, "styleRunExtensions": { "styleRunColorMapExtension": { "colorMap": [ { "key": "USER_INTERFACE_THEME_LIGHT", "value": 4284506208 }, { "key": "USER_INTERFACE_THEME_DARK", "value": 4289374890 } ] } } } ], "attachmentRuns": [ { "startIndex": 9, "length": 0, "element": { "type": { "imageType": { "image": { "sources": [ { "clientResource": { "imageName": "CHECK_CIRCLE_FILLED" }, "width": 14, "height": 14 } ] } } }, "properties": { "layoutProperties": { "height": { "value": 14, "unit": "DIMENSION_UNIT_POINT" }, "width": { "value": 14, "unit": "DIMENSION_UNIT_POINT" }, "margin": { "left": { "value": 4, "unit": "DIMENSION_UNIT_POINT" } } } } }, "alignment": "ALIGNMENT_VERTICAL_CENTER" } ] } } ] }, { "metadataParts": [ { "text": { "content": "521K views" } }, { "text": { "content": "1 day ago" }, "accessibilityLabel": "1 day ago" } ] }, { "badges": [ { "badgeViewModel": { "badgeText": "Fundraiser", "badgeStyle": "BADGE_COMMERCE", "trackingParams": "CI0IENTEDBgAIhMI_OOy14-nmAMVykO4BB0ZvzDG" } } ] } ], ``` --- src/invidious/yt_backend/extractors.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/invidious/yt_backend/extractors.cr b/src/invidious/yt_backend/extractors.cr index 485bb5d87..1031ba7ab 100644 --- a/src/invidious/yt_backend/extractors.cr +++ b/src/invidious/yt_backend/extractors.cr @@ -723,7 +723,7 @@ private module Parsers next end - metadata_parts = row.dig("metadataParts").try &.as_a + metadata_parts = row.dig?("metadataParts").try &.as_a if view_count_text.nil? view_count_text = metadata_parts.try &.find { |item| item["icon"]?.nil? && item.dig?("text", "content").try &.as_s.includes?("views") }