admin: various fixes in fill_exercices
This commit is contained in:
parent
119280d814
commit
0b4e8a233c
@ -61,7 +61,7 @@ new_key() {
|
|||||||
THEME="$1"
|
THEME="$1"
|
||||||
EXERCICE="$2"
|
EXERCICE="$2"
|
||||||
TYPE="$3"
|
TYPE="$3"
|
||||||
KEY=`echo $4 | sed 's/"/\\\\"/g' | sed 's#\\\\#\\\\\\\\#g'`
|
KEY=`echo $4 | sed 's#\\\\#\\\\\\\\#g' | sed 's/"/\\\\"/g'`
|
||||||
|
|
||||||
curl -f -s -d "{\"type\": \"$TYPE\", \"key\": \"$KEY\"}" "${BASEURL}/api/themes/$THEME/exercices/$EXERCICE/keys" |
|
curl -f -s -d "{\"type\": \"$TYPE\", \"key\": \"$KEY\"}" "${BASEURL}/api/themes/$THEME/exercices/$EXERCICE/keys" |
|
||||||
grep -Eo '"id":[0-9]+,' | grep -Eo "[0-9]+"
|
grep -Eo '"id":[0-9]+,' | grep -Eo "[0-9]+"
|
||||||
@ -80,6 +80,7 @@ get_file_from_cloud() {
|
|||||||
}
|
}
|
||||||
get_file() {
|
get_file() {
|
||||||
cat "${BASEFILE}$1" 2> /dev/null | tr -d '\r'
|
cat "${BASEFILE}$1" 2> /dev/null | tr -d '\r'
|
||||||
|
echo
|
||||||
}
|
}
|
||||||
#alias get_file=get_file_from_cloud
|
#alias get_file=get_file_from_cloud
|
||||||
|
|
||||||
@ -98,7 +99,7 @@ unhtmlentities() {
|
|||||||
do
|
do
|
||||||
THM_BASEURI="/${THEME_URI}/"
|
THM_BASEURI="/${THEME_URI}/"
|
||||||
THEME_NAME=$(echo "${THEME_URI#*-}" | unhtmlentities)
|
THEME_NAME=$(echo "${THEME_URI#*-}" | unhtmlentities)
|
||||||
THEME_AUTHORS=$(get_file "${THM_BASEURI}/AUTHORS.txt" | sed 's/$/, /' | tr -d '\n' | sed 's/, $//')
|
THEME_AUTHORS=$(get_file "${THM_BASEURI}/AUTHORS.txt" | sed '/^$/d;s/$/, /' | tr -d '\n' | sed 's/, $//')
|
||||||
THEME_ID=`new_theme "$THEME_NAME" "$THEME_AUTHORS"`
|
THEME_ID=`new_theme "$THEME_NAME" "$THEME_AUTHORS"`
|
||||||
if [ -z "$THEME_ID" ]; then
|
if [ -z "$THEME_ID" ]; then
|
||||||
echo -e "\e[31;01m!!! An error occured during theme add\e[00m"
|
echo -e "\e[31;01m!!! An error occured during theme add\e[00m"
|
||||||
@ -132,7 +133,7 @@ do
|
|||||||
|
|
||||||
EXO_BASEURI="${EXO_URI}/"
|
EXO_BASEURI="${EXO_URI}/"
|
||||||
|
|
||||||
EXO_VIDEO=$(get_dir "${THM_BASEURI}${EXO_BASEURI}/resolution/" | grep -E "\.(mov|mkv|mp4|avi|flv|ogv|webm)$" | while read f; do basename $f; done | tail -1)
|
EXO_VIDEO=$(get_dir "${THM_BASEURI}${EXO_BASEURI}/resolution/" | grep -E "\.(mov|mkv|mp4|avi|flv|ogv|webm)$" | while read f; do basename "$f"; done | tail -1)
|
||||||
[ -n "$EXO_VIDEO" ] && EXO_VIDEO="/resolution${THM_BASEURI}${EXO_BASEURI}resolution/${EXO_VIDEO}"
|
[ -n "$EXO_VIDEO" ] && EXO_VIDEO="/resolution${THM_BASEURI}${EXO_BASEURI}resolution/${EXO_VIDEO}"
|
||||||
|
|
||||||
if [ "${LAST}" = "null" ]; then
|
if [ "${LAST}" = "null" ]; then
|
||||||
@ -158,6 +159,8 @@ do
|
|||||||
# Keys
|
# Keys
|
||||||
get_file "${THM_BASEURI}${EXO_BASEURI}/flags.txt" | while read KEYLINE
|
get_file "${THM_BASEURI}${EXO_BASEURI}/flags.txt" | while read KEYLINE
|
||||||
do
|
do
|
||||||
|
[ -z "${KEYLINE}" ] && continue
|
||||||
|
|
||||||
KEY_NAME=$(echo "$KEYLINE" | cut -d : -f 1)
|
KEY_NAME=$(echo "$KEYLINE" | cut -d : -f 1)
|
||||||
KEY_RAW=$(echo "$KEYLINE" | cut -d : -f 2-)
|
KEY_RAW=$(echo "$KEYLINE" | cut -d : -f 2-)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user