# (may be /bin/bash or perhaps any default shell) # This chain of sed scripts creates a *.srt file, containing subtitles # in the second language only, # using a source file with two languages, formatted (with no blank lines): # mm:ss # original language # second language (translation of the original one) # A source text formatted # mm:ss # original language subtitle # is easy to copy from youtube, # provided the manually-written subtitles are there # - use the transcript icon, the 4th option below the video. # (by Jenik Hollan, CzechGlobe, May 2014) sed -r "{N; N; s/\n[^\n]+\n/,000 /; s/^/00:/} " en_cz.txt | \ sed -r "=" | \ sed -r "{N; s/^([0-9]+)\n(.+)/\1 \2/}" | \ sed -r "{s/^([0-9]+) ([0-9:,]+) (.+)/\2\n\1 \2 \3/}" | \ sed -r '1d; ${s/^([0-9]+) ([0-9:,]+) (.+)/\1 \2 \3\n\2/}' | \ sed -r '${s/,000/,900/}' | \ sed -r " {s/,000/,100/; N; s/([0-9]+) ([0-9:]+,100) ([^\n]*)\n(.+)$/\n\1\n\2 --> \4\n\3/} " > cz.srt