commit 33a2fddf06d6309c421b9ae2ae67ff253c482ae4 parent 904cca9342b06dfd408cd08ee3f708c3f6fda3cf Author: hhvn <dev@hhvn.uk> Date: Sat, 19 Jun 2021 17:40:26 +0100 .s/b/ytmeta: rewrite Diffstat:
M | .scripts/bin/ytmeta | | | 19 | +++++-------------- |
1 file changed, 5 insertions(+), 14 deletions(-)
diff --git a/.scripts/bin/ytmeta b/.scripts/bin/ytmeta @@ -1,17 +1,8 @@ -#!/bin/sh - -content=$(curl -H "Accept-Language: en-US" -qsL $1) - +content=$(curl -L "$(echo "$1" | sed 's/invidio.us/www.youtube.com/g;s~embed/~watch?v=~g')") title=$(echo "$content" | grep '\[{\"videoPrimaryInfoRenderer\":{\"title\":{\"runs\"\:\[{\"text\":' | sed 's/.*\[{\"videoPrimaryInfoRenderer\":{\"title\":{\"runs\"\:\[{\"text\":// ; s/}\]}.*// ; s/\\//g ; s/^\"// ; s/.$//') author=$(echo "$content" | grep -o 'author":[^}]*}' | sed -E 's/.*:"([^"]*).*/\1/g') -date=$(echo "$content" | grep -o 'uploadDate":[^}]*}' | sed -E 's/.*:"([^"]*).*/\1/g;s/([0-9]*)-([0-9]*)-([0-9]*)/\3-\2-\1/') -views=$(echo "$content" | grep -o 'viewCount":[^}]*}' | head -n 1 | grep -o 'simpleText":[^}]*}' | sed -E 's/.*:"([^"]*).*/\1/g ; s/ views//;s/ Aufrufe//g;s/\./,/g') -length=$(echo "$content" | grep '\<meta itemprop=\"duration\"' | sed 's/.*content\=// ; s/\"//g ; s/PT// ; s/./\L&/g ; s/.$//') +uploaded=$(echo "$content" | grep -o 'uploadDate":[^}]*}' | sed -E 's/.*:"([^"]*).*/\1/g;s/([0-9]*)-([0-9]*)-([0-9]*)/\3-\2-\1/') -printf "URI: %s\nTitle: %s\nAuthor: %s\nPublished: %s\nLength: %s\nViews: %s\n" \ - "$1" \ - "$title" \ - "$author" \ - "$date" \ - "$length" \ - "$views" +printf 'Title: %s\n' "$title" +printf 'Author: %s\n' "$author" +printf 'Uploaded: %s\n' "$uploaded"