Skip to content

Instantly share code, notes, and snippets.

@azimut
Last active November 30, 2024 03:33
Show Gist options
  • Save azimut/bad34fd818b179ef5e78acd8c3b8811d to your computer and use it in GitHub Desktop.
Save azimut/bad34fd818b179ef5e78acd8c3b8811d to your computer and use it in GitHub Desktop.
zoom2srt - convert zoom chat .txt output to .srt
#!/usr/bin/gawk -f
# Description:
# converts a Zoom chat in txt format to a .srt
#
# Usage:
# $ cat zoomchat.txt | gawk -f zoom2srt.awk > out.srt
#
# TODO:
# - full es language support
# - nicknames format (color?)
# - timeshift
# Copyright (C) 2024 azimut
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
BEGIN { OFS="\t"; FS="\t"; DURATION=59; OFFSET=0 }
match($0, /^[0-9]{2}:[0-9]{2}/) {
timestamp=substr($1, RSTART,RLENGTH)":00"; $1=""
}
/Reacted to/ || /Se ha reaccionado a / { next }
/^$/ { next }
NF == 1 { # reply msg
content[timestamp]=content[timestamp] " " $0
}
NF == 3 {
gsub(/\s+$/,"\n",$3) # dos2unix
if ($3 ~ /Replying to/) content[timestamp]=content[timestamp] $2 # reply from
else content[timestamp]=content[timestamp] $2 " " $3
}
END {
PROCINFO["sorted_in"] = "@ind_str_asc"
for (idx in content) {
print ++counter
spacedtt=idx; gsub(":"," ",spacedtt)
printf "%s,000 --> %s,000\n", idx, strftime("%H:%M:%S", mktime("1980 01 01 "spacedtt) + DURATION)
print content[idx]
printf "\n"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment