From 9f4ebeade27115510a8d863a303b1cafa8ddb9fa Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Sun, 3 Sep 2017 02:12:04 +0530 Subject: Support vimeo videos. * apod-bot.sh: Support vimeo videos as media. Clean up video detection code. --- apod-bot.sh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/apod-bot.sh b/apod-bot.sh index 5bd3952..ffa2a1d 100755 --- a/apod-bot.sh +++ b/apod-bot.sh @@ -27,14 +27,12 @@ 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/ *$//') -image_link=$apod_base_url/$(echo "$apod_html" | pup -p 'img attr{src}') -youtube_video_id=$(echo "$apod_html" | pup 'iframe attr{src}' | awk -F/ '{print $5}' | awk -F? '{print $1}') -youtube_link="https://www.youtube.com/watch?v=$youtube_video_id" -if [[ -z "$youtube_video_id" ]] -then - media_link=$image_link +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=$youtube_link + media_link=$(echo "$apod_html" | pup 'iframe attr{src}' | sed 's/?.*//' \ + | sed 's|player.vimeo.com/video|vimeo.com|' \ + | sed 's|embed/|watch?v=|') 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