From 4bfe9173ed9416fe79b6147ff33ee5767f4cfdd0 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Sun, 29 Apr 2018 18:40:19 +0530 Subject: Prepend https scheme if absent in media URI. * apod-bot.sh: Prepend https scheme if absent in media URI. Re-indent title extraction code. --- apod-bot.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apod-bot.sh b/apod-bot.sh index 5527077..85f503d 100755 --- a/apod-bot.sh +++ b/apod-bot.sh @@ -31,13 +31,14 @@ send-request -o /dev/null $social_api_url/statuses/home_timeline.json apod_html=$(curl -sS $apod_base_url/astropix.html) title=$(echo "$apod_html" | pup 'center:nth-child(2) > b:nth-child(1) text{}' \ - | sed -e 's/^ *//' -e 's/ *$//') + | sed -e 's/^ *//' -e 's/ *$//') if [[ -z "$(echo "$apod_html" | pup 'iframe attr{src}')" ]]; then media_link=$apod_base_url/$(echo "$apod_html" | pup -p 'img attr{src}') else media_link=$(echo "$apod_html" | pup 'iframe attr{src}' | sed 's/?.*//' \ | sed 's|player.vimeo.com/video|vimeo.com|' \ - | sed 's|embed/|watch?v=|') + | sed 's|embed/|watch?v=|' \ + | sed 's|^//|https://|') fi date=$(echo "$apod_html" | pup ':contains("Discuss") attr{href}' | awk -F= '{print $2}') page_link=$apod_base_url/ap$date.html -- cgit v1.2.3