diff options
| author | Johannes Herman <johannes.herman@gmail.com> | 2025-12-11 06:49:19 +0100 |
|---|---|---|
| committer | Johannes Herman <johannes.herman@gmail.com> | 2025-12-11 06:49:19 +0100 |
| commit | c14aabfd17c85632bd68db60867edb3fb662c7e7 (patch) | |
| tree | d3fc7a1c44bba6fa56c39bd77013911151977532 /bin/make_archives.sh | |
initial commit
Diffstat (limited to 'bin/make_archives.sh')
| -rwxr-xr-x | bin/make_archives.sh | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/bin/make_archives.sh b/bin/make_archives.sh new file mode 100755 index 0000000..02bec66 --- /dev/null +++ b/bin/make_archives.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +CSV_FILE="tricks.csv" +VIDEO_DIR="videos" +DEMO_DIR="demos" +ARCHIVE_DIR="public/archives" + +mkdir -p "$ARCHIVE_DIR" + +declare -A montage_videos +declare -A montage_demos + +while IFS=',' read -r name players train_videos ingame_videos demos montage; do + key="$(echo "$montage" | xargs)" + videos_raw=$(echo "$ingame_videos" | xargs) + demos_raw=$(echo "$demos" | xargs) + key="$(echo "$key" | sed 's/ /_/g')" + + videos="" + IFS=';' read -ra video_items <<< "$videos_raw" + for item in "${video_items[@]}"; do + videos+="${VIDEO_DIR}/${item}.mp4 " + done + + demos="" + IFS=';' read -ra demo_items <<< "$demos_raw" + for item in "${demo_items[@]}"; do + demos+="${DEMO_DIR}/${item} " + done + + if [[ -z "$key" ]]; then + key="Unused" + fi + + if [[ -n "${montage_videos[$key]}" ]]; then + montage_videos[$key]="${montage_videos[$key]} $videos" + else + montage_videos[$key]="$videos" + fi + + if [[ -n "${montage_demos[$key]}" ]]; then + montage_demos[$key]="${montage_demos[$key]} $demos" + else + montage_demos[$key]="$demos" + fi +done < <(tail -n +2 "$CSV_FILE") + +for montage in "${!montage_videos[@]}"; do + [[ -n "${montage_videos[$montage]}" ]] \ + && zip -r "${ARCHIVE_DIR}/${montage}_videos.zip" ${montage_videos[$montage]} + continue +done + +for montage in "${!montage_demos[@]}"; do + [[ -n "${montage_demos[$montage]}" ]] \ + && zip -r "${ARCHIVE_DIR}/${montage}_demos.zip" ${montage_demos[$montage]} +done + |
