From 1ab04638e353bea7824de51b19f0be4ca73cf765 Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Sat, 22 Sep 2018 11:14:57 -0500 Subject: [PATCH] Add 'videoCount' to playlists in search --- src/invidious.cr | 2 ++ src/invidious/helpers/helpers.cr | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/invidious.cr b/src/invidious.cr index bdd00b0f..1cb1ca7e 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -2645,6 +2645,7 @@ get "/api/v1/channels/search/:ucid" do |env| json.field "authorId", item.ucid json.field "authorUrl", "/channel/#{item.ucid}" + json.field "videoCount", item.video_count json.field "videos" do json.array do item.videos.each do |video| @@ -2765,6 +2766,7 @@ get "/api/v1/search" do |env| json.field "authorId", item.ucid json.field "authorUrl", "/channel/#{item.ucid}" + json.field "videoCount", item.video_count json.field "videos" do json.array do item.videos.each do |video| diff --git a/src/invidious/helpers/helpers.cr b/src/invidious/helpers/helpers.cr index e1fc4d52..7449a435 100644 --- a/src/invidious/helpers/helpers.cr +++ b/src/invidious/helpers/helpers.cr @@ -238,7 +238,10 @@ def extract_items(nodeset, ucid = nil) when .includes? "yt-lockup-playlist" plid = HTTP::Params.parse(URI.parse(id).query.not_nil!)["list"] - anchor = node.xpath_node(%q(.//ul[@class="yt-lockup-meta-info"]/li/a)) + anchor = node.xpath_node(%q(.//div[contains(@class, "yt-lockup-meta")]/a)) + if !anchor + anchor = node.xpath_node(%q(.//ul[@class="yt-lockup-meta-info"]/li/a)) + end if anchor video_count = anchor.content.match(/View full playlist \((?\d+)/).try &.["count"].to_i? end