Skip to content

Commit

Permalink
openload: fix anonymous download (upstream)
Browse files Browse the repository at this point in the history
Fixes mcrapet#83.
  • Loading branch information
mcrapet committed May 20, 2016
1 parent 2043caf commit 4cf50fe
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions openload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,23 +105,40 @@ openload_login() {
# stdout: real file download link
openload_download() {
local -r URL=$2
local PAGE WAIT FILE_URL FILE_NAME
local PAGE WAIT FILE_URL JS

PAGE=$(curl -L "$URL") || return

if match "<p class=\"lead\">We can't find the file you are looking for" "$PAGE"; then
return $ERR_LINK_DEAD
fi

WAIT=$(parse_tag 'id="secondsleft"' span <<< "$PAGE") || return
detect_javascript || return

WAIT=$(parse_tag 'id="secondsleft"' span <<< "$PAGE") || return
wait $(($WAIT)) seconds || return

FILE_URL=$(parse_attr 'id="realdownload"' href <<< "$PAGE")
FILE_NAME=$(parse_tag 'id="filename"' span <<< "$PAGE")
# Obfuscated code with utf-8 variable names
JS=$(grep_script_by_order "$PAGE" 12) || return
JS=${JS#<script type=\"text/javascript\">}
JS=${JS%</script>}

FILE_URL=$(echo "
attr = function(name,value) {
if (typeof console === 'object' && typeof console.log === 'function') {
console.log(value);
} else {
print(value);
}
}
\$ = function(obj) {
return {
attr: attr
};
}
$JS" | javascript) || return

echo "$FILE_URL"
echo "$FILE_NAME"
}

# Static function. Check if a cookie doesn't expired.
Expand Down

0 comments on commit 4cf50fe

Please sign in to comment.