-if [ "$video" -a -f "$vid_db" -a -r "$vid_db" ]; then
- read -r VIDEO_ID VIDEO_NAME VIDEO_DESCRIPTION VIDEO_RESX VIDEO_RESY \
- VIDEO_LENGTH VIDEO_COVER VIDEO_STATUS VIDEO_UPLOADER VIDEO_HITS \
- VIDEO_DESCR_CACHE VIDEO_FUTUREUSE <<-EOF
- $(grep "^${video} " "${vid_db}")
- EOF
- if [ "$VIDEO_ID" ]; then
- VIDEO_NAME="$(UNSTRING "$VIDEO_NAME")"
- VIDEO_DESCRIPTION="$(UNSTRING "$VIDEO_DESCRIPTION")"
- VIDEO_COVER="$(UNSTRING "$VIDEO_COVER")"
- VIDEO_DESCR_CACHE="$(UNSTRING "$VIDEO_DESCR_CACHE")"
- else
- video=''
- fi
-fi
-
-update_video(){
- local id="${1}" name description resx resy length cover status uploader \
- hits descr_cache futureuse
- local ID NAME DESCRIPTION RESX RESY LENGTH COVER STATUS UPLOADER HITS \
- DESCR_CACHE FUTUREUSE
- local arg video thumb
- video="${_DATA}/${CHANNEL_ID}/${VIDEO_ID}.mp4"
- thumb="${_DATA}/${CHANNEL_ID}/${VIDEO_ID}_thumb.jpg"
-
- for arg in "$@"; do case $arg in
- name=*) name="${arg#*=}";;
- description=*) description="${arg#*=}";;
- cover=*) cover="${arg#*=}";;
- status=*) status="${arg#*=}";;
- uploader=*) uploader="${arg#*=}";;
- hits=*) hits="${arg#*=}";;
- esac; done
-
- if [ -f "$video" -a -r "$video" ]; then
- arg="$(echo; ffprobe -show_entries stream=width,height,duration "$video" 2>&-)"
- resx="${arg#*width=}"; resx="${resx%%${BR}*}"
- resy="${arg#*height=}"; resy="${resy%%${BR}*}"
- length="${arg#*duration=}"; length="${length%%${BR}*}"
- fi
- if [ "$length" -a ! "${thumb}" -nt "${video}" ]; then
- ffmpeg -nostdin -y -i "$video" -vf scale=320:-2,fps=10/${length} "${thumb%.jpg}_%02d.jpg"
- montage "${thumb%.jpg}_"[01][0-9].jpg -tile 10x1 -geometry 320x180+0+0 -quality 85 "${thumb}"
- rm -- "${thumb%.jpg}_"[01][0-9].jpg
- fi 2>&-