@@ -18,17 +18,17 @@ source "${Dir}"/inspect.sh
1818# source inspect.sh
1919
2020# url.contentSize(url) -> int
21- # Gives you size of content file in MBs .
21+ # Gives you size of content file in MiB .
2222# Args:
2323# url (str) > takes url as string.
2424# Returns:
25- # size (int) > size in MBs (eg: 60).
25+ # size (int) > size in MiB (eg: 60).
2626url.contentSize (){
2727 # checking required functions.
2828 inspect.is_func ' wget' ;
29- local contentSizeVar =" $( wget --spider " ${1} " --no-check-certificate 2>&1 ) " ;
30- local contentSize =" $( echo " ${contentSizeVar } " | grep -i length: | awk ' {print $2}' ) " ;
31- echo " $(( contentSize / 1048576 )) " ;
29+ local ContentSizeVar =" $( wget --spider " ${1} " --no-check-certificate 2>&1 ) " ;
30+ local ContentSize =" $( echo " ${ContentSizeVar } " | grep -i length: | awk ' {print $2}' ) " ;
31+ echo " $(( ContentSize / 1048576 )) " ;
3232}
3333
3434# url.contentChart(urls,*paths)
@@ -37,42 +37,33 @@ url.contentSize(){
3737# urls (array) > takes one or array of urls.
3838# paths (array) > Optional: takes file paths.
3939url.contentChart (){
40- inspect.ScreenSize ' 81' ' 38' ;
41- # taking urls and content path.
40+ inspect.ScreenSize ' 50' ' 12' ;
4241 local ARGs=(" ${@ } " )
43- # size of all contents.
4442 local PuraSize=0;
45- # turning off cursor of terminal.
4643 setCursor off;
47- echo ;
48- say.success " 📦 Getting Information Urls" ;
49- echo -e "
50- ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
51- ┃ INFORMATION FILES ┃
52- ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
53- ┃ FILE NAME FILE SIZE ┃
54- ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛" ;
44+ echo -e "
45+ ╭─ Content ────────────────────────────────────╮" ;
46+ echo -e " │ │" ;
47+ printf " │ %-34s %-7s │\n" ' Content' ' Size' ;
48+ printf " │ %-34s %-7s │\n" ' ──────────────────────────────────' ' ───────' ;
5549 for ARG in " ${ARGs[@]} "
5650 do
57- # url of content.
5851 local ContentUrl=" $( echo " ${ARG} " | awk ' {print $1}' ) " ;
59- # path of content.
6052 local ContentPath=" $( echo " ${ARG} " | awk ' {print $2}' ) " ;
61- # check if path is provided.
62- [[ -z " ${Path} " ]] &&
53+ [[ -z " ${ContentPath} " ]] &&
6354 local ContentVar=" $( echo " ${ContentUrl} " | awk -F/ ' {print $NF}' ) " ||
6455 local ContentVar=" $( echo " ${ContentPath} " | awk -F/ ' {print $NF}' ) " ;
65- # taking content size of url.
6656 local ContentSize=" $( url.contentSize " ${ContentUrl} " ) " ;
67- printf " ┃ ${Green} %-36s${Clear} ${Yelo} %8s${Clear} ┃\n" " ${ContentVar} " " ${ContentSize} MB" ;
68- echo -e " ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛" ;
69- # add all size of contents.
57+ printf " │ ${Green} %-34s${Clear} ${Yelo} %3s${Clear} %-3s │\n" " ${ContentVar} " " ${ContentSize} " ' MiB' ;
7058 local PuraSize=$(( PuraSize+ ContentSize ))
7159 done
72- # print total content size.
73- printf " ┃ [ ${Yelo} %5s${Clear} ] ─────────────────────────────> ${Green} %7s${Clear} %-2s ┃" " TOTAL" " ${PuraSize} MB" ;
74- echo -e " \n ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛" ;
60+ echo -e " │ │" ;
61+ echo -e " ╰──────────────────────────────────────────────╯\n" ;
62+ echo -e " ╭─ TOTAL ────────────────────╮" ;
63+ printf " │ %14s: ${Green} %4s${Clear} %3s │\n" " Download Size" " ${PuraSize} " ' MiB' ;
64+ echo -e " ╰────────────────────────────╯" ;
7565 setCursor on;
66+ return 0;
7667}
7768
7869# url.getContent(urls,*paths)
0 commit comments