summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Roth <omarroth@protonmail.com>2019-10-04 12:23:28 -0400
committerOmar Roth <omarroth@protonmail.com>2019-10-04 12:23:28 -0400
commit68be24ffc69bdd38735faaa87a32d885f47f0ec9 (patch)
tree6c56625cf23b8647d2326cd7602140df65d38be4
parent9dcc87c70533aa0fd61542ebf778fcbf5f192617 (diff)
downloadinvidious-68be24ffc69bdd38735faaa87a32d885f47f0ec9.tar.gz
invidious-68be24ffc69bdd38735faaa87a32d885f47f0ec9.tar.bz2
invidious-68be24ffc69bdd38735faaa87a32d885f47f0ec9.zip
Refactor process_video_params
-rw-r--r--src/invidious/videos.cr25
1 files changed, 9 insertions, 16 deletions
diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr
index ea6788ee..354ab19e 100644
--- a/src/invidious/videos.cr
+++ b/src/invidious/videos.cr
@@ -1276,19 +1276,19 @@ end
def 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 = false
end
- if query["t"]?
- video_start = decode_time(query["t"])
+ if start = query["t"]? || query["time_continue"]? || query["start"]?
+ video_start = decode_time(start)
end
video_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"])
- end
if query["end"]?
video_end = decode_time(query["end"])