forked from laurensorensen/DPDP_Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuploadaccess
More file actions
executable file
·61 lines (53 loc) · 2.2 KB
/
uploadaccess
File metadata and controls
executable file
·61 lines (53 loc) · 2.2 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
#!/bin/bash
scriptdir=$(dirname $(which "$0"))
. "${scriptdir}/mmfunctions" || { echo "Missing '${scriptdir}/mmfunctions'. Exiting." ; exit 1 ;};
force=""
cleanup(){
_log -a "Process aborted"
exit 1
}
usage(){
echo didnt write it yet
exit
}
# command-line options to set mediaid and original variables
OPTIND=1
while getopts ":fh:" opt; do
case "$opt" in
f) force="Y" ;;
h) usage ;;
\?) echo "Invalid option: -$OPTARG" ; exit 1 ;;
:) echo "Option -$OPTARG requires an argument" ; exit 1 ;;
esac
done
shift $(( ${OPTIND} - 1 ))
package_path="${1}"
if [ -z "${package_path}" ]; then
report -w "The path to the AIP package must be declared."
exit 1
fi
trap cleanup SIGHUP SIGINT SIGTERM
_log -b
package_dir=$(dirname "${package_path}")
pkgname=$(basename "${package_path}")
pbcoreid=$(cat "${package_path}/metadata/submissionDocumentation/pbcoreurl.txt" | grep -o ........-....-....-....-............)
thumbnail_file=$(find "${package_path}/objects/access/" -type f \( -name '*.jpg' -o -name '*.jpeg' \) | head -n 1)
video_file=$(find "${package_path}/objects/access/" -type f -name '*.mp4' | head -n 1)
report -d "pbcoreid ${pbcoreid}"
report -d "thumbnail_file ${thumbnail_file}"
report -d "video_file ${video_file}"
if [ ! -n "${pbcoreid}" -o ! -s "${thumbnail_file}" -o ! -s "${video_file}" ] ; then
report -w "The upload script requires a valid pbcoreurl.txt file, thumbnail, and video proxy."
exit 1
fi
if [ ! "$force" = "Y" ] ;then
if [ $(curl "http://archive.danceheritage.org/assets/${pbcoreid}.xml" | grep "<formatDigital>video/mp4</formatDigital>") ] ; then
report -w "The asset seems to already have an access copy at http://archive.danceheritage.org/assets/${pbcoreid}"
exit 86
elif [ -s "${1}/metadata/submissionDocumentation/logs/upload_log.txt" ] ; then
report -w "An upload log already exists, upload cancelled."
exit 1
fi
fi
eval "${scriptdir}/upload-video --site http://archive.danceheritage.org/ --asset '${pbcoreid}' --thumbnail '${thumbnail_file}' --video '${video_file}' --user ${PBCORE_USERNAME} --pass ${PBCORE_PASSWORD}" 2>&1 | tee "${1}/metadata/submissionDocumentation/logs/upload_log.txt"
_log -e