Skip to content

Commit cd4dfff

Browse files
committed
Use faster algorithm for timestamps for YouTube video from Podcasts#show
1 parent f48e36d commit cd4dfff

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

app/controllers/podcasts_controller.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,14 @@ def convert_shownote(content)
5151
t = $1
5252
t = (t.size == '0:00'.size) ? '0' + t : t
5353
t = (t.size == '00:00'.size) ? '00:' + t : t
54-
t = Time.parse(t).seconds_since_midnight.to_i
54+
55+
#t = Time.parse(t).seconds_since_midnight.to_i
56+
# This format should be faster than above:
57+
# ?t=01:23:45
58+
# ?t=01h23m45s
59+
t[2] = 'h'
60+
t[5] = 'm'
61+
t << 's'
5562
"- [#{$1}](https://youtu.be/#{youtube_id}?t=#{t}) &nbsp; "
5663
end
5764
end

0 commit comments

Comments
 (0)