mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-04-11.git
synced 2024-08-15 00:43:26 +00:00
Add '/api/v1/popular'
This commit is contained in:
parent
3c98601f35
commit
18bb397c7d
1 changed files with 34 additions and 0 deletions
|
@ -2606,6 +2606,40 @@ get "/api/v1/trending" do |env|
|
||||||
videos
|
videos
|
||||||
end
|
end
|
||||||
|
|
||||||
|
get "/api/v1/popular" do |env|
|
||||||
|
videos = JSON.build do |json|
|
||||||
|
json.array do
|
||||||
|
popular_videos.each do |video|
|
||||||
|
json.object do
|
||||||
|
json.field "title", video.title
|
||||||
|
json.field "videoId", video.id
|
||||||
|
json.field "videoThumbnails" do
|
||||||
|
generate_thumbnails(json, video.id)
|
||||||
|
end
|
||||||
|
|
||||||
|
json.field "lengthSeconds", video.info["length_seconds"].to_i
|
||||||
|
json.field "viewCount", video.views
|
||||||
|
|
||||||
|
json.field "author", video.author
|
||||||
|
json.field "authorId", video.ucid
|
||||||
|
json.field "authorUrl", "/channel/#{video.ucid}"
|
||||||
|
json.field "published", video.published.to_unix
|
||||||
|
json.field "publishedText", "#{recode_date(video.published)} ago"
|
||||||
|
|
||||||
|
description = video.description.gsub("<br>", "\n")
|
||||||
|
description = description.gsub("<br/>", "\n")
|
||||||
|
description = XML.parse_html(description)
|
||||||
|
json.field "description", description.content
|
||||||
|
json.field "descriptionHtml", video.description
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
env.response.content_type = "application/json"
|
||||||
|
videos
|
||||||
|
end
|
||||||
|
|
||||||
get "/api/v1/top" do |env|
|
get "/api/v1/top" do |env|
|
||||||
videos = JSON.build do |json|
|
videos = JSON.build do |json|
|
||||||
json.array do
|
json.array do
|
||||||
|
|
Loading…
Reference in a new issue