diff options
| author | Omar Roth <omarroth@hotmail.com> | 2018-09-22 11:14:57 -0500 |
|---|---|---|
| committer | Omar Roth <omarroth@hotmail.com> | 2018-09-22 11:14:57 -0500 |
| commit | 1ab04638e353bea7824de51b19f0be4ca73cf765 (patch) | |
| tree | 4999f23bfeb1a50f749468107c98fa263b1db3cc | |
| parent | f80f4f2521786bd979d25584df7b8a926e8058d1 (diff) | |
| download | invidious-1ab04638e353bea7824de51b19f0be4ca73cf765.tar.gz invidious-1ab04638e353bea7824de51b19f0be4ca73cf765.tar.bz2 invidious-1ab04638e353bea7824de51b19f0be4ca73cf765.zip | |
Add 'videoCount' to playlists in search
| -rw-r--r-- | src/invidious.cr | 2 | ||||
| -rw-r--r-- | src/invidious/helpers/helpers.cr | 5 |
2 files changed, 6 insertions, 1 deletions
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 \((?<count>\d+)/).try &.["count"].to_i? end |
