Skip to content

Commit

Permalink
ui updated in url chart
Browse files Browse the repository at this point in the history
  • Loading branch information
OurCodeBase committed Jan 12, 2024
1 parent ff071ab commit 5b5b168
Showing 1 changed file with 19 additions and 28 deletions.
47 changes: 19 additions & 28 deletions src/url.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ source "${Dir}"/inspect.sh
# source inspect.sh

# url.contentSize(url) -> int
# Gives you size of content file in MBs.
# Gives you size of content file in MiB.
# Args:
# url (str) > takes url as string.
# Returns:
# size (int) > size in MBs (eg: 60).
# size (int) > size in MiB (eg: 60).
url.contentSize(){
# checking required functions.
inspect.is_func 'wget';
local contentSizeVar="$(wget --spider "${1}" --no-check-certificate 2>&1)";
local contentSize="$(echo "${contentSizeVar}" | grep -i length: | awk '{print $2}')";
echo "$(( contentSize/1048576 ))";
local ContentSizeVar="$(wget --spider "${1}" --no-check-certificate 2>&1)";
local ContentSize="$(echo "${ContentSizeVar}" | grep -i length: | awk '{print $2}')";
echo "$(( ContentSize/1048576 ))";
}

# url.contentChart(urls,*paths)
Expand All @@ -37,42 +37,33 @@ url.contentSize(){
# urls (array) > takes one or array of urls.
# paths (array) > Optional: takes file paths.
url.contentChart(){
inspect.ScreenSize '81' '38';
# taking urls and content path.
inspect.ScreenSize '50' '12';
local ARGs=("${@}")
# size of all contents.
local PuraSize=0;
# turning off cursor of terminal.
setCursor off;
echo;
say.success "๐Ÿ“ฆ Getting Information Urls";
echo -e "
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ INFORMATION FILES โ”ƒ
โ”ฃโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ซ
โ”ƒ FILE NAME FILE SIZE โ”ƒ
โ”—โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›";
echo -e "
โ•ญโ”€ Content โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ";
echo -e " โ”‚ โ”‚";
printf " โ”‚ %-34s %-7s โ”‚\n" 'Content' 'Size';
printf " โ”‚ %-34s %-7s โ”‚\n" 'โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€' 'โ”€โ”€โ”€โ”€โ”€โ”€โ”€';
for ARG in "${ARGs[@]}"
do
# url of content.
local ContentUrl="$(echo "${ARG}" | awk '{print $1}')";
# path of content.
local ContentPath="$(echo "${ARG}" | awk '{print $2}')";
# check if path is provided.
[[ -z "${Path}" ]] &&
[[ -z "${ContentPath}" ]] &&
local ContentVar="$(echo "${ContentUrl}" | awk -F/ '{print $NF}')" ||
local ContentVar="$(echo "${ContentPath}" | awk -F/ '{print $NF}')";
# taking content size of url.
local ContentSize="$(url.contentSize "${ContentUrl}")";
printf " โ”ƒ ${Green}%-36s${Clear} ${Yelo}%8s${Clear} โ”ƒ\n" "${ContentVar}" "${ContentSize} MB";
echo -e " โ”—โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›";
# add all size of contents.
printf " โ”‚ ${Green}%-34s${Clear} ${Yelo}%3s${Clear} %-3s โ”‚\n" "${ContentVar}" "${ContentSize}" 'MiB';
local PuraSize=$(( PuraSize+ContentSize ))
done
# print total content size.
printf " โ”ƒ [ ${Yelo}%5s${Clear} ] โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€> ${Green}%7s${Clear} %-2s โ”ƒ" "TOTAL" "${PuraSize} MB";
echo -e "\n โ”—โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›";
echo -e " โ”‚ โ”‚";
echo -e " โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ\n";
echo -e " โ•ญโ”€ TOTAL โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ";
printf " โ”‚ %14s: ${Green}%4s${Clear} %3s โ”‚\n" "Download Size" "${PuraSize}" 'MiB';
echo -e " โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ";
setCursor on;
return 0;
}

# url.getContent(urls,*paths)
Expand Down

0 comments on commit 5b5b168

Please sign in to comment.