summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/invidious/channels/community.cr18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/invidious/channels/community.cr b/src/invidious/channels/community.cr
index 87659c47..da8be6ea 100644
--- a/src/invidious/channels/community.cr
+++ b/src/invidious/channels/community.cr
@@ -1,3 +1,5 @@
+private IMAGE_QUALITIES = {320, 560, 640, 1280, 2000}
+
# TODO: Add "sort_by"
def fetch_channel_community(ucid, continuation, locale, format, thin_mode)
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 "authorThumbnails" do
json.array do
- qualities = {32, 48, 76, 100, 176, 512}
author_thumbnail = post["authorThumbnail"]["thumbnails"].as_a[0]["url"].as_s
- qualities.each do |quality|
+ IMAGE_QUALITIES.each do |quality|
json.object do
json.field "url", author_thumbnail.gsub(/s\d+-/, "s#{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)
url = thumbnail["url"].as_s.gsub(/=w\d+-h\d+(-p)?(-nd)?(-df)?(-rwa)?/, "=s640")
- qualities = {320, 560, 640, 1280, 2000}
-
- qualities.each do |quality|
+ IMAGE_QUALITIES.each do |quality|
json.object do
json.field "url", url.gsub(/=s\d+/, "=s#{quality}")
json.field "width", quality
@@ -196,7 +195,7 @@ def fetch_channel_community(ucid, continuation, locale, format, thin_mode)
json.array do
attachment["choices"].as_a.each do |choice|
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.
# Ex post: https://www.youtube.com/post/UgkxD4XavXUD4NQiddJXXdohbwOwcVqrH9Re
if choice["image"]?
@@ -205,10 +204,9 @@ def fetch_channel_community(ucid, continuation, locale, format, thin_mode)
height = thumbnail["height"].as_i
aspect_ratio = (width.to_f / height.to_f)
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.array do
- qualities.each do |quality|
+ IMAGE_QUALITIES.each do |quality|
json.object do
json.field "url", url.gsub(/=s\d+/, "=s#{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)
url = thumbnail["url"].as_s.gsub(/=w\d+-h\d+(-p)?(-nd)?(-df)?(-rwa)?/, "=s640")
- qualities = {320, 560, 640, 1280, 2000}
-
- qualities.each do |quality|
+ IMAGE_QUALITIES.each do |quality|
json.object do
json.field "url", url.gsub(/=s\d+/, "=s#{quality}")
json.field "width", quality
lt;philosoph@snopyta.org> 2022-07-06Update Chinese (Traditional) translationHosted Weblate Co-authored-by: Hosted Weblate <hosted@weblate.org> Co-authored-by: Jeff Huang <s8321414@gmail.com> 2022-07-06Update Ukrainian translationHosted Weblate Co-authored-by: Hosted Weblate <hosted@weblate.org> Co-authored-by: Ihor Hordiichuk <igor_ck@outlook.com> 2022-07-06Update Italian translationHosted Weblate Update Italian translation Co-authored-by: Hosted Weblate <hosted@weblate.org> Co-authored-by: Pietro Cappuccino <p.cappuccino@tiscali.it> Co-authored-by: ㅤAbsurdUsername <sgso@pm.me> 2022-07-06Update Norwegian Bokmål translationHosted Weblate Co-authored-by: Allan Nordhøy <epost@anotheragency.no> Co-authored-by: Hosted Weblate <hosted@weblate.org> 2022-07-06Update Russian translationHosted Weblate Update Russian translation Update Russian translation Update Russian translation Co-authored-by: AHOHNMYC <lqwh2h2cwa@protonmail.com> Co-authored-by: Hosted Weblate <hosted@weblate.org> Co-authored-by: Егор Ермаков <eg.ermakov2016@yandex.ru> 2022-07-06Update comment for NotFoundExceptionÉmilien Devos 2022-07-04Don't treat LIVE_STREAM_OFFLINE playability status as an error (fixes #3155)Samantaz Fox 2022-07-04Remove all backend code related to dislikesSamantaz Fox 2022-07-04Fix syntax errors in shell scriptsSamantaz Fox 2022-07-04Remove useless link in item forms (buttons on thumbnail)Samantaz Fox 2022-07-04Remove item (video/channel/mix) thumbnail from keyboard navigation treeSamantaz Fox 2022-07-04Fix missing hash key: "availableCountries" (Closes #3047)Samantaz Fox 2022-07-04Add #to_http_params method to Query (Fixes #3148)Samantaz Fox 2022-07-03switched to extract_selected_tab for the community tab11tuvork28 2022-07-03Fixed community tab11tuvork28 2022-07-03Fix `Missing hash key: "selected" (KeyError)`11tuvork28 2022-07-03updated comment to represent current structure11tuvork28 2022-06-25Update some comments138138138 2022-06-25Update MobileUi138138138 2022-06-25Update MobileUi138138138 2022-06-25DASH Default to high quality m4a138138138 2022-06-25Change player.css order138138138 2022-06-25Add audioTrackButton138138138 2022-06-25change lang to label138138138 lang has to be BCP 47 standard. Using label also can let video.js know there are 2 audio tracks. 2022-06-24Update DASH format to serve 2 audio to player138138138 player.audioTracks() can successfully show tracks_: Array(2) 2022-06-23formatting138138138 2022-06-23Highest quality m4a on audio only mode as default138138138 Audio mode will automatically select highest quality m4a as default. 2022-06-23DASH playback force highest quality m4a138138138 Since VideoJS is unable to handle adaptive audio quality, the best audo quality is forced for every video quality. 2022-06-23Fix captions138138138 textTracks 0 in DASH mode shows debug messages. Use textTracks 1 in DASH mode, and textTracks 0 in non-DASH mode and audio mode. 2022-06-22Player MobileUi fast forward/backward rate138138138 The fast forward/backward seconds will be adjusted according to playback rate (same as YouTube app behavior). 5 seconds is used when the playback rate is 1x. Previously it was 10 seconds. I believe most of the users watch videos at 2x, so the change will not be obvious. 2022-06-22Fix captions138138138 Captions should automatically show according to preferences. 2022-06-13Bump revision for crystal alpine package on DockerÉmilien Devos