45 lines
808 B
Bash
Executable File
45 lines
808 B
Bash
Executable File
#!/bin/sh
|
|
##############################
|
|
# name: yt-desc
|
|
# lisc: gnu gplv3
|
|
# main: jadedctrl
|
|
# desc: print desc of yt video
|
|
##############################
|
|
|
|
# Usage: yt-desc "$url/id"
|
|
|
|
# STRING --> STRING
|
|
# Get the description of a YT video, from HTML.
|
|
function video_desc {
|
|
local html="$1"
|
|
|
|
echo "$html" \
|
|
| grep "action-panel-details" \
|
|
| sed 's/.*<p .*class="" >//' \
|
|
| sed 's%</p>.*%%' \
|
|
| lynx -stdin -dump \
|
|
| sed 's/^ //'
|
|
}
|
|
|
|
# --------------------------------------
|
|
# invocation
|
|
|
|
function usage {
|
|
echo "usage: yt-desc url/id"
|
|
exit 2
|
|
}
|
|
|
|
# --------------------------------------
|
|
|
|
if test -z "$1"; then
|
|
usage
|
|
elif echo "$1" | grep "youtube" > /dev/null; then
|
|
URL="$1"
|
|
else
|
|
URL="https://www.youtube.com/watch?v=${1}"
|
|
fi
|
|
|
|
# --------------------------------------
|
|
|
|
video_desc "$(gendl "$URL")"
|