Guest User

FritzLoad Unrestrict.li

a guest
Jan 22nd, 2014
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.84 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # Problem? => [email protected]
  4.  
  5. unrestrictli() {
  6.     local f=$tmp/dl.response.htm
  7.     local c=$tmp/unrestrict.cookie
  8.  
  9.     local try=0 finalurl filename invalid
  10.    
  11.     # Check if no cookies or expired cookies
  12.     if ! unrestrictli_account_info; then
  13.         # Sign in if account is set
  14.         if [ -n "$ACCOUNT_USER" ]; then
  15.             unrestrictli_login "$ACCOUNT_USER" "$ACCOUNT_PASS"
  16.         else
  17.             log "Unrestrict.li VIP account is required."
  18.             errmsg "Unrestrict.li VIP account is required."
  19.             return 1
  20.         fi
  21.     fi
  22.    
  23.     while [ $try -lt $retries ]; do
  24.         try=$(($try+1))
  25.        
  26.         GET "http://unrestrict.li/unrestrict.php" $f "--cookie $c -d jdownloader=1&domain=long&link=$link" "UNRESTRICT"
  27.        
  28.         finalurl=$(echo "$f" | sed 's/{"\([^"]\+\)":.*/\1/' | sed 's/\\//g')
  29.         invalid=$(echo "$f" | sed 's/.*"invalid":"\([^"]\+\)".*/\1/')
  30.         filename=$(echo "$f" | parse_json_string name)
  31.        
  32.         if [ "$invalid" != "$f" ]; then
  33.             log "Failed to unrestrict link. (Errormessage: $invalid)"
  34.             errmsg "Failed to unrestrict link. (Errormessage: $invalid)"
  35.             waiting ${slot_waittime:-60}
  36.             continue
  37.         fi
  38.         [ -z "$filename" ] && filename=${finalurl##*/}
  39.        
  40.         log "Starting download of $finalurl."
  41.         if download "$finalurl" "$filename" "--retry 3 -C -"; then
  42.             return 0
  43.         fi
  44.     done
  45.     log "Download failed."
  46.     errmsg "Download failed."
  47.     return 1
  48. }
  49.  
  50. # Check account info
  51. unrestrictli_account_info() {
  52.     local traffic expires timestamp
  53.     GET "http://unrestrict.li/api/jdownloader/user.php?format=json" $f "--cookie $c" "TRAFFIC"
  54.     traffic=$(echo "$f" | parse_json_number traffic)
  55.     expires=$(echo "$f" | parse_json_number expires)
  56.     timestamp=$(date +%s)
  57.     if [ $expires -lt $timestamp ]; then
  58.         log "No VIP!"
  59.         errmsg "No VIP!"
  60.         return 1
  61.     fi
  62.     expires=$(date -d @$expires +%c)
  63.     log "VIP expires: $expires."       
  64.     if [ $traffic -le 0 ]; then
  65.         log "No traffic!"
  66.         errmsg "No traffic!"
  67.         return 1
  68.     fi
  69.     log "$traffic bytes left." 
  70.     return 0
  71. }
  72.  
  73. # Check hosts
  74. unrestrictli_check() {
  75.     local result
  76.     GET "http://unrestrict.li/api/jdownloader/hosts.php?format=json" $f "--cookie $c" "HOSTERLIST"
  77.     result=$(echo "$f" | parse_json_array result)
  78.     echo "$result" | grep -q "$hosterdomain" || return 1
  79.     return 0
  80. }
  81.  
  82. # Sign in
  83. unrestrictli_login() {
  84.     local username=$1
  85.     local password=$2
  86.     local cookiefile=$c
  87.     local name
  88.        
  89.     GET "http://unrestrict.li/sign_in" $f "--cookie-jar $cookiefile -d return=home&username=$username&password=$password&signin=Log%20in&remember_me=remember" "LOGIN"
  90.     name=$(<$cookiefile parse_cookie 'unrestrict_user')
  91.     if [ -n "$name" ]; then
  92.         log "Signed in as $user."
  93.         return 0
  94.     fi 
  95.     log "Failed to sign in. Check username and/or password. Complete captcha in browser before trying again."  
  96.     errmsg "Failed to sign in. Check username and/or password. Complete captcha in browser before trying again."
  97.     return 1
  98.     # TODO: Captcha (Solvemedia) processing
  99. }
Advertisement
Add Comment
Please, Sign In to add comment