4 . "$_EXEC/cgilite/session.sh" nocookie
7 # newtags='' # tags selected in ui
8 # tags='' # taglist from database
9 # detag='' # temporary remove list
10 # extags='' # exclusive tags, tags that preclude others within their categorie
11 # group='' # id for grouping videos (videos in a group get a common group id)
12 # op='' # operation: add | del | flip
15 for tn in $(seq 1 $(POST_COUNT tag)); do
16 newtags="$(POST tag $tn)${BR}${newtags}"
18 newtags="$(POST newtag |tr -d '\r' |tr , '\n')${BR}${newtags}"
20 if [ "$(POST makegroup)" = true ]; then
24 # strip leading and trailing line breaks
25 while [ "${newtags#${BR}}" != "${newtags}" ]; do newtags="${newtags#${BR}}"; done
26 while [ "${newtags%${BR}}" != "${newtags}" ]; do newtags="${newtags%${BR}}"; done
30 for select in $(seq 1 $(POST_COUNT select)); do
31 file="$(POST select $select)"
32 read_meta "${file%.*}" || continue
34 tags="$(printf %s\\n "$META_TAGS" |tr , \\n)"
36 if [ "$op" = add ]; then
37 extags="$(printf '%s' "${newtags}" |grep -e "^-" |cut -d: -f1 )"
38 [ "$extags" ] && tags="$(printf %s\\n "$tags" |grep -vwFe "$extags")"
39 if printf %s "${newtags}" |grep -e "^-" |grep -qEe "^-[^:]+$"; then
40 tags="$(printf %s\\n "$tags" |grep -vEe '^-[^:]+$')"
42 tags="${tags}${BR}${newtags}"
44 elif [ "$op" = del ]; then
45 detag="${newtags}${BR}"; while [ "$detag" ]; do
46 tags="$(printf '%s\n' "$tags" |grep -vxFe "${detag%%${BR}*}")"
47 detag="${detag#*${BR}}"
50 elif [ "$op" = flip ]; then
51 fliptag="${newtags}${BR}"; while [ "$fliptag" ]; do
53 tags="$(printf '%s\n' "$tags" |grep -vxFe "${fliptag%%${BR}*}")"
54 [ "$comp" = "$tags" ] && tags="${tags}${BR}${fliptag%%${BR}*}"
55 fliptag="${fliptag#*${BR}}"
59 tags="$(printf '%s\n' "$tags" |sort -u |tr '\n' ,)"
60 tags="${tags#,}"; tags="${tags%,}"
63 update_meta "$META_NAME" tags="${tags}" group="${group}"
65 update_meta "$META_NAME" tags="${tags}"
69 ( if [ $(POST_COUNT select) -gt 0 ]; then
71 mv -- "$c_tags.$$" "$c_tags"