new.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/bash
  2. # Video ID
  3. videoID=$(date +%s%N | md5sum | head -c 22)
  4. # Load data
  5. printf '%s' "Enter Title: "
  6. read -r
  7. title="$REPLY"
  8. printf '%s' "Enter Author: "
  9. read -r
  10. author="$REPLY"
  11. printf '%s' "Enter Category: "
  12. read -r
  13. category="$REPLY"
  14. # Slug | lowercase, without accent mark
  15. lug=$(printf '%s' "${title// /-}")
  16. slug=$(echo "$lug" | sed 'y/áÁàÀãÃâÂéÉêÊíÍóÓõÕôÔúÚñÑçÇ/aAaAaAaAeEeEiIoOoOoOuUnNcC/' | sed -e 's/\(.*\)/\L\1/')
  17. printf '%s' "Enter Tags: "
  18. read -r
  19. tag="$REPLY"
  20. # output
  21. o_videoid=$(printf '%s%s\n' "VideoID: " "$videoID")
  22. o_author=$(printf '%s%s\n' "Author: " "$author")
  23. o_category=$(printf '%s%s\n' "Category: " "$category")
  24. o_date=$(printf '%s%s\n' "Date: " "$(date +"%Y-%m-%d %T")")
  25. o_slug=$(printf '%s%s\n' "Slug: " "$slug")
  26. o_tag=$(printf '%s%s\n' "Tags: " "$tag")
  27. o_title=$(printf '%s%s\n' "Title: " "$title")
  28. # export to file.md
  29. printf '%s\n%s\n%s\n%s\n%s\n%s\n' "$o_author"\
  30. "$o_category"\
  31. "$o_date"\
  32. "$o_videoid"\
  33. "$o_slug"\
  34. "$o_tag"\
  35. "$o_title" > "$slug.md"