#!/bin/rc if(! ~ $#* 1 || ! ~ $1 http*){ echo usage: $0 url >[1=2] exit usage } hget `{echo $1 | sed 's,(https?://[^/]+).*/([^/]+),\1/api/v1/videos/\2,'} | jb -p | awk ' /^((account\/)?name|publishedAt|description|streamingPlaylists\[[0-9]+\]\/files\[[0-9]+\]\/(fileDownloadUrl|resolution\/label)): /{sub(/[^ ]+ /, ""); print} /^duration: /{printf "%.2d:%.2d:%.2d\n", $2 / 60 / 60, $2 / 60 % 60, $2 % 60} /^streamingPlaylists\[[0-9]+\]\/files\[[0-9]+\]\/size: /{ if($2 < 1024) print $2 " bytes" else if($2 < 1024 * 1024) printf "%.1f kilobytes\n", $2 / 1024 else if($2 < 1024 * 1024 * 1024) printf "%.1f megabytes\n", $2 / 1024 / 1024 else printf "%.1f gigabytes\n", $2 / 1024 / 1024 / 1024 }'