diff --git a/includes/common.sh b/includes/common.sh index 834100cd..9e84cec0 100644 --- a/includes/common.sh +++ b/includes/common.sh @@ -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:?}" @@ -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 "${?}" } }