mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-26 15:33:36 +00:00
Add author thumbnails to playlist endpoint
This commit is contained in:
parent
c2e72439f5
commit
74b285d0f7
@ -2839,6 +2839,20 @@ get "/api/v1/playlists/:plid" do |env|
|
||||
json.field "authorId", playlist.ucid
|
||||
json.field "authorUrl", "/channel/#{playlist.ucid}"
|
||||
|
||||
json.field "authorThumbnails" do
|
||||
json.array do
|
||||
qualities = [32, 48, 76, 100, 176, 512]
|
||||
|
||||
qualities.each do |quality|
|
||||
json.object do
|
||||
json.field "url", playlist.author_thumbnail.gsub("=s100-", "=s#{quality}-")
|
||||
json.field "width", quality
|
||||
json.field "height", quality
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
json.field "description", playlist.description
|
||||
json.field "descriptionHtml", playlist.description_html
|
||||
json.field "videoCount", playlist.video_count
|
||||
|
@ -3,6 +3,7 @@ class Playlist
|
||||
title: String,
|
||||
id: String,
|
||||
author: String,
|
||||
author_thumbnail: String,
|
||||
ucid: String,
|
||||
description: String,
|
||||
description_html: String,
|
||||
@ -164,6 +165,8 @@ def fetch_playlist(plid)
|
||||
|
||||
anchor = document.xpath_node(%q(//ul[@class="pl-header-details"])).not_nil!
|
||||
author = anchor.xpath_node(%q(.//li[1]/a)).not_nil!.content
|
||||
author_thumbnail = document.xpath_node(%q(//img[@class="channel-header-profile-image"])).try &.["src"]
|
||||
author_thumbnail ||= ""
|
||||
ucid = anchor.xpath_node(%q(.//li[1]/a)).not_nil!["href"].split("/")[2]
|
||||
|
||||
video_count = anchor.xpath_node(%q(.//li[2])).not_nil!.content.delete("videos, ").to_i
|
||||
@ -181,6 +184,7 @@ def fetch_playlist(plid)
|
||||
title,
|
||||
plid,
|
||||
author,
|
||||
author_thumbnail,
|
||||
ucid,
|
||||
description,
|
||||
description_html,
|
||||
|
Loading…
Reference in New Issue
Block a user