summaryrefslogtreecommitdiffstats
path: root/roles/obs/templates/play
blob: 22f58c72a545d70012fa3a2dc61338203fe3d77a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
# Play intro if recorded, then play files
# {{ ansible_managed }}

shopt -s nullglob

# play-with-intro $SLUG
YEAR="{{ emacsconf_year }}"
BASE_DIR="{{ emacsconf_caption_dir }}"
CACHE_DIR="{{ emacsconf_caption_dir }}/cache"
FIREFOX_NAME=firefox-esr
SLUG=$1
PREFIX=$(get-file-prefix $SLUG)

/usr/local/bin/reset-state

# Update the overlay
overlay $SLUG

# Play the video if it exists. If it doesn't exist, switch to the BBB room and stop processing.
if [ "x$TEST_MODE" = "x" ]; then
  LIST=($BASE_DIR/assets/stream/{{ emacsconf_id }}-{{ emacsconf_year }}-$SLUG*--main.webm)
else
  LIST=($BASE_DIR/assets/test/{{ emacsconf_id }}-{{ emacsconf_year }}-$SLUG*--main.webm)
fi
FILE="${LIST[0]}"
# No file in the stream directory; check for original files in the stream directory, then check the cache
NOSUB=""
if [[ ! -f "$FILE" ]]; then
		# Is there a cache file or an original file?
		LIST=($CACHE_DIR/{{ emacsconf_id }}-{{ emacsconf_year }}-$SLUG*--main.webm)
    FILE="${LIST[0]}"
		if [[ ! -f $FILE ]]; then
				LIST=($CACHE_DIR/{{ emacsconf_id }}-{{ emacsconf_year }}-$SLUG*--original.*)
				FILE="${LIST[0]}"
		fi
		echo "Candidate: " $FILE
		SUBS=($CACHE_DIR/{{ emacsconf_id }}-{{ emacsconf_year }}-$SLUG*--main.vtt)
		if [[ -f "${SUBS[0]}"  ]]; then
		  if ! cat ${SUBS[0]} | head -1 | grep -q captioned ; then
				echo "Skipping subtitles because they're not edited"
				NOSUB="--sub-visibility=no"
			else
					NOSUB="--sub-visibility=yes"
			fi
		fi
fi

if [[ -f "$FILE" ]]; then
  screen -mS talk /bin/bash -c "mpv $NOSUB $FILE"
else
	/usr/local/bin/bbb $SLUG
  exit 0
fi