aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2017-09-03 02:12:04 +0530
committerArun Isaac2017-09-03 02:12:04 +0530
commit9f4ebeade27115510a8d863a303b1cafa8ddb9fa (patch)
tree23165370a1c5da94d81e4fe510107927dd7f3606
parent5667a5bb1dec6c15e46ab917773433b19db39c89 (diff)
downloadnasa-apod-gnu-social-bot-9f4ebeade27115510a8d863a303b1cafa8ddb9fa.tar.gz
nasa-apod-gnu-social-bot-9f4ebeade27115510a8d863a303b1cafa8ddb9fa.tar.lz
nasa-apod-gnu-social-bot-9f4ebeade27115510a8d863a303b1cafa8ddb9fa.zip
Support vimeo videos.
* apod-bot.sh: Support vimeo videos as media. Clean up video detection code.
-rwxr-xr-xapod-bot.sh12
1 files 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