diff --git a/webroot/watch.shs b/webroot/watch.shs index 1335ced..cefa792 100755 --- a/webroot/watch.shs +++ b/webroot/watch.shs @@ -1,5 +1,9 @@ #!/bin/bash +function format_numbers() { + rev | sed "s#[[:digit:]]\{3\}#&,#g" | rev | sed -E 's/^,//' +} + if [[ ! -d "temp" ]]; then mkdir "temp" fi @@ -119,9 +123,9 @@ if [[ "${get_data[v]}" ]]; then fi strings[upload_date]=$(date -d "$(echo $video | jq -r '.upload_date' | sed -E 's/..../&-/;s/....-../&-/')" "+%d %B %Y") - strings[view_count]=$(echo $video | jq -r '.view_count' | xargs printf "%'d\n") - like_count=$(echo $video | jq -r '.like_count' | xargs printf "%'d\n") - dislike_count=$(echo $video | jq -r '.dislike_count' | xargs printf "%'d\n") + strings[view_count]=$(echo $video | jq -r '.view_count' | format_numbers) + like_count=$(echo $video | jq -r '.like_count' | format_numbers) + dislike_count=$(echo $video | jq -r '.dislike_count' | format_numbers) if [[ ${cfg[template]} == 'default' ]]; then if [[ $like_count == 'null' && $dislike_count == 'null' ]]; then strings[like_dislike_count]="Likes are turned off"