mirror of
https://github.com/rwxrob/dot
synced 2024-11-14 18:12:56 +00:00
52 lines
912 B
Bash
Executable File
52 lines
912 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
stamp () {
|
|
local video=$(yt liveid)
|
|
|
|
#local vids="$HOME/Videos/Recordings"
|
|
local vids="${YOUTUBE_RECORDINGS}"
|
|
|
|
local epoch=$(date +%s)
|
|
local offset=$(( $epoch - $(stat --printf '%W' $(newest "${vids}"))))
|
|
|
|
local hours=$(( $offset / 3600 ))
|
|
local remainder=$(( $offset % 3600))
|
|
local minutes=$(( $remainder / 60 ))
|
|
local seconds=$(( $offset % 60))
|
|
printf "%02d:%02d:%02d https://youtu.be/%s?t=%d %s\n" \
|
|
$hours $minutes $seconds $video $offset $(date -d @$epoch -Iseconds)
|
|
}
|
|
|
|
parse_secs () {
|
|
local x="$*"
|
|
x=${x#*t=}
|
|
x=${x% *}
|
|
echo "$x"
|
|
}
|
|
|
|
parse_time () {
|
|
local x="$*"
|
|
x=${x##* }
|
|
echo "$x"
|
|
}
|
|
|
|
usage () {
|
|
echo 'usage:
|
|
vidoffset (print offset stamp)
|
|
vidoffset ±<adj> (print adjusted offset)'
|
|
}
|
|
|
|
if [[ -z $1 ]]; then
|
|
stamp
|
|
exit
|
|
fi
|
|
|
|
if [[ -z $2 ]]; then
|
|
val=$(stamp)
|
|
echo $val
|
|
echo "would adjust prev stamp by $1"
|
|
exit
|
|
fi
|
|
|
|
usage
|