Last active
June 25, 2024 14:19
-
-
Save cmj/25269d468618afcbb071d04314883683 to your computer and use it in GitHub Desktop.
Create KOIN webcam montage via new Youtube sources
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Create KOIN webcam montage via new Youtube sources | |
# * Requires Youtube API key | |
# livestream url: https://youtube.com/@KOINLOCAL6/streams | |
# channelId: UCXN7rPhZK6Rp8lMhvpSri_Q | |
# image url: https://i.ytimg.com/vi/wb5uv4SYHe0/maxresdefault.jpg | |
# old: https://media.psg.nexstardigital.net/koin/weather/cameras/Vancouver-Waterfront.jpg | |
# filter: grep -Ev 'Kalama|Evergreen' | |
key="" | |
channelId="UCXN7rPhZK6Rp8lMhvpSri_Q" # ID for @KIONLOCAL6 | |
eventType="live" | |
maxResults="20" # upwards of 14 livestreams | |
part="snippet" | |
type="video" | |
tmpdir=$(mktemp -d /tmp/mosiac-XXX) | |
feeds=$(curl -sG "https://www.googleapis.com/youtube/v3/search" \ | |
-d "key=${key}" \ | |
-d "channelId=${channelId}" \ | |
-d "eventType=${eventType}" \ | |
-d "maxResults=${maxResults}" \ | |
-d "part=${part}" \ | |
-d "type=${type}" | | |
jq -r '.items[]| "\(.id.videoId) \(.snippet.title)"' | | |
grep -Ev 'Kalama' | | |
sed 's|Oregon's ||;s|Subaru of Portland's ||;s/\&/\&/g') | |
n=1 | |
#s=$(date +%s) | |
while read id title; do | |
echo cam $n "https://i.ytimg.com/vi/${id}/maxresdefault.jpg ${title}" | |
curl -s "https://i.ytimg.com/vi/${id}/maxresdefault.jpg?${RANDOM}" -o "${tmpdir}/${id}.jpg" | |
convert -fill white -undercolor '#00000080' -pointsize 42 \ | |
-gravity NorthWest -draw "text 10,10 ' ${title} '" "${tmpdir}/${id}.jpg" "${tmpdir}/${id}.jpg" | |
((n++)) | |
done <<< "${feeds}" | |
montage -geometry '1280x720' -background black +adjoin -tile 4x3 "${tmpdir}/*.jpg[0]" "${tmpdir}/mosaic.jpg" | |
# upload to imgur | |
imgur "${tmpdir}/mosaic.jpg" | |
rm -r "${tmpdir}" | |
# successful run: | |
# $ ./koin.sh | |
# cam 1 https://i.ytimg.com/vi/DMRhJGfxfo0/maxresdefault.jpg Mt. Hood Territory | |
# cam 2 https://i.ytimg.com/vi/7h1YnQP0nUA/maxresdefault.jpg Chinook Winds Casino Resort in Lincoln City, OR | |
# cam 3 https://i.ytimg.com/vi/PQjSpQdoQSU/maxresdefault.jpg Hotel Indigo Kirkland Tower at Vancouver Waterfront | |
# cam 4 https://i.ytimg.com/vi/YgZmQarTd1I/maxresdefault.jpg City of Seaside | |
# cam 5 https://i.ytimg.com/vi/X7cYmyWful0/maxresdefault.jpg Oregon Coast Aquarium | |
# cam 6 https://i.ytimg.com/vi/fdY10DVfIsQ/maxresdefault.jpg Mt Hood Meadows | |
# cam 7 https://i.ytimg.com/vi/Ifga5t8zQRM/maxresdefault.jpg Riverview Bank in Vancouver WA | |
# cam 8 https://i.ytimg.com/vi/4kIfs4x9LQM/maxresdefault.jpg Explore Tualatin Valley | |
# cam 9 https://i.ytimg.com/vi/JyyEawlRvyI/maxresdefault.jpg Stoller Family Estate in Dayton OR | |
# cam 10 https://i.ytimg.com/vi/0b9SZYwnpU4/maxresdefault.jpg KOIN Tower Southwest View | |
# cam 11 https://i.ytimg.com/vi/8JTWQYXDUzM/maxresdefault.jpg KOIN Tower Northeast view | |
# cam 12 https://i.ytimg.com/vi/wb5uv4SYHe0/maxresdefault.jpg ilani Hotel in Ridgefield, Washington | |
# https://i.imgur.com/QxVcu6n.jpeg | |
# Delete page: https://imgur.com/delete/foobar12345 |
Author
cmj
commented
Jun 25, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment