summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Roth <omarroth@protonmail.com>2019-10-04 10:23:02 -0400
committerOmar Roth <omarroth@protonmail.com>2019-10-04 10:26:02 -0400
commit9dcc87c70533aa0fd61542ebf778fcbf5f192617 (patch)
tree7c35a4ef010673a2993993f6aeaa8f4f094ecbf4
parentd36c536107baaedfbbb983a0457ca6b16d19743e (diff)
downloadinvidious-9dcc87c70533aa0fd61542ebf778fcbf5f192617.tar.gz
invidious-9dcc87c70533aa0fd61542ebf778fcbf5f192617.tar.bz2
invidious-9dcc87c70533aa0fd61542ebf778fcbf5f192617.zip
Refactor storyboard generation
-rw-r--r--src/invidious/videos.cr19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr
index e175ae39..ea6788ee 100644
--- a/src/invidious/videos.cr
+++ b/src/invidious/videos.cr
@@ -715,14 +715,15 @@ struct Video
storyboards = player_response["storyboards"]?
.try &.as_h
.try &.["playerStoryboardSpecRenderer"]?
+ .try &.["spec"]?
+ .try &.as_s.split("|")
if !storyboards
- storyboards = player_response["storyboards"]?
- .try &.as_h
- .try &.["playerLiveStoryboardSpecRenderer"]?
-
- if storyboard = storyboards.try &.["spec"]?
- .try &.as_s
+ if storyboard = player_response["storyboards"]?
+ .try &.as_h
+ .try &.["playerLiveStoryboardSpecRenderer"]?
+ .try &.["spec"]?
+ .try &.as_s
return [{
url: storyboard.split("#")[0],
width: 106,
@@ -736,9 +737,6 @@ struct Video
end
end
- storyboards = storyboards.try &.["spec"]?
- .try &.as_s.split("|")
-
items = [] of NamedTuple(
url: String,
width: Int32,
@@ -767,6 +765,7 @@ struct Video
interval = interval.to_i
storyboard_width = storyboard_width.to_i
storyboard_height = storyboard_height.to_i
+ storyboard_count = (count / (storyboard_width * storyboard_height)).ceil.to_i
items << {
url: url.to_s.sub("$L", i).sub("$N", "M$M"),
@@ -776,7 +775,7 @@ struct Video
interval: interval,
storyboard_width: storyboard_width,
storyboard_height: storyboard_height,
- storyboard_count: (count.to_f / (storyboard_width.to_f * storyboard_height.to_f)).ceil.to_i,
+ storyboard_count: storyboard_count,
}
end