Skip to content

Instantly share code, notes, and snippets.

@deanet
Last active February 1, 2018 01:07
Show Gist options
  • Save deanet/800ec56e116478498bdee40215a54b35 to your computer and use it in GitHub Desktop.
Save deanet/800ec56e116478498bdee40215a54b35 to your computer and use it in GitHub Desktop.
#!/bin/bash
##auto detect live stream at youtube channel ar-raudhah
#*/5 * * * * /bin/bash -x /home/raudhah/bin/ar-raudhah.live.sh
currentid=`cat /tmp/currentid.txt`
newid=`/usr/bin/curl -vvv -L "https://www.youtube.com/user/arraudhahsolo" | grep "yt-badge-live" -B 10 | grep -A 5 "yt-lockup-title" | grep watch | sed -e 's/^.*\/watch?v=//g' | cut -d \" -f 1`
if [ "$newid" == "" ]; then
newid="xglXZuKqvgk"
echo "id kosong, maybe tidak live";
echo "UPDATE rdh_posts SET
ID = '2',
post_author = '1',
post_date = '2013-01-12 02:04:59',
post_date_gmt = '2013-01-11 19:04:59',
post_content = '<center>LIVE VIDEO\n<iframe src=\"https://www.youtube.com/embed/"$newid"\" width=\"100%\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"></iframe>\n<audio controls=\"controls\">\n<source src=\"http://audio.aswajacenter.com:4818/;stream.mp3\" type=\"audio/mpeg\" />&nbsp;\n\n</audio></center>\n<p style=\"text-align: center;\"></p>',
post_title = 'Live Streaming',
post_excerpt = '',
post_status = 'publish',
comment_status = 'open',
ping_status = 'closed',
post_password = '',
post_name = 'live',
to_ping = '',
pinged = '',
post_modified = '2016-01-31 04:18:17',
post_modified_gmt = '2016-01-30 21:18:17',
post_content_filtered = '',
post_parent = '0',
guid = 'http://ar-raudhah.info/?page_id=2',
menu_order = '0',
post_type = 'page',
post_mime_type = '',
comment_count = '0'
WHERE ID = '2';" > /home/raudhah/bin/update-live.sh
/usr/bin/mysql -u raudhah_ar -p'MHQWFsVlkR' raudhah_ar < /home/raudhah/bin/update-live.sh
elif [ "$newid" == "$currentid" ]; then
echo "id masih sama";
else [ "$newid" != "currentid" ];
echo "mantabbb, newid: $newid";
echo "$newid" > /tmp/currentid.txt;
#echo '<center>LIVE VIDEO
#<iframe src="https://www.youtube.com/embed/'$newid'" width="100%" height="315" frameborder="0" allowfullscreen="allowfullscreen"></iframe>
#<center>' > /home/raudhah/web/ar-raudhah.info/public_html/live.html
echo "UPDATE rdh_posts SET
ID = '2',
post_author = '1',
post_date = '2013-01-12 02:04:59',
post_date_gmt = '2013-01-11 19:04:59',
post_content = '<center>LIVE VIDEO\n<iframe src=\"https://www.youtube.com/embed/"$newid"\" width=\"100%\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"></iframe>\n<audio controls=\"controls\">\n<source src=\"http://audio.aswajacenter.com:4818/;stream.mp3\" type=\"audio/mpeg\" />&nbsp;\n\n</audio></center>\n<p style=\"text-align: center;\"></p>',
post_title = 'Live Streaming',
post_excerpt = '',
post_status = 'publish',
comment_status = 'open',
ping_status = 'closed',
post_password = '',
post_name = 'live',
to_ping = '',
pinged = '',
post_modified = '2016-01-31 04:18:17',
post_modified_gmt = '2016-01-30 21:18:17',
post_content_filtered = '',
post_parent = '0',
guid = 'http://ar-raudhah.info/?page_id=2',
menu_order = '0',
post_type = 'page',
post_mime_type = '',
comment_count = '0'
WHERE ID = '2';" > /home/raudhah/bin/update-live.sh
/usr/bin/mysql -u raudhah_ar -p'MHQWFsVlkR' raudhah_ar < /home/raudhah/bin/update-live.sh
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment