fix: skip non comment commentFilterContextViewModel key in comments (#5870)

Some YouTube videos like https://www.youtube.com/watch?v=Ajkr_Wg-k8g
had an non comment key that was inside the Array that contained some
comment information that Invidious parses (like comment_key and
toolbar_key), that being the `commentFilterContextViewModel` key, which
is just an indicator on how comments are sorted:

```
{
    "commentThreadRenderer": { ... } <- comment information that is
    handled by line 134 of youtube.cr
},
{
    "commentFilterContextViewModel": {
        "text": {
            "content": "Top is selected, so you'll see featured comments"
        },
        "accessibility": {
            "accessibilityData": {
                "label": "Top is selected, so you'll see featured comments"
            }
        }
    } <- Useless information, this is not a comment
}
```
This commit is contained in:
Fijxu
2026-08-02 16:20:43 -04:00
committed by GitHub
parent 51dd4fefd0
commit 21a3434850

View File

@@ -128,6 +128,8 @@ module Invidious::Comments
json.field "comments" do json.field "comments" do
json.array do json.array do
contents.as_a.each do |node| contents.as_a.each do |node|
next if node["commentFilterContextViewModel"]?
json.object do json.object do
if node["commentThreadRenderer"]? if node["commentThreadRenderer"]?
node = node["commentThreadRenderer"] node = node["commentThreadRenderer"]