server: implement -s bans
[rb-79.git] / tools / rb79-describe-file.sh
blob0956d320b1ed875c39334b19311e6ea514e1f69a
1 #!/bin/sh
3 format="${1}"
4 file="${2}"
6 size=$(/usr/bin/du -h "${file}" | /usr/bin/cut -d' ' -f1)
8 case "${format}" in
9 "video/"*)
10 width=$( ffprobe -v error -of flat=s=_ \
11 -select_streams v:0 \
12 -show_entries stream=width \
13 "${file}" | \
14 cut -d= -f2)
15 height=$(ffprobe -v error -of flat=s=_ \
16 -select_streams v:0 \
17 -show_entries stream=height \
18 "${file}" | \
19 cut -d= -f2)
20 duration=$(ffprobe -v error -of default=noprint_wrappers=1:nokey=1 \
21 -select_streams v:0 \
22 -show_entries format=duration\
23 -sexagesimal \
24 "${file}" | \
25 cut -d= -f2)
26 printf "%s, " "${format}"
27 printf "%s, " "${size}"
28 printf "%sx%s, " "${width}" "${height}"
29 printf "%s" "${duration}"
31 "image/"*)
32 width=$( ffprobe -v error -of flat=s=_ \
33 -select_streams v:0 \
34 -show_entries stream=width \
35 "${file}" | \
36 cut -d= -f2)
37 height=$(ffprobe -v error -of flat=s=_ \
38 -select_streams v:0 \
39 -show_entries stream=height \
40 "${file}" | \
41 cut -d= -f2)
42 printf "%s, " "${format}"
43 printf "%s, " "${size}"
44 printf "%sx%s" "${width}" "${height}"
46 "application/epub+zip")
47 printf "%s, " "${format}"
48 printf "%s" "${size}"
51 printf %s "${format}"
53 esac