@@ -18,17 +18,17 @@ source "${Dir}"/inspect.sh
18
18
# source inspect.sh
19
19
20
20
# url.contentSize(url) -> int
21
- # Gives you size of content file in MBs .
21
+ # Gives you size of content file in MiB .
22
22
# Args:
23
23
# url (str) > takes url as string.
24
24
# Returns:
25
- # size (int) > size in MBs (eg: 60).
25
+ # size (int) > size in MiB (eg: 60).
26
26
url.contentSize (){
27
27
# checking required functions.
28
28
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 )) " ;
32
32
}
33
33
34
34
# url.contentChart(urls,*paths)
@@ -37,42 +37,33 @@ url.contentSize(){
37
37
# urls (array) > takes one or array of urls.
38
38
# paths (array) > Optional: takes file paths.
39
39
url.contentChart (){
40
- inspect.ScreenSize ' 81' ' 38' ;
41
- # taking urls and content path.
40
+ inspect.ScreenSize ' 50' ' 12' ;
42
41
local ARGs=(" ${@ } " )
43
- # size of all contents.
44
42
local PuraSize=0;
45
- # turning off cursor of terminal.
46
43
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" ' ──────────────────────────────────' ' ───────' ;
55
49
for ARG in " ${ARGs[@]} "
56
50
do
57
- # url of content.
58
51
local ContentUrl=" $( echo " ${ARG} " | awk ' {print $1}' ) " ;
59
- # path of content.
60
52
local ContentPath=" $( echo " ${ARG} " | awk ' {print $2}' ) " ;
61
- # check if path is provided.
62
- [[ -z " ${Path} " ]] &&
53
+ [[ -z " ${ContentPath} " ]] &&
63
54
local ContentVar=" $( echo " ${ContentUrl} " | awk -F/ ' {print $NF}' ) " ||
64
55
local ContentVar=" $( echo " ${ContentPath} " | awk -F/ ' {print $NF}' ) " ;
65
- # taking content size of url.
66
56
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' ;
70
58
local PuraSize=$(( PuraSize+ ContentSize ))
71
59
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 " ╰────────────────────────────╯" ;
75
65
setCursor on;
66
+ return 0;
76
67
}
77
68
78
69
# url.getContent(urls,*paths)
0 commit comments