From ecf1ecbae6b44c4063f8ab8050f1e815c3ae512c Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Thu, 25 Jul 2024 10:33:33 -0700 Subject: [PATCH] Add .vcf support to automtime --- automtime | 13 +++++++++++++ test-automtime-expected | 1 + testfiles/type1.vcf | 24 ++++++++++++++++++++++++ testfiles/type2.vcf | 10 ++++++++++ 4 files changed, 48 insertions(+) create mode 100644 testfiles/type1.vcf create mode 100644 testfiles/type2.vcf diff --git a/automtime b/automtime index a31c9ca..6512caf 100755 --- a/automtime +++ b/automtime @@ -811,6 +811,15 @@ mtime_vbox () { TIME=$(normalize_iso_time "$RAWTIME") } +# File type: vcf (vCard contact) +mtime_vcf () { + RAWTIME=$(sed -E -n -e 's/^REV:([^()]*)(\(.*\))?$/\1/p' <"$1" | sort | tail -1) + # $RAWTIME is like 2017-05-10T14:34:50Z + if [ -n "$RAWTIME" -a "$RAWTIME" != "0" ]; then + TIME=$(normalize_iso_time "$RAWTIME") + fi +} + # File type: warcgz (Compressed Web Archive Collection file) mtime_warcgz () { # Look for the WARC-Date: lines only within the WARC header sections @@ -1208,6 +1217,10 @@ for f in "$@" ; do TYPE=vbox ;; + *.vcf) + TYPE=vcf + ;; + *.warc.gz) TYPE=warcgz ;; diff --git a/test-automtime-expected b/test-automtime-expected index 9001883..91fe594 100644 --- a/test-automtime-expected +++ b/test-automtime-expected @@ -54,6 +54,7 @@ 'testfiles/type1.tgz' '2021-10-14 20:36:00 +0000' 'testfiles/type1.tiff' '2009-10-11 12:13:14' 'testfiles/type1.ttf' '2021-10-17' +'testfiles/type1.vcf' '2024-07-25 17:09:12 +0000' 'testfiles/type1.wacz' '2022-05-21 21:14:54' 'testfiles/type1.warc.gz' '2023-01-13 17:59:30.783 +0000' 'testfiles/type1.webm' '2023-04-05 06:07:08.0900000333786011' diff --git a/testfiles/type1.vcf b/testfiles/type1.vcf new file mode 100644 index 0000000..271d318 --- /dev/null +++ b/testfiles/type1.vcf @@ -0,0 +1,24 @@ +BEGIN:VCARD +UID:sorted-1 +N:Last;First Name +TEL;HOME:+1-212-5553789 +EMAIL;TYPE=home,work:work@example.com +REV:2017-05-10T14:36:01Z(0) +END:VCARD +BEGIN:VCARD +VERSION:3.0 +UID:photo-1 +FN:photo +N:;photo;;; +PHOTO;TYPE="PNG";ENCODING=b:iVBORw0KGgoAAAANSUhEUgAAAAgAAAA + IAQAAAADsdIMmAAAAC0lEQVQImWNgQAUAABAAASG2FtIAAAAASUVORK5CYII= +EMAIL;TYPE=WORK:photo@example.com +REV:2024-07-25T17:09:12Z(2) +END:VCARD +BEGIN:VCARD +UID:custom-12 +N:Name;A +TEL;HOME:1.800 K L 5 E R R O R +EMAIL;TYPE=home,work:example@example.com +REV:0 +END:VCARD diff --git a/testfiles/type2.vcf b/testfiles/type2.vcf new file mode 100644 index 0000000..02c7035 --- /dev/null +++ b/testfiles/type2.vcf @@ -0,0 +1,10 @@ +BEGIN:VCARD +VERSION:3.0 +EMAIL;TYPE:mail@example.com +FN:Fullname +N:ZeroRev;;;; +ORG:Organization +UID:5a535529-fd93-4448-bae3-bde1ee3ff695 +X-KADDRESSBOOK-X-Profession:Professional Test Services +REV:0 +END:VCARD