diff --git a/data_error_handling.sh b/data_error_handling.sh new file mode 100755 index 0000000000000000000000000000000000000000..3ece6b2d0941fe832feb2fd5674275a0fead5e04 --- /dev/null +++ b/data_error_handling.sh @@ -0,0 +1,129 @@ +#!/bin/bash + +date=$(date +%d-%m-%Y) +time=$(date "+%H:%M:%S %p") + +if (curl -sSf "https://www.youtube.com/watch?v=F2pQEXieIqM" > /dev/null) +then + curl -s https://www.youtube.com/watch?v=F2pQEXieIqM > /home/admin/Documents/cw2/musicPlaylist.html + video1=$(cat musicPlaylist.html | grep -o 'viewCount":{"videoViewCountRenderer":{"viewCount":{"simpleText":"[0-9,]\+' | grep -o '[0-9,]\+' | sed 's/[^$.0-9]*//g') + echo "musicPlaylist,$video1,$date $time" >> /home/admin/Documents/cw2/musicPlaylist.txt + $(/opt/lampp/bin/mysql -u root -e "use data; insert into YoutubeViews (Name,Views,DateTime) values ('musicPlaylist', $video1, default)") + +else + echo "musicPlaylist Youtube link error." +fi + + + +if (curl -sSf "https://www.youtube.com/watch?v=togcVWa-90I" > /dev/null) +then + curl -s https://www.youtube.com/watch?v=togcVWa-90I > /home/admin/Documents/cw2/jvkeMusic.html + video2=$(cat jvkeMusic.html | grep -o 'viewCount":{"videoViewCountRenderer":{"viewCount":{"simpleText":"[0-9,]\+' | grep -o '[0-9,]\+' | sed 's/[^$.0-9]*//g') + echo "jvkeMusic,$video2,$date $time" >> /home/admin/Documents/cw2/jvkeMusic.txt + $(/opt/lampp/bin/mysql -u root -e "use data; insert into YoutubeViews (Name,Views,DateTime) values ('jvkeMusic', $video2, default)") + +else + echo "jvkeMusic Youtube link error." +fi + + + +if (curl -sSf "https://www.youtube.com/watch?v=6ZUIwj3FgUY" > /dev/null) +then + curl -s https://www.youtube.com/watch?v=6ZUIwj3FgUY > /home/admin/Documents/cw2/iveMusic.html + video8=$(cat iveMusic.html | grep -o 'viewCount":{"videoViewCountRenderer":{"viewCount":{"simpleText":"[0-9,]\+' | grep -o '[0-9,]\+' | sed 's/[^$.0-9]*//g') + echo "iveMusic,$video8,$date $time" >> /home/admin/Documents/cw2/iveMusic.txt + $(/opt/lampp/bin/mysql -u root -e "use data; insert into YoutubeViews (Name,Views,DateTime) values ('iveMusic', $video8, default)") + +else + echo "iveMusic Youtube link error." +fi + + + +if (curl -sSf "https://www.youtube.com/watch?v=a3QioFosUxQ" > /dev/null) +then + curl -s https://www.youtube.com/watch?v=a3QioFosUxQ > /home/admin/Documents/cw2/gamingVideo.html + video3=$(cat gamingVideo.html | grep -o 'viewCount":{"videoViewCountRenderer":{"viewCount":{"simpleText":"[0-9,]\+' | grep -o '[0-9,]\+' | sed 's/[^$.0-9]*//g') + echo "gamingVideo,$video3,$date $time" >> /home/admin/Documents/cw2/gamingVideo.txt + $(/opt/lampp/bin/mysql -u root -e "use data; insert into YoutubeViews (Name,Views,DateTime) values ('gamingVideo', $video3, default)") + +else + echo "gamingVideo Youtube link error." +fi + + + +if (curl -sSf "https://www.youtube.com/watch?v=nUPm-loO4FE" > /dev/null) +then + curl -s https://www.youtube.com/watch?v=nUPm-loO4FE > /home/admin/Documents/cw2/mukbangVideo.html + video4=$(cat mukbangVideo.html | grep -o 'viewCount":{"videoViewCountRenderer":{"viewCount":{"simpleText":"[0-9,]\+' | grep -o '[0-9,]\+' | sed 's/[^$.0-9]*//g') + echo "mukbangVideo,$video4,$date $time" >> /home/admin/Documents/cw2/mukbangVideo.txt + $(/opt/lampp/bin/mysql -u root -e "use data; insert into YoutubeViews (Name,Views,DateTime) values ('mukbangVideo', $video4, default)") +else + echo "mukbangVideo Youtube link error." +fi + + + +if (curl -sSf "https://www.youtube.com/watch?v=o_UbEhAYl8Q" > /dev/null) +then + curl -s https://www.youtube.com/watch?v=o_UbEhAYl8Q > /home/admin/Documents/cw2/documentary.html + video5=$(cat documentary.html | grep -o 'viewCount":{"videoViewCountRenderer":{"viewCount":{"simpleText":"[0-9,]\+' | grep -o '[0-9,]\+' | sed 's/[^$.0-9]*//g') + echo "documentary,$video5,$date $time" >> /home/admin/Documents/cw2/documentary.txt + $(/opt/lampp/bin/mysql -u root -e "use data; insert into YoutubeViews (Name,Views,DateTime) values ('documentary', $video5, default)") +else + echo "documentary Youtube link error." +fi + + + +if (curl -sSf "https://www.youtube.com/watch?v=ENkugc7KWbA" > /dev/null) +then + curl -s https://www.youtube.com/watch?v=ENkugc7KWbA > /home/admin/Documents/cw2/offlineTVVideo.html + video6=$(cat offlineTVVideo.html | grep -o 'viewCount":{"videoViewCountRenderer":{"viewCount":{"simpleText":"[0-9,]\+' | grep -o '[0-9,]\+' | sed 's/[^$.0-9]*//g') + echo "offlineTVVideo,$video6,$date $time" >> /home/admin/Documents/cw2/offlineTVVideo.txt + $(/opt/lampp/bin/mysql -u root -e "use data; insert into YoutubeViews (Name,Views,DateTime) values ('offlineTVVideo', $video6, default)") +else + echo "offlineTVVideo Youtube link error." +fi + + + +if (curl -sSf "https://www.youtube.com/watch?v=lYbFLBqJXVc" > /dev/null) +then + curl -s https://www.youtube.com/watch?v=lYbFLBqJXVc > /home/admin/Documents/cw2/tenDam.html + video7=$(cat tenDam.html | grep -o 'viewCount":{"videoViewCountRenderer":{"viewCount":{"simpleText":"[0-9,]\+' | grep -o '[0-9,]\+' | sed 's/[^$.0-9]*//g') + echo "tanDam,$video7,$date $time" >> /home/admin/Documents/cw2/tendam.txt + $(/opt/lampp/bin/mysql -u root -e "use data; insert into YoutubeViews (Name,Views,DateTime) values ('tendam', $video7, default)") +else + echo "tenDam Youtube link error." +fi + + + +if (curl -sSf "https://www.youtube.com/watch?v=YudHcBIxlYw" > /dev/null) +then + curl -s https://www.youtube.com/watch?v=YudHcBIxlYw > /home/admin/Documents/cw2/jisooMusic.html + video9=$(cat jisooMusic.html | grep -o 'viewCount":{"videoViewCountRenderer":{"viewCount":{"simpleText":"[0-9,]\+' | grep -o '[0-9,]\+' | sed 's/[^$.0-9]*//g') + echo "jisooMusic,$video9,$date $time" >> /home/admin/Documents/cw2/jisooMusic.txt + $(/opt/lampp/bin/mysql -u root -e "use data; insert into YoutubeViews (Name,Views,DateTime) values ('jisooMusic', $video9, default)") + +else + echo "jisooMusic Youtube link error." +fi + + + + +if (curl -sSf "https://www.youtube.com/watch?v=Way9Dexny3w" > /dev/null) +then + curl -s https://www.youtube.com/watch?v=Way9Dexny3w > /home/admin/Documents/cw2/duneTrailer.html + video10=$(cat duneTrailer.html | grep -o 'viewCount":{"videoViewCountRenderer":{"viewCount":{"simpleText":"[0-9,]\+' | grep -o '[0-9,]\+' | sed 's/[^$.0-9]*//g') + echo "duneTrailer,$video10,$date $time" >> /home/admin/Documents/cw2/duneTrailer.txt + $(/opt/lampp/bin/mysql -u root -e "use data; insert into YoutubeViews (Name,Views,DateTime) values ('duneTrailer', $video10, default)") + +else + echo "duneTrailer Youtube link error." +fi