forked from laurensorensen/DPDP_Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakemetadata
More file actions
executable file
·69 lines (62 loc) · 2.63 KB
/
makemetadata
File metadata and controls
executable file
·69 lines (62 loc) · 2.63 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
# make metadata
version="0.2"
scriptdir=$(dirname $(which "$0"))
. "$scriptdir/mmfunctions" || { echo "Missing '$scriptdir/mmfunctions'. Exiting." ; exit 1 ;};
dependencies=(ffprobe mediainfo exiftool)
_initialize_make
usage(){
echo
echo "$(basename ${0}) ${version}"
echo "This script may be run interactively by running it with no arguments or may be used with the following options."
echo "Usage: $(basename $0) [ -m mediaid ]"
echo " -n (dry-run mode, show the commands that would be run but don't do anything)"
echo " -m mediaid"
exit
}
[ "${#}" = 0 ] && usage
# command-line options to set mediaid and original variables
OPTIND=1
while getopts ":e:E:nh" opt ; do
case "${opt}" in
e) emailaddress_delivery="$OPTARG" && check_emailaddress "${emailaddress_delivery}" ;;
E) emailaddress_outcome="$OPTARG" && check_emailaddress "${emailaddress_outcome}" ;;
n) DRYRUN=true;;
h) usage ;;
*) echo "bad option -$OPTARG" ; usage ;;
:) echo "Option -$OPTARG requires an argument" ; exit 1 ;;
esac
done
shift $(( ${OPTIND} - 1 ))
_log -b
outputdir="./metadata/submissionDocumentation/fileMeta"
_run mkdir -p "$outputdir"
while [ "$*" != "" ] ; do
uuid=$(uuidgen)
package_path="$1"
mediaid=$(basename "$package_path" | cut -d. -f1)
pwd=$(pwd)
cd "$package_path"
FILELIST=$(maketemp)
find "./objects" -type f ! -name ".*" > "$FILELIST"
if [ -d ./objects/service ] ; then
service_file=$(find "./objects/service" -maxdepth 1 -mindepth 1 -type f ! -name ".*")
servicebasename=$(basename "$service_file")
fi
while read file ; do
filenameroot=$(basename "$file")
parentdir=$(dirname "$file")
fileoutput="$outputdir/$parentdir"
_run mkdir -p "$fileoutput"
_run ffprobe 2> /dev/null "$file" -show_format -show_streams -show_data -show_error -show_versions -show_chapters -noprivate -of xml="q=1:x=1" > "$fileoutput/${filenameroot%.*}_ffprobe.xml"
_run ffprobe 2> /dev/null "$file" -show_format -show_streams -show_data -show_error -show_versions -show_chapters -of json > "$fileoutput/${filenameroot%.*}_ffprobe.json"
_run mediainfo --language=raw -f --output=XML "$file" > "$fileoutput/${filenameroot%.*}_mediainfo.xml"
_run mediainfo --inform="Details;1" "$file" > "$fileoutput/${filenameroot%.*}_mediainfo_trace.txt"
_run exiftool -X "$file" > "$fileoutput/${filenameroot%.*}_exiftool.xml"
_run exiftool "$file" > "$fileoutput/${filenameroot%.*}_exiftool.txt"
done < "$FILELIST"
cd "$pwd"
_run rm -r -f "$FILELIST"
shift
_log -e
done