|Yotsubaaa 1951bb6f5f||10 months ago|
|.gitignore||1 year ago|
|LICENSE||1 year ago|
|README.md||10 months ago|
|bb_timestamps.rb||10 months ago|
|kiwi_timestamps_eg1.png||1 year ago|
|kiwi_timestamps_eg2.png||1 year ago|
|kiwi_timestamps_eg3.png||1 year ago|
|kiwi_timestamps_eg4.png||1 year ago|
Make pretty formatted timestamps using BB codes for Xenforo 2 forum posts.
The Ruby script
bb_timestamps.rb automates the process I use to make timestamps for YouTube streams and videos in my Kiwi Farms posts. See the Demonstration below for a usage example.
Released under the Unlicense License. Feel free to do anything you want with this script; just don’t hold me liable if anything bad happens!## Demonstration Here's a step-by-step example of using the `bb_timestamps.rb` script to make a pretty list of timestamps.
Using your favorite text editor, write your timestamp lines in the following format, e.g.
00:12:34 Something funny happens here at 1hr, 23mins, 45secs 00:13:45 Something else happens 23:45 This timestamp doesn't have the hours column (this is fine!) 01:23:45 This timestamp comes after a blank line (this is also fine!) 1:34:56 This timestamp doesn't have padded zeros (again, perfectly fine!)
with a single space separating the time and the comment, and with each new timestamp on a new line.
kiwi_timestamps.rbscript ignores any blank lines and extraneous whitespace when reading the timestamps. Only the single space between the time and the comment is important.
Optionally (but most usefully!), if the first line of your text file of timestamps is a link to the YouTube video/stream, e.g.
then the timestamps will be formatted to include a hyperlink to that exact moment in the video/stream, using YouTube’s
&time_continue= parameter. Otherwise, if no link is provided, the timestamps will simply be colored light blue so that they stand out a bit.
Here’s me making some timestamps for a YouTube stream. Note the timestamps file in the EMACS editor on the right-hand side. The file includes the link to the YouTube stream as the first line, then a blank line (which gets ignored by the script), and then the timestamps I want. The timestamps file is saved as
bb_timestamps.rband grab the output.
Once you’ve written all of your timestamps to a file (called
timestamps_file for example), simply run the script
bb_timestamps.rb as a Ruby script and pass in your file of timestamps with
ruby bb_timestamps.rb timestamps_file
or, if you’ve given the script permission to run as an executable,
The version of Ruby I had on hand when I wrote the script was Ruby 2.3, so the script should (presumably?) run on any version >=2.3.
When executed, the script prints each of the formatted timestamps to the standard output stream. Optionally redirect the output to a file for easier copy-pasting.
Here I run the
bb_timestamps.rb script at the command line, passing in
MADI_timestamps as an argument and redirecting the script output to a new file
MADI_formatted. The script only takes a moment to run, and we can see (using
cat MADI_formatted to look at the file contents) that all of the timestamps have been formatted to include the font and hyperlink information.
The formatted output text contains the explicit BB codes that are used to format posts on Kiwi Farms (and other Xenforo2 forum boards). But if we paste it into a new post like usual, then those code strings will just appear as text in the post. So we first click the ‘Toggle BB code’ button in the top-right corner so that the BB codes for the font/url/color/etc are interpreted properly.
When I go to make my Kiwi Farms post, I click the ‘Toggle BB code’ button in the top-right corner.
At this point, all that’s left is to paste in the formatted timestamp text, and perhaps click ‘Preview’ to make sure that everything appears nicely as expected.
Here I have copy-pasted the formatted timestamps from
MADI_formatted into my post, and clicked ‘Preview’. The timestamps come up all pretty and monospaced, and clicking on any of them opens a link to that moment in the YouTube stream (see the hyperlink hovertext in the bottom-left corner).
And that’s all there is to it! After you’ve copy-pasted in the formatted timestamp text, you can click ‘Toggle BB code’ again to return to the normal post interface and do more things (change text around, maybe put the timestamps inside spoiler tags if they’re a long list, etc).