From 08d52f49face6aeeb1eeccddbdebf1f96451c259 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Thu, 30 Sep 2021 19:40:24 +0200 Subject: [PATCH] automatic meta data --- page_video.sh | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/page_video.sh b/page_video.sh index 1da7f0b..e1a2ae3 100644 --- a/page_video.sh +++ b/page_video.sh @@ -1,5 +1,7 @@ #!/bin/sh +# ID NAME DESCRIPTION RESX RESY LENGTH COVER STATUS (void|private|hidden|public) UPLOADER HITS DESCR_CACHE FUTUREUSE + 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 \ @@ -16,33 +18,35 @@ if [ "$video" -a -f "$vid_db" -a -r "$vid_db" ]; then fi fi -# Video -# ID NAME DESCRIPTION RESX RESY LENGTH COVER STATUS (void|private|hidden|public) UPLOADER HITS DESCR_CACHE FUTUREUSE - 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 + local arg video + video="$_DATA/$CHANNEL_ID/$VIDEO_ID.mp4" for arg in "$@"; do case $arg in name=*) name="${arg#*=}";; description=*) description="${arg#*=}";; - resx=*) resx="${arg#*=}";; - resy=*) resy="${arg#*=}";; - length=*) length="${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 LOCK "$vid_db"; then while read -r ID NAME DESCRIPTION RESX RESY LENGTH COVER STATUS UPLOADER HITS \ DESCR_CACHE FUTUREUSE; do if [ "$id" = "$ID" ]; then - printf '%s %s %s %i %i %i %s %s %s %i %s %s\n' \ + printf '%s %s %s %i %i %f %s %s %s %i %s %s\n' \ "$id" "$(STRING "${name-$(UNSTRING "$NAME")}")" \ "$(STRING "${description-$(UNSTRING "$DESCRIPTION")}")" \ "${resx:-${resx-${RESX}}${resx+0}}" \ -- 2.39.2