Update code

This commit is contained in:
2025-08-20 23:33:52 +07:00
parent 7e99b228f5
commit a02171820c
29 changed files with 553 additions and 0 deletions

26
Moodle/SH/genmedia.sh Normal file
View File

@@ -0,0 +1,26 @@
#!/bin/bash
# Thư mục gốc của khóa học
COURSE_FOLDER="$(pwd)"
# Tìm tất cả các thư mục con
mapfile -t DIRS < <(find "$COURSE_FOLDER" -type d)
for dir in "${DIRS[@]}"; do
relative_path="${dir#*/vod/}"
OUTPUT_JSON="$dir/mdl.media"
# Xóa tệp mdl.media cũ nếu tồn tại
rm -f "$OUTPUT_JSON"
# Tìm và sắp xếp các file .mp3 và .mp4 theo thứ tự tự nhiên
mapfile -d '' -t FILES < <(find "$dir" -maxdepth 1 -type f \( -name '*.mp3' -o -name '*.mp4' \) -print0 | sort -z -V)
for file in "${FILES[@]}"; do
filename=$(basename "$file")
vid="$relative_path/$filename"
echo "[stream=$vid]" >> "$OUTPUT_JSON"
done
echo "File mdl.media created successfully in $dir."
done