subtitle-paste - annna - Annna the nice friendly bot.
HTML git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/
DIR Log
DIR Files
DIR Refs
DIR Tags
DIR README
---
subtitle-paste (696B)
---
1 #!/bin/sh
2
3 export PATH="/home/annna/bin:$PATH"
4
5 if [ $# -lt 1 ];
6 then
7 printf "usage: %s uri\n" "$(basename "$0")" >&2
8 exit 1
9 fi
10
11 pastebase="/br/gopher/paste"
12 uri="$1"
13
14 cd "${pastebase}"
15 tmpfile="$(mktemp -u p-XXXXXXXXXXXXX)"
16
17 youtube-dl -q --write-auto-sub --skip-download -o "${tmpfile}" "${uri}" 2>/dev/null
18 rfile="$(find . -name "${tmpfile}.*")"
19 [ -z "${rfile}" ] && exit 1
20 ofile="$(basename "${rfile}")"
21 [ -z "${ofile}" ] && exit 1
22
23 if [ $(stat -c%s "${ofile}") -eq 0 ];
24 then
25 rm "${ofile}"
26 else
27 # Make it more human readable.
28 awk -f /home/annna/bin/ytautosubcleaner.awk < "${ofile}" > "${ofile}.bak"
29 mv "${ofile}.bak" "${ofile}"
30 printf "gophers://bitreich.org/0/p/%s\n" "${ofile}"
31 fi
32