mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2023-06-08.git
synced 2024-08-15 00:53:38 +00:00
Add author thumbnails to playlist endpoint
This commit is contained in:
parent
c2e72439f5
commit
74b285d0f7
2 changed files with 18 additions and 0 deletions
|
@ -2839,6 +2839,20 @@ get "/api/v1/playlists/:plid" do |env|
|
||||||
json.field "authorId", playlist.ucid
|
json.field "authorId", playlist.ucid
|
||||||
json.field "authorUrl", "/channel/#{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 "description", playlist.description
|
||||||
json.field "descriptionHtml", playlist.description_html
|
json.field "descriptionHtml", playlist.description_html
|
||||||
json.field "videoCount", playlist.video_count
|
json.field "videoCount", playlist.video_count
|
||||||
|
|
|
@ -3,6 +3,7 @@ class Playlist
|
||||||
title: String,
|
title: String,
|
||||||
id: String,
|
id: String,
|
||||||
author: String,
|
author: String,
|
||||||
|
author_thumbnail: String,
|
||||||
ucid: String,
|
ucid: String,
|
||||||
description: String,
|
description: String,
|
||||||
description_html: String,
|
description_html: String,
|
||||||
|
@ -164,6 +165,8 @@ def fetch_playlist(plid)
|
||||||
|
|
||||||
anchor = document.xpath_node(%q(//ul[@class="pl-header-details"])).not_nil!
|
anchor = document.xpath_node(%q(//ul[@class="pl-header-details"])).not_nil!
|
||||||
author = anchor.xpath_node(%q(.//li[1]/a)).not_nil!.content
|
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]
|
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
|
video_count = anchor.xpath_node(%q(.//li[2])).not_nil!.content.delete("videos, ").to_i
|
||||||
|
@ -181,6 +184,7 @@ def fetch_playlist(plid)
|
||||||
title,
|
title,
|
||||||
plid,
|
plid,
|
||||||
author,
|
author,
|
||||||
|
author_thumbnail,
|
||||||
ucid,
|
ucid,
|
||||||
description,
|
description,
|
||||||
description_html,
|
description_html,
|
||||||
|
|
Loading…
Reference in a new issue