aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/00-export-videos.sh
blob: 42f5d6facfa2b64a0ea1cde6fe1e2426c492d16d (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
#!/bin/sh

CHAT_EXPORT="$1"

jq \
  -r '.messages | map(select(.media_type == "video_file")) | .[].file' \
  "$CHAT_EXPORT/result.json" | while read -r file; do

  FILE="$CHAT_EXPORT/$file"

  ffprobe \
    -v quiet \
    -print_format json \
    -select_streams a \
    -show_streams \
    "$FILE" > "$FILE.tmp.json"

  HAS_AUDIO="$(jq '.streams | length > 0' "$FILE.tmp.json")"

  if [ "$HAS_AUDIO" = "true" ]; then

    cp "$FILE" videos/$(basename "$FILE")

  fi

  rm "$FILE.tmp.json"

done