
#------------------------------------------------------------------------------
# $File: subtitle,v 1.2 2022/09/07 11:29:09 christos Exp $
# subtitle:  file(1) magic for subtitles files

# EBU-STL
# https://tech.ebu.ch/docs/tech/tech3264.pdf
3	string	STL		EBU-STL subtitles
>6	regex	=^[0-9][0-9]	\b, rate %s
>>8	string	.01		\b, v1
!:mime	application/x-ebu-stl
>>>16	regex	=^[^\ ]{0,32}	\b, title "%s"
>>>>224 regex	=^[0-9]{2}	\b, created %-.2s
>>>>>&0 regex	=^[0-9]{2}	\b-%-.2s
>>>>>>&0 regex	=^[0-9]{2}	\b-%-.2s
!:ext	stl

# SubRip (srt) subtitles
0	regex/20	=^1[\r\n]+0[01]:[0-9]{2}:[0-9]{2},[0-9]{3}\040-->	 SubRip
!:mime	application/x-subrip
!:ext	srt

# WebVTT subtitles
# https://www.w3.org/TR/webvtt1/
0	string/t	WEBVTT
>&0	regex/255	=[0-9]{2}:[0-9]{2}\\.[0-9]{3}\040-->	WebVTT subtitles
!:mime	text/vtt
!:ext	vtt

# XML TTML subtitles
# https://www.w3.org/TR/ttml2/
0	string/t	\<?xml
>20	search/400	\020xmlns=
>>&0 regex ['"]http://www.w3.org/ns/ttml    TTML subtitles
!:mime	application/ttml+xml
# Augment strength to beat plain XML
!:strength * 3
!:ext	ttml
