drpanwe

romdownloader

Oct 2nd, 2020
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.54 KB | None | 0 0
  1. #!/bin/bash
  2. gamepage="$1" # e.g. https://vimm.net/vault/1169
  3.  
  4. if [ $# -eq 0 ]
  5.   then
  6.     echo "No arguments supplied. Example: ./script.sh https://vimm.net/vault/1169"
  7.     exit 1
  8. fi
  9.  
  10. # Find the mediaID
  11. while true; do
  12.   id=$(curl -s "$gamepage" | grep 'fileSize\[' | head -n 1 | cut -d \[ -f2 | cut -d \] -f1)
  13.   if [ -z "$id" ]; then
  14.       echo "\$id is empty. Retrying ..."
  15.   else
  16.       echo "\$id is $id"
  17.       break
  18.   fi
  19. done
  20.  
  21. # Construct URL
  22. URL="https://download.vimm.net/download/?mediaId=$id"
  23. echo "Visiting $URL"
  24.  
  25. # Find the filename
  26. while true; do
  27.   filename=$(curl -s -D - \
  28.      -H "Referer: https://vimm.net/" \
  29.      -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36" \
  30.      "$URL" | grep "Content-Disposition" | awk -F '=' '{print substr($2,2,length($2)-3)}')
  31.    if [ -z "$filename" ]; then
  32.     echo "\$filename is empty. Retrying ..."
  33.    else
  34.         echo "\$filename is $filename"
  35.         break
  36.    fi
  37. done
  38.  
  39. # Download it
  40. while true; do
  41.   curl -s \
  42.      -H "Referer: https://vimm.net/" \
  43.      -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36" \
  44.      "$URL" --output "$filename"
  45.  
  46.   # Test the file
  47.   if test -f "$filename"; then
  48.     echo "$filename has been downloaded"
  49.     # Check if thefile is zip
  50.     if file "$filename" | grep 'Zip archive data' &> /dev/null; then
  51.       echo "$filename is a valid Zip archive"
  52.       break
  53.     else
  54.       echo "$filename is not a zip archive. Retrying ..."
  55.     fi
  56.   else
  57.     echo "$filename has not been downloaded. Retrying ..."
  58.   fi
  59. done
  60.  
  61.  
  62. # Not needed Headers
  63. #     -H "Cache-Control: max-age=0" \
  64. #     -H "If-None-Match: \"add61c4fdac54d1a735088da4c743358\"" \
  65. #     -H "Cookie: __cfduid=db8b88950e20f8a7abcd1a8c1e5c3f4ef1601646842" \
  66. #     -H "DNT: 1" \
  67. #     -H "Upgrade-Insecure-Requests: 1" \
  68. #     -H "Sec-Fetch-User: ?1" \
  69. #     -H "Sec-Fetch-Site: same-site" \
  70. #     -H "Sec-Fetch-Mode: navigate" \
  71. #     -H "Sec-Fetch-Dest: document" \
  72. #     -H "Host: download.vimm.net" \
  73. #     -H "Content-Type: application/zip" \
  74. #     -H "Connection: keep-alive" \
  75. #     -H "Accept-Language: en,en-DE;q=0.9,el-GR;q=0.8,el;q=0.7,de-DE;q=0.6,de;q=0.5,en-US;q=0.4" \
  76. #     -H "Accept-Encoding: gzip, deflate, br" \
  77. #     -H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9" \
  78. # curl -v --connect-timeout 5 -k -L \
  79.  
Add Comment
Please, Sign In to add comment