Invidious is an alternative front-end to YouTube
Refactor process_video_params
Omar Roth68be24ffc69b
diff --git a/src/invidious/videos.cr b/src/invidious/videos.crindex ea6788ee..354ab19e 100644--- a/src/invidious/videos.cr+++ b/src/invidious/videos.cr@@ -1276,19 +1276,19 @@ enddef process_video_params(query, preferences)annotations = query["iv_load_policy"]?.try &.to_i?- autoplay = query["autoplay"]?.try &.to_i?+ autoplay = query["autoplay"]?.try { |q| (q == "true" || q == "1").to_unsafe }comments = query["comments"]?.try &.split(",").map { |a| a.downcase }- continue = query["continue"]?.try &.to_i?- continue_autoplay = query["continue_autoplay"]?.try &.to_i?- listen = query["listen"]? && (query["listen"] == "true" || query["listen"] == "1").to_unsafe- local = query["local"]? && (query["local"] == "true" || query["local"] == "1").to_unsafe+ continue = query["continue"]?.try { |q| (q == "true" || q == "1").to_unsafe }+ continue_autoplay = query["continue_autoplay"]?.try { |q| (q == "true" || q == "1").to_unsafe }+ listen = query["listen"]?.try { |q| (q == "true" || q == "1").to_unsafe }+ local = query["local"]?.try { |q| (q == "true" || q == "1").to_unsafe }player_style = query["player_style"]?preferred_captions = query["subtitles"]?.try &.split(",").map { |a| a.downcase }quality = query["quality"]?region = query["region"]?- related_videos = query["related_videos"]? && (query["related_videos"] == "true" || query["related_videos"] == "1").to_unsafe+ related_videos = query["related_videos"]?.try { |q| (q == "true" || q == "1").to_unsafe }speed = query["speed"]?.try &.rchop("x").to_f?- video_loop = query["loop"]?.try &.to_i?+ video_loop = query["loop"]?.try { |q| (q == "true" || q == "1").to_unsafe }volume = query["volume"]?.try &.to_i?if preferences@@ -1341,17 +1341,10 @@ def process_video_params(query, preferences)local = falseend- if query["t"]?- video_start = decode_time(query["t"])+ if start = query["t"]? || query["time_continue"]? || query["start"]?+ video_start = decode_time(start)endvideo_start ||= 0- if query["time_continue"]?- video_start = decode_time(query["time_continue"])- end- video_start ||= 0- if query["start"]?- video_start = decode_time(query["start"])- endif query["end"]?video_end = decode_time(query["end"])