From 90249cdafaf3c7b25619a14016e72ce5950907a6 Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Sat, 7 Sep 2019 20:09:08 -0400 Subject: [PATCH] Fix extractor for short_view_count_text --- src/invidious/videos.cr | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index ef3f4d4b..7010fa97 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -1113,14 +1113,15 @@ def extract_player_config(body, html) .try &.["results"]? .try &.as_a - rvs = extract_recommended(rvs) - rvs.each_with_index do |rv, i| - if !rv["view_count"]? + rvs = extract_recommended(rvs).compact_map do |rv| + if !rv["short_view_count_text"]? rv_params = rvs_params.select { |rv_params| rv_params["id"]? == (rv["id"]? || "") }[0]? - if rv_params - rvs[i]["short_view_count_text"] = rv_params["short_view_count_text"] + + if rv_params.try &.["short_view_count_text"]? + rv["short_view_count_text"] = rv_params.not_nil!["short_view_count_text"] + rv else - rvs.delete_at(i) + nil end end end