From f8f1195589b5cc37ef53a784d7a3d76482df5c49 Mon Sep 17 00:00:00 2001 From: Edu4rdSHL Date: Wed, 2 Feb 2022 19:19:22 -0500 Subject: [PATCH] Update script. Switch from wget to curl Fixes #2 Signed-off-by: Edu4rdSHL --- files/MSFTFreeEbooks.txt | 409 +++++++++++++++++++++++++++++++++++++++ files/README.md | 1 + script.sh | 58 +++--- 3 files changed, 444 insertions(+), 24 deletions(-) create mode 100644 files/MSFTFreeEbooks.txt create mode 100644 files/README.md mode change 100644 => 100755 script.sh diff --git a/files/MSFTFreeEbooks.txt b/files/MSFTFreeEbooks.txt new file mode 100644 index 0000000..81d6833 --- /dev/null +++ b/files/MSFTFreeEbooks.txt @@ -0,0 +1,409 @@ +MSFT eBooks +http://ligman.me/29ngkYn +http://ligman.me/29jL5wW +http://ligman.me/29afIRV +http://ligman.me/29pyHgR +http://ligman.me/29dmbfC +http://ligman.me/29ollRF +http://ligman.me/29gvv67 +http://ligman.me/29pzkHg +http://ligman.me/29CWQ20 +http://ligman.me/1G0Cm7T +http://ligman.me/29vDVrw +http://ligman.me/29CW4SV +http://ligman.me/29G1z1N +http://ligman.me/29yWAAO +http://ligman.me/29DHWHq +http://ligman.me/1HGwMgm +http://ligman.me/29yUVeH +http://ligman.me/29ErxWs +http://ligman.me/29EsHkr +http://ligman.me/29v5zCF +http://ligman.me/1H32nUT +http://ligman.me/29yixk9 +http://ligman.me/29vq6d2 +http://ligman.me/29cvrjG +http://ligman.me/29pzjTR +http://ligman.me/29rPOf6 +http://ligman.me/29ctW9z +http://ligman.me/29gvoHt +http://ligman.me/29gvfEd +http://ligman.me/29LvcBg +http://ligman.me/29DS3gJ +http://ligman.me/1q9L65I +http://ligman.me/29pufLO +http://ligman.me/29wODdA +http://ligman.me/29vch9q +http://ligman.me/29EmfZc +http://ligman.me/29LXmMt +http://ligman.me/29qwKfQ +http://ligman.me/29sp3nZ +http://ligman.me/29yWFFf +http://ligman.me/29ZNaMN +http://ligman.me/29gYy5h +http://ligman.me/29NhudA +http://ligman.me/29jDRJf +http://ligman.me/29conIf +http://ligman.me/29cnLlL +http://ligman.me/29fNYRE +http://ligman.me/29cq9cw +http://ligman.me/29acqhj +http://ligman.me/29fJJCS +http://ligman.me/29nbxWK +http://ligman.me/29fO9MV +http://ligman.me/29pr2x1 +http://ligman.me/29oa0kH +http://ligman.me/29i6ntm +http://ligman.me/29n7JVF +http://ligman.me/29fQsQ4 +http://ligman.me/29fQo2J +http://ligman.me/29idz8T +http://ligman.me/29dfwlu +http://ligman.me/29fLliP +http://ligman.me/29i83TI +http://ligman.me/29diypX +http://ligman.me/29fNpHO +http://ligman.me/29oefNf +http://ligman.me/29jGTgC +http://ligman.me/29crPhL +http://ligman.me/29FUJIk +http://ligman.me/1G2oDNG +http://ligman.me/29u5uMT +http://ligman.me/29rlRt3 +http://ligman.me/29Yd9V0 +http://ligman.me/29s4EQ1 +http://ligman.me/29vkv6E +http://ligman.me/29A3q8Z +http://ligman.me/29H7ovO +http://ligman.me/1dHMOui +http://ligman.me/1G2pw8X +http://ligman.me/29gnaPK +http://ligman.me/29d7GZH +http://ligman.me/29i2Mvf +http://ligman.me/29rbpkY +http://ligman.me/29e6cTO +http://ligman.me/29hJU1c +http://ligman.me/29bcJtd +http://ligman.me/29bcRZO +http://ligman.me/29d5mS2 +http://ligman.me/29cz6OD +http://ligman.me/29fDult +http://ligman.me/29pEdjN +http://ligman.me/29rwoY0 +http://ligman.me/29fTQrx +http://ligman.me/29gfrkN +http://ligman.me/29rwoHw +http://ligman.me/29d5AbX +http://ligman.me/29fudHc +http://ligman.me/29FzGG5 +http://ligman.me/29osNwd +http://ligman.me/29a22WR +http://ligman.me/29alDpK +http://ligman.me/29fDylj +http://ligman.me/29jPTCx +http://ligman.me/29d5XTw +http://ligman.me/29rUIci +http://ligman.me/29hVdVa +http://ligman.me/29ijDhm +http://ligman.me/29pn5e2 +http://ligman.me/29ckVx7 +http://ligman.me/29cfePX +http://ligman.me/29vGIvY +http://ligman.me/29hfnPR +http://ligman.me/29fCVFe +http://ligman.me/29a6YLu +http://ligman.me/29n4GwJ +http://ligman.me/29jAS3v +http://ligman.me/29ci56U +http://ligman.me/29nW9L3 +http://ligman.me/29hV6ZM +http://ligman.me/29d1qAV +http://ligman.me/29pfpbI +http://ligman.me/29v8nwX +http://ligman.me/29uq452 +http://ligman.me/29d1wc3 +http://ligman.me/29Y1O7a +http://ligman.me/29a7wRA +http://ligman.me/29pnEEG +http://ligman.me/1FYtDD8 +http://ligman.me/1HByNKS +http://ligman.me/1NCfcKC +http://ligman.me/1HCDxl9 +http://ligman.me/1HCCCRP +http://ligman.me/1H4Q0e5 +http://ligman.me/1JI6V77 +http://ligman.me/1CSMobd +http://ligman.me/1jWMJA2 +http://ligman.me/1m6xucg +http://ligman.me/1onTg9n +http://ligman.me/1n49kzj +http://ligman.me/1sgBtn4 +http://ligman.me/1qZlnOJ +http://ligman.me/TWa2Dg +http://ligman.me/1vM9mwt +http://ligman.me/1qzON6Q +http://ligman.me/1rB8nl1 +http://ligman.me/TL3pn1 +http://ligman.me/1vM9H2d +http://ligman.me/29odbJ6 +http://ligman.me/1LSKTC0 +http://ligman.me/1qC1pu4 +http://ligman.me/1dHSpRh +http://ligman.me/1LO5k1Y +http://ligman.me/1M7Xr5v +http://ligman.me/29jLNtX +http://ligman.me/29agpuw +http://ligman.me/29cv8FE +http://ligman.me/29ieXIo +http://ligman.me/29dmCXi +http://ligman.me/29jLjnM +http://ligman.me/29agkqx +http://ligman.me/29gvTBJ +http://ligman.me/29pztuz +http://ligman.me/29dmTJT +http://ligman.me/29ieSEI +http://ligman.me/29hB9CQ +http://ligman.me/29fOWdV +http://ligman.me/1JPNIAt +http://ligman.me/29Xnqk8 +http://ligman.me/29oRWlp +http://ligman.me/29csX4C +http://ligman.me/29jH8bx +http://ligman.me/29pcQFA +http://ligman.me/29FkNr3 +http://ligman.me/12FIapt +http://ligman.me/13WvGXa +http://ligman.me/1bPPb6C +http://ligman.me/12FIZ1I +http://ligman.me/16CaDM1 +http://ligman.me/19LwMLI +http://ligman.me/1JHmqiB +http://ligman.me/1KHqGNK +http://ligman.me/1M7Ycve +http://ligman.me/1LSOsIu +http://ligman.me/1UrQDFx +http://ligman.me/TUmyTW +http://ligman.me/1NLviCk +http://ligman.me/17iaq4l +http://ligman.me/1bPRqqz +http://ligman.me/17iah0Q +http://ligman.me/1287Jt4 +http://ligman.me/29djdrk +http://ligman.me/29rLH2H +http://ligman.me/29fNPxT +http://ligman.me/29ddm60 +http://ligman.me/29gsnHt +http://ligman.me/29nc2QS +http://ligman.me/29fOrnd +http://ligman.me/29dk0Ze +http://ligman.me/29aewh2 +http://ligman.me/29gteI8 +http://ligman.me/29ibJVq +http://ligman.me/29fKMD6 +http://ligman.me/29cthAz +http://ligman.me/29ohqUT +http://ligman.me/29crGiw +http://ligman.me/29gsFOl +http://ligman.me/29ncgrb +http://ligman.me/29fKWdi +http://ligman.me/29djvi9 +http://ligman.me/29FW41O +http://ligman.me/29ddKBp +http://ligman.me/29dkhf4 +http://ligman.me/29rML6Q +http://ligman.me/29hxyEN +http://ligman.me/29fPweO +http://ligman.me/29fPMug +http://ligman.me/29fPnIe +http://ligman.me/29hxogT +http://ligman.me/29deg2k +http://ligman.me/29pwCBO +http://ligman.me/29fPAec +http://ligman.me/29deQgz +http://ligman.me/29afaLE +http://ligman.me/29pxarl +http://ligman.me/29ne5V5 +http://ligman.me/29csBjh +http://ligman.me/29dkZZK +http://ligman.me/29ojrAy +http://ligman.me/29jJLdx +http://ligman.me/29df2fw +http://ligman.me/29cu6sX +http://ligman.me/29dlaE5 +http://ligman.me/29FZx0B +http://ligman.me/29idnpO +http://ligman.me/29dlH9d +http://ligman.me/29cs157 +http://ligman.me/29dkq1V +http://ligman.me/29aelm3 +http://ligman.me/29ycEnb +http://ligman.me/29w5gr9 +http://ligman.me/29pfQ50 +http://ligman.me/1sgMWDe +http://ligman.me/29w68w8 +http://ligman.me/29viFmi +http://ligman.me/29zYWzl +http://ligman.me/29H2bo1 +http://ligman.me/29AT60J +http://ligman.me/29xtlNa +http://ligman.me/29xtHDs +http://ligman.me/29GpFsY +http://ligman.me/29ddd2b +http://ligman.me/29fJpEc +http://ligman.me/29cs7Fg +http://ligman.me/29fJA2g +http://ligman.me/29cqzzq +http://ligman.me/29ddbYb +http://ligman.me/29rLlZV +http://ligman.me/29ialCf +http://ligman.me/29pvj5I +http://ligman.me/29hwj8y +http://ligman.me/29dj7zY +http://ligman.me/1sl39Hs +http://ligman.me/1anyEJj +http://ligman.me/17icbPc +http://ligman.me/ZZezok +http://ligman.me/12S035G +http://ligman.me/12RZWY1 +http://ligman.me/13PlvVY +http://ligman.me/12FMEMP +http://ligman.me/128a1ID +http://ligman.me/19LCgpM +http://ligman.me/13Pn1XY +http://ligman.me/13WChkr +http://ligman.me/12FN71F +http://ligman.me/ZZh7Ts +http://ligman.me/14HcD5O +http://ligman.me/17UHSNJ +http://ligman.me/19LEPIz +http://ligman.me/11VIxdB +http://ligman.me/12FObmf +http://ligman.me/11HXnjD +http://ligman.me/14fCxLS +http://ligman.me/16CkUI4 +http://ligman.me/17VqB79 +http://ligman.me/13XRfqr +http://ligman.me/19fCnqV +http://ligman.me/11WvSqL +http://ligman.me/1002Upx +http://ligman.me/14HMJ1Q +http://ligman.me/10ttQ3n +http://ligman.me/15fRBI9 +http://ligman.me/19fDuqE +http://ligman.me/11IMDlh +http://ligman.me/10tu5eD +http://ligman.me/128NAD6 +http://ligman.me/1bRgXzV +http://ligman.me/14givRo +http://ligman.me/18VNatF +http://ligman.me/128Ogso +http://ligman.me/13Qbl7k +http://ligman.me/10tuWvL +http://ligman.me/16dFAWc +http://ligman.me/11lkViX +http://ligman.me/1bRhVMn +http://ligman.me/14HOjki +http://ligman.me/1bRiXbc +http://ligman.me/13QcfRi +http://ligman.me/16E4lf4 +http://ligman.me/1005lbB +http://ligman.me/14HOxb2 +http://ligman.me/16E6G9L +http://ligman.me/14gkBRc +http://ligman.me/1006fEV +http://ligman.me/16dHXZ9 +http://ligman.me/13QdHDb +http://ligman.me/11IQ8bd +http://ligman.me/17jgPfG +http://ligman.me/15fXTHQ +http://ligman.me/11vx5Cy +http://ligman.me/N1JiHO +http://ligman.me/OudHlO +http://ligman.me/OudJdr +http://ligman.me/N1I2o4 +http://ligman.me/Oue0NG +http://ligman.me/Oue2oE +http://ligman.me/N1HQW0 +http://ligman.me/Ouebsh +http://ligman.me/OuecfK +http://ligman.me/N1Ienp +http://ligman.me/OuelQu +http://ligman.me/OueoMd +http://ligman.me/N1J8A8 +http://ligman.me/OueFPb +http://ligman.me/OueIKU +http://ligman.me/N1I935 +http://ligman.me/OueUd4 +http://ligman.me/OueVxy +http://ligman.me/N1HMW7 +http://ligman.me/Ouf6sO +http://ligman.me/Ouf9og +http://ligman.me/N1Jo27 +http://ligman.me/OufgQN +http://ligman.me/OufkQs +http://ligman.me/N1HEpM +http://ligman.me/Oufwzg +http://ligman.me/OufCXN +http://ligman.me/N1JfvI +http://ligman.me/OufRSs +http://ligman.me/OufVlq +http://ligman.me/N1HX3Q +http://ligman.me/Oug5Jl +http://ligman.me/Oug74a +http://ligman.me/1H1Exty +http://ligman.me/1S1f34H +http://ligman.me/1HGqihD +http://ligman.me/1G2ccS5 +http://ligman.me/1ffeiJo +http://ligman.me/1NKjUqp +http://ligman.me/1KEShAt +http://ligman.me/1S1i4C0 +http://ligman.me/1ReR3Qq +http://ligman.me/1dGxnSW +http://ligman.me/1IZCarE +http://ligman.me/1H2Bq3J +http://ligman.me/1Rf7BaZ +http://ligman.me/1LRIveQ +http://ligman.me/1dGxEW7 +http://ligman.me/1omCrM6 +http://ligman.me/1j5aDhH +http://ligman.me/1n3mkVY +http://ligman.me/1n3mAUZ +http://ligman.me/1vKOGot +http://ligman.me/1H7bxTv +http://ligman.me/1G0DEjb +http://ligman.me/29pbiLY +http://ligman.me/29dlTVV +http://ligman.me/29rOYz9 +http://ligman.me/29ie2rq +http://ligman.me/29fQN5c +http://ligman.me/29idEct +http://ligman.me/29nevuE +http://ligman.me/29olaWI +http://ligman.me/29pz4Im +http://ligman.me/29fQRlQ +http://ligman.me/29hzPzU +http://ligman.me/29rON6X +http://ligman.me/29cumbH +http://ligman.me/29cv1JW +http://ligman.me/29dmh6L +http://ligman.me/29dfUkt +http://ligman.me/1giniO7 +http://ligman.me/29H7K5O +http://ligman.me/1qbEeVc +http://ligman.me/1ewwcq6 +http://ligman.me/1H1MFKr +http://ligman.me/1pxniH4 +http://ligman.me/1dG2ZZ9 +http://ligman.me/29v9igV +http://ligman.me/29hofVk +http://ligman.me/29idcee +http://ligman.me/29rOvx0 +http://ligman.me/29ctkki +http://ligman.me/29okalt +http://ligman.me/29i2CEe +http://ligman.me/29FT71n +http://ligman.me/29NBSj1 +http://ligman.me/29H3O3o +http://ligman.me/29OHLKa +http://ligman.me/29uHKKV \ No newline at end of file diff --git a/files/README.md b/files/README.md new file mode 100644 index 0000000..0e774ff --- /dev/null +++ b/files/README.md @@ -0,0 +1 @@ +Here we save the files which contains the links in case that they are deleted. diff --git a/script.sh b/script.sh old mode 100644 new mode 100755 index 4928c58..ffa384a --- a/script.sh +++ b/script.sh @@ -1,30 +1,40 @@ #!/usr/bin/env sh -VERSION=0.2 +VERSION=0.3 echo "Microsoft GIVE AWAY files downloader. Version $VERSION" +echo "Made with love by @edu4rdshl." echo -echo "Star the project and follow @edu4rdshl in Github/Twitter, it will be appreciated." echo "Downloading books links..." -if wget -q -O "links-temp.txt" "https://msdnshared.blob.core.windows.net/media/2017/07/Ligman_eBooks_2017.txt"; then - echo "Books links correctly downloaded." - tail -n +2 "links-temp.txt" > "links.txt" - sed -i -r 's/\s+//g' "links.txt" - rm -f "links-temp.txt" - TOTAL_BOOKS=$(wc -l "links.txt" | awk '{print $1;}') - echo "Total books to download: $TOTAL_BOOKS" - echo "Downloading books now, do not interrupt the process..." - COUNTER=0; - while read -r LINK; do - if wget -q --content-disposition "$LINK"; then - COUNTER=$((COUNTER + 1)); - echo "Sucessfully downloaded book number: $COUNTER" + +GIVEAWAY_URLS=("https://msdnshared.blob.core.windows.net/media/2017/07/Ligman_eBooks_2017.txt" "http://www.mssmallbiz.com/ericligman/Key_Shorts/MSFTFreeEbooks.txt") + +for URL in ${GIVEAWAY_URLS[@]}; do + if [ $(curl -sSfLo "links-temp.txt" "$URL" -w '%{http_code}\n') -eq 200 ]; then + echo "Books links correctly downloaded from $URL..." + tail -n +2 "links-temp.txt" > "links.txt" + sed -i -r 's/\s+//g' "links.txt" + rm -f "links-temp.txt" + TOTAL_BOOKS=$(wc -l "links.txt" | awk '{print $1;}') + echo "Total books to download: $TOTAL_BOOKS" + echo "Downloading books now, do not interrupt the process..." + COUNTER=0; + while read -r LINK; do + if curl -sSfLo "$(basename "$(curl -sSfw '%{redirect_url}' "$LINK")")" "$LINK"; then + COUNTER=$((COUNTER + 1)); + echo "Sucessfully downloaded book: $COUNTER/$TOTAL_BOOKS" + else + COUNTER=$((COUNTER + 1)); + echo "A error as ocurred while downloading the book: $COUNTER from link: $LINK" + fi + done < links.txt + rm -f "links.txt" + echo "Job finished." + else + echo "Error downloading books links from $URL" + if [ ${#GIVEAWAY_URLS[@]} -gt 1 ]; then + echo "Trying next URL..." else - COUNTER=$((COUNTER + 1)); - echo "A error as ocurred while downloading the book: $COUNTER from link: $LINK" + echo "Exiting..." + exit fi - done < links.txt - rm -f "links.txt" - echo "Job finished." -else - echo "Error downloading books links, exiting." - exit -fi + fi +done