Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ale5000-git committed Sep 23, 2023
1 parent 35e9166 commit ebc5ea9
Showing 1 changed file with 16 additions and 23 deletions.
39 changes: 16 additions & 23 deletions includes/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ dl_type_one()
report_failure_one "${?}" 'get link 2' "${_result:-}" || return "${?}"
}

sleep 0.2
sleep 0.3
{
_referrer="${_url:?}"
_url="${_base_url:?}${_result:?}"
Expand All @@ -421,47 +421,40 @@ dl_type_one()
}
}

report_failure_two()
report_failure()
{
readonly DL_TYPE_2_FAILED='true'
printf 1>&2 '%s - ' "DL type ${1?} failed at '${3:-}' with ret. code ${2?}"
if test -n "${4:-}"; then printf 1>&2 '\n%s\n' "${4:?}"; fi

printf '%s - ' "Failed at '${2}' with ret. code ${1:?}"
if test -n "${3:-}"; then printf '%s\n' "${3:?}"; fi

return "${1:?}"
return "${2:?}"
}

dl_type_two()
{
if test "${DL_TYPE_2_FAILED:-false}" != 'false'; then return 128; fi
local _url _domain
local _url _domain _base_dm

_url="${1:?}" || {
report_failure_two "${?}" || return "${?}"
}
_domain="$(get_domain_from_url "${_url:?}")" || {
report_failure_two "${?}" || return "${?}"
}
_base_dm="$(printf '%s' "${_domain:?}" | cut -sd '.' -f '2-3')" || {
report_failure_two "${?}" || return "${?}"
}
_url="${1:?}" || report_failure 2 "${?}" || return "${?}"
_domain="$(get_domain_from_url "${_url:?}")" || report_failure 2 "${?}" || return "${?}"
_base_dm="$(printf '%s' "${_domain:?}" | cut -sd '.' -f '2-3')" || report_failure 2 "${?}" || return "${?}"

_loc_code="$(get_location_header_from_http_request "${_url:?}" | cut -d '/' -f '5-' -s)" || {
report_failure_two "${?}" 'get location' || return "${?}"
report_failure 2 "${?}" 'get location' || return "${?}"
}

sleep 0.2
_other_code="$(get_JSON_value_from_ajax_request "${DL_PROT:?}api.${_base_dm:?}/createAccount" "${DL_PROT:?}${_base_dm:?}" 'token')" || {
report_failure_two "${?}" 'get JSON' || return "${?}"
report_failure 2 "${?}" 'get JSON' || return "${?}"
}

sleep 0.2
send_empty_ajax_request "${DL_PROT:?}api.${_base_dm:?}/getContent?contentId=${_loc_code:?}&token=${_other_code:?}"'&website''Token=''7fd9''4ds1''2fds4' "${DL_PROT:?}${_base_dm:?}" || {
report_failure_two "${?}" 'get content' || return "${?}"
report_failure 2 "${?}" 'get content' || return "${?}"
}

sleep 0.3
_parse_and_store_cookie "${_domain:?}" 'account''Token='"${_other_code:?}" || return "${?}"
_parse_and_store_cookie "${_domain:?}" 'account''Token='"${_other_code:?}" || report_failure 2 "${?}" || return "${?}"
_direct_download "${_url:?}" '' "${3:?}" || {
report_failure_two "${?}" 'dl' || return "${?}"
report_failure 2 "${?}" 'dl' || return "${?}"
}
}

Expand Down

0 comments on commit ebc5ea9

Please sign in to comment.