57 lines
1.6 KiB
Bash
Executable file
57 lines
1.6 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
CONTENT_DIR="./conteudo"
|
|
OUTPUT_FILE="./manifest.json"
|
|
|
|
echo "{" > "$OUTPUT_FILE"
|
|
|
|
first_dir=true
|
|
|
|
# Loop through each subdirectory
|
|
for dir in "$CONTENT_DIR"/*/ ; do
|
|
if [ -d "$dir" ]; then
|
|
dirname=$(basename "$dir")
|
|
|
|
# Add comma between directories
|
|
if [ "$first_dir" = false ]; then
|
|
echo "," >> "$OUTPUT_FILE"
|
|
fi
|
|
first_dir=false
|
|
|
|
echo -n " \"$dirname\": [" >> "$OUTPUT_FILE"
|
|
|
|
# Get files sorted by modification time (oldest first)
|
|
# Exclude .jpg files that have a corresponding video file (thumbnails)
|
|
files=$(find "$dir" -maxdepth 1 -type f -printf '%T@ %f\n' | sort -n | cut -d' ' -f2-)
|
|
|
|
first_file=true
|
|
while IFS= read -r filename; do
|
|
[ -z "$filename" ] && continue
|
|
|
|
# Skip .jpg files if a video with the same base name exists
|
|
if [[ "$filename" =~ \.jpg$ ]]; then
|
|
base="${filename%.jpg}"
|
|
# Check if any video format exists with this base name
|
|
if ls "$dir/$base".{mp4,mov,avi,webm,mkv,MP4,MOV,AVI,WEBM,MKV} 2>/dev/null | grep -q .; then
|
|
continue
|
|
fi
|
|
fi
|
|
|
|
if [ "$first_file" = false ]; then
|
|
echo -n "," >> "$OUTPUT_FILE"
|
|
fi
|
|
first_file=false
|
|
|
|
echo "" >> "$OUTPUT_FILE"
|
|
echo -n " {\"name\": \"$filename\"}" >> "$OUTPUT_FILE"
|
|
done <<< "$files"
|
|
|
|
echo "" >> "$OUTPUT_FILE"
|
|
echo -n " ]" >> "$OUTPUT_FILE"
|
|
fi
|
|
done
|
|
|
|
echo "" >> "$OUTPUT_FILE"
|
|
echo "}" >> "$OUTPUT_FILE"
|
|
|
|
echo "✓ Manifest generated successfully!"
|