From efdb7515af9f521897940cec075b9ddb56a05a43 Mon Sep 17 00:00:00 2001 From: Fabs Date: Sat, 9 Dec 2023 16:44:39 +0100 Subject: [PATCH] Replace tidy tr based cleanup and change matching --- bandcamp_album_length | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bandcamp_album_length b/bandcamp_album_length index 8dc7af1..52901ba 100755 --- a/bandcamp_album_length +++ b/bandcamp_album_length @@ -12,7 +12,7 @@ if ! grep -qF 'bandcamp.com/album' <<<"$url"; then exit 1 fi -track_durations=$(curl "$url" 2>/dev/null | tidy 2>/dev/null | sed -n -E 's/^.*"time secondaryText">(.*)<\/span.*$/\1/p') +track_durations=$(curl "$url" 2>/dev/null | tr -d '\n' | tr -s ' ' | grep -oE 'time secondaryText"> [0-9]+:[0-9]+' | cut -d' ' -f3) total_seconds=$( { printf '('; cut -d: -f1 <<<"$track_durations" | paste -d+ -s | tr -d '\n'; printf ') * 60 +'; cut -d: -f2 <<<"$track_durations" | paste -d+ -s; } | bc ) date -u -d @${total_seconds} +%T