-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmkwatch
More file actions
executable file
·50 lines (45 loc) · 1.25 KB
/
mkwatch
File metadata and controls
executable file
·50 lines (45 loc) · 1.25 KB
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
#!/bin/bash
# ignore * patterns that don't match anything
shopt -s nullglob
host="${HOSTNAME-$(hostname)}"
port=":${PORT-3030}"
site=${WATCHHOST-"${host}${port}"}
prefix=${WATCHPREFIX-}
[ $# = 0 ] && set .
for show; do
cd "${show}"
# assume web server points to a disk under /Volumes (typical for macOS)
dir="${PWD#/Volumes/}"
# template for each video's web page
read -r -d '' html <<EOF
<!DOCTYPE html>
<html lang="en">
<style>
video {
width: 100%;
height: 100%;
}
</style>
<body>
<div class="video-container">
<video controls autoplay>
<source src="../%%FILENAME%%" type="video/mp4">
</video>
</div>
</body>
</html>
EOF
# make sure the "watch" dir is there
mkdir -p watch
# assume video files are named .mp4 or .mkv or .m4v or something starting with 'm'
for video in *.{mp4,avi,mkv,m4v,webm,mov,flv,vob,ogv,ogg,ts,m2ts,qt,wmv,rm,asf,muddypawsgames@gmail.com,mpeg}; do
basename="${video%%.???}"
urlvideo=$(echo "$video" | perl -e 'use URI::Escape; $v=<>; chomp($v); $v =~ s#%#%%#g; print uri_escape_utf8($v);')
echo "$html" \
| perl -p -e "s#%%FILENAME%%#${urlvideo}#;" \
> watch/"${basename}".html
done
dir=$(echo "$dir" | perl -pe "s#${prefix}/##; s/ /%20/g;")
echo "> http://${site}/${dir}/watch"
cd ..
done