Add support for AAhBBmCCsDDms in video start and end params
This commit is contained in:
parent
fef2cbc0b2
commit
75f8fcd40b
@ -643,3 +643,25 @@ def fetch_user(sid, client, headers)
|
|||||||
user = User.new(sid, Time.now, [] of String, channels, email)
|
user = User.new(sid, Time.now, [] of String, channels, email)
|
||||||
return user
|
return user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def decode_time(string)
|
||||||
|
time = string.try &.to_f?
|
||||||
|
|
||||||
|
if !time
|
||||||
|
hours = /(?<hours>\d+)h/.match(string).try &.["hours"].try &.to_i
|
||||||
|
hours ||= 0
|
||||||
|
|
||||||
|
minutes = /(?<minutes>\d+)m/.match(string).try &.["minutes"].try &.to_i
|
||||||
|
minutes ||= 0
|
||||||
|
|
||||||
|
seconds = /(?<seconds>\d+)s/.match(string).try &.["seconds"].try &.to_i
|
||||||
|
seconds ||= 0
|
||||||
|
|
||||||
|
millis = /(?<millis>\d+)ms/.match(string).try &.["millis"].try &.to_i
|
||||||
|
millis ||= 0
|
||||||
|
|
||||||
|
time = hours * 3600 + minutes * 60 + seconds + millis / 1000
|
||||||
|
end
|
||||||
|
|
||||||
|
return time
|
||||||
|
end
|
||||||
|
@ -242,17 +242,23 @@ get "/watch" do |env|
|
|||||||
next env.redirect "/"
|
next env.redirect "/"
|
||||||
end
|
end
|
||||||
|
|
||||||
video_start = env.params.query["start"]?.try &.to_i
|
if env.params.query["start"]?
|
||||||
video_start ||= 0
|
video_start = decode_time(env.params.query["start"])
|
||||||
|
else
|
||||||
|
video_start = 0
|
||||||
|
end
|
||||||
|
|
||||||
video_end = env.params.query["end"]?.try &.to_i
|
if env.params.query["end"]?
|
||||||
video_end ||= -1
|
video_end = decode_time(env.params.query["end"])
|
||||||
|
else
|
||||||
|
video_end = -1
|
||||||
|
end
|
||||||
|
|
||||||
listen = false
|
|
||||||
if env.params.query["listen"]? && env.params.query["listen"] == "true"
|
if env.params.query["listen"]? && env.params.query["listen"] == "true"
|
||||||
listen = true
|
listen = true
|
||||||
env.params.query.delete_all("listen")
|
env.params.query.delete_all("listen")
|
||||||
end
|
end
|
||||||
|
listen ||= false
|
||||||
|
|
||||||
authorized = env.get? "authorized"
|
authorized = env.get? "authorized"
|
||||||
if authorized
|
if authorized
|
||||||
|
@ -74,10 +74,10 @@ var player = videojs('player', options, function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
player.offset({
|
player.offset({
|
||||||
start: <%= video_start %>,
|
start: <%= video_start %>,
|
||||||
end: <%= video_end %>,
|
end: <%= video_end %>
|
||||||
restart_beginning: true
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function toggle(target) {
|
function toggle(target) {
|
||||||
|
Loading…
Reference in New Issue
Block a user