- info="$1"
- cache="${info%/*}/.index/${info##*/}.cache"
- meta="${info%/*}/.index/${info##*/}.meta"
-
- if [ "$cache" -ont "$meta" ]; then
- cat "$cache"
- else
- videofile="$info"
- thumb="${info%/*}/.index/${info##*/}.jpg"
- [ -f "$thumb" ] || genthumb "$videofile" "$thumb"
- [ -f "$meta" ] || genmeta "$videofile" "$meta"
-
- { read -r length width height filename
- read -r tags
- } <"$meta"
- length=$(validate "$length" '[0-9]+' 0)
- width=$(validate "$width" '[0-9]+' 0)
- height=$(validate "$height" '[0-9]+' 0)
-
- video="$(urlsafe "$info")"
- thumb="$(urlsafe "$directory/.index/${info##*/}.jpg")"
- linkinfo="$(urlsafe "${directory%/}/${info##*/}")"
- htmlinfo="$(htmlsafe "${info##*/}")"
- attrinfo="$(attribsafe "$info")"
-
- minutes="$(printf "%d:%02d" $(($length / 60)) $(($length % 60)) )"
-
- tee "$cache" <<VIDEOend
- <li id="$attrinfo" class="thumb">
- <button class="watchlink" name="${linkinfo}" formaction="?action=watch&l=${linkinfo}">
- <img src="$thumb" alt="Preview not yet available">
- </button>
- <h2><a href="?action=watch&l=${linkinfo}">${htmlinfo}</a></h2>
-
- <input type="checkbox" name="tagsel" value="${htmlinfo}">
- <span class="info property">${minutes}min</span>
- <span class="info property">${width}x${height}</span>
- $(printf %s "$tags" |sed -r 's:\|*([^|]+)\|*: <span class="info tag">\1</span>:g')
- </li>
+ name="$1"
+
+ video="${treeroot%/}/${directory%/}/${name}"
+ thumb="${treeroot%/}/${directory%/}/.index/${name}.jpg"
+ meta="${treeroot%/}/${directory%/}/.index/${name}.meta"
+
+ [ -f "$thumb" ] || genthumb "$video" "$thumb"
+ [ -f "$meta" ] || genmeta "$video" "$meta"
+
+ { read -r length width height filename
+ read -r tags
+ } <"$meta"
+ read length width height <<-EOF
+ $(validate "$length $width $height" '[0-9]+ [0-9]+ [0-9]+' "0 0 0")
+ EOF
+
+ location="$(attribsafe "${directory%/}/${name}")"
+ thumblocation="$(attribsafe "${directory%/}/.index/${name}.jpg")"
+ display="$(htmlsafe "$name")"
+
+ minutes="$(printf "%d:%02d" $(($length / 60)) $(($length % 60)) )"
+
+ cat <<VIDEOend
+ <li id="${location}" class="thumb">
+ <button class="watchlink" name="${location}" formaction="?action=watch&l=${location}">
+ <img src="${thumblocation}" alt="Preview not yet available">
+ </button>
+ <h2><a href="?action=watch&l=${location}">${display}</a></h2>
+
+ <input type="checkbox" name="tagsel" value="${location}">
+ <span class="info property">${minutes}min</span>
+ <span class="info property">${width}x${height}</span>
+ $(printf %s "$tags" |sed -r 's:\|*([^|]+)\|*: <span class="info tag">\1</span>:g')
+ </li>