mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-23 00:29:53 +05:30
use dig, create private image quality constant
Co-Authored-By: Samantaz Fox <coding@samantaz.fr>
This commit is contained in:
parent
4731480821
commit
4a14713462
@ -1,3 +1,5 @@
|
|||||||
|
private IMAGE_QUALITIES = {320, 560, 640, 1280, 2000}
|
||||||
|
|
||||||
# TODO: Add "sort_by"
|
# TODO: Add "sort_by"
|
||||||
def fetch_channel_community(ucid, continuation, locale, format, thin_mode)
|
def fetch_channel_community(ucid, continuation, locale, format, thin_mode)
|
||||||
response = YT_POOL.client &.get("/channel/#{ucid}/community?gl=US&hl=en")
|
response = YT_POOL.client &.get("/channel/#{ucid}/community?gl=US&hl=en")
|
||||||
@ -75,10 +77,9 @@ def fetch_channel_community(ucid, continuation, locale, format, thin_mode)
|
|||||||
json.field "author", author
|
json.field "author", author
|
||||||
json.field "authorThumbnails" do
|
json.field "authorThumbnails" do
|
||||||
json.array do
|
json.array do
|
||||||
qualities = {32, 48, 76, 100, 176, 512}
|
|
||||||
author_thumbnail = post["authorThumbnail"]["thumbnails"].as_a[0]["url"].as_s
|
author_thumbnail = post["authorThumbnail"]["thumbnails"].as_a[0]["url"].as_s
|
||||||
|
|
||||||
qualities.each do |quality|
|
IMAGE_QUALITIES.each do |quality|
|
||||||
json.object do
|
json.object do
|
||||||
json.field "url", author_thumbnail.gsub(/s\d+-/, "s#{quality}-")
|
json.field "url", author_thumbnail.gsub(/s\d+-/, "s#{quality}-")
|
||||||
json.field "width", quality
|
json.field "width", quality
|
||||||
@ -177,9 +178,7 @@ def fetch_channel_community(ucid, continuation, locale, format, thin_mode)
|
|||||||
aspect_ratio = (width.to_f / height.to_f)
|
aspect_ratio = (width.to_f / height.to_f)
|
||||||
url = thumbnail["url"].as_s.gsub(/=w\d+-h\d+(-p)?(-nd)?(-df)?(-rwa)?/, "=s640")
|
url = thumbnail["url"].as_s.gsub(/=w\d+-h\d+(-p)?(-nd)?(-df)?(-rwa)?/, "=s640")
|
||||||
|
|
||||||
qualities = {320, 560, 640, 1280, 2000}
|
IMAGE_QUALITIES.each do |quality|
|
||||||
|
|
||||||
qualities.each do |quality|
|
|
||||||
json.object do
|
json.object do
|
||||||
json.field "url", url.gsub(/=s\d+/, "=s#{quality}")
|
json.field "url", url.gsub(/=s\d+/, "=s#{quality}")
|
||||||
json.field "width", quality
|
json.field "width", quality
|
||||||
@ -196,7 +195,7 @@ def fetch_channel_community(ucid, continuation, locale, format, thin_mode)
|
|||||||
json.array do
|
json.array do
|
||||||
attachment["choices"].as_a.each do |choice|
|
attachment["choices"].as_a.each do |choice|
|
||||||
json.object do
|
json.object do
|
||||||
json.field "text", choice["text"]["runs"][0]["text"].as_s
|
json.field "text", choice.dig("text", "runs", 0, "text").as_s
|
||||||
# A choice can have an image associated with it.
|
# A choice can have an image associated with it.
|
||||||
# Ex post: https://www.youtube.com/post/UgkxD4XavXUD4NQiddJXXdohbwOwcVqrH9Re
|
# Ex post: https://www.youtube.com/post/UgkxD4XavXUD4NQiddJXXdohbwOwcVqrH9Re
|
||||||
if choice["image"]?
|
if choice["image"]?
|
||||||
@ -205,10 +204,9 @@ def fetch_channel_community(ucid, continuation, locale, format, thin_mode)
|
|||||||
height = thumbnail["height"].as_i
|
height = thumbnail["height"].as_i
|
||||||
aspect_ratio = (width.to_f / height.to_f)
|
aspect_ratio = (width.to_f / height.to_f)
|
||||||
url = thumbnail["url"].as_s.gsub(/=w\d+-h\d+(-p)?(-nd)?(-df)?(-rwa)?/, "=s640")
|
url = thumbnail["url"].as_s.gsub(/=w\d+-h\d+(-p)?(-nd)?(-df)?(-rwa)?/, "=s640")
|
||||||
qualities = {320, 560, 640, 1280, 2000}
|
|
||||||
json.field "image" do
|
json.field "image" do
|
||||||
json.array do
|
json.array do
|
||||||
qualities.each do |quality|
|
IMAGE_QUALITIES.each do |quality|
|
||||||
json.object do
|
json.object do
|
||||||
json.field "url", url.gsub(/=s\d+/, "=s#{quality}")
|
json.field "url", url.gsub(/=s\d+/, "=s#{quality}")
|
||||||
json.field "width", quality
|
json.field "width", quality
|
||||||
@ -235,9 +233,7 @@ def fetch_channel_community(ucid, continuation, locale, format, thin_mode)
|
|||||||
aspect_ratio = (width.to_f / height.to_f)
|
aspect_ratio = (width.to_f / height.to_f)
|
||||||
url = thumbnail["url"].as_s.gsub(/=w\d+-h\d+(-p)?(-nd)?(-df)?(-rwa)?/, "=s640")
|
url = thumbnail["url"].as_s.gsub(/=w\d+-h\d+(-p)?(-nd)?(-df)?(-rwa)?/, "=s640")
|
||||||
|
|
||||||
qualities = {320, 560, 640, 1280, 2000}
|
IMAGE_QUALITIES.each do |quality|
|
||||||
|
|
||||||
qualities.each do |quality|
|
|
||||||
json.object do
|
json.object do
|
||||||
json.field "url", url.gsub(/=s\d+/, "=s#{quality}")
|
json.field "url", url.gsub(/=s\d+/, "=s#{quality}")
|
||||||
json.field "width", quality
|
json.field "width", quality
|
||||||
|
Loading…
Reference in New Issue
Block a user