From 011b9fd7490fa9b2ed53b7aa879bb0837ccd5c07 Mon Sep 17 00:00:00 2001 From: Rui Sun Date: Wed, 25 Oct 2023 22:54:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AF=B9=E4=BA=8EMP4?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=9A=84=E5=88=9B=E5=BB=BA=E6=97=A5=E6=9C=9F?= =?UTF-8?q?=E6=8F=90=E5=8F=96=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WechatMediaRenamer/MediaFileRenamer.cs | 34 ++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/WechatMediaRenamer/MediaFileRenamer.cs b/WechatMediaRenamer/MediaFileRenamer.cs index 400e29a..5a64bf1 100644 --- a/WechatMediaRenamer/MediaFileRenamer.cs +++ b/WechatMediaRenamer/MediaFileRenamer.cs @@ -4,10 +4,10 @@ using System.IO; using System.Text.RegularExpressions; using System.Drawing; using System.Drawing.Imaging; -using System.Windows.Interop; using MetadataExtractor; using System.Collections.Generic; using MetadataExtractor.Formats.Exif; +using MetadataExtractor.Formats.QuickTime; namespace WechatMediaRenamer { @@ -77,7 +77,9 @@ namespace WechatMediaRenamer { DateTime? shotDate = null; IEnumerable directories = ImageMetadataReader.ReadMetadata(FullFilePath); + Print(directories); foreach (var directory in directories) + { if (directory is ExifSubIfdDirectory) { var subIfdDirectory = directory as ExifSubIfdDirectory; @@ -88,13 +90,41 @@ namespace WechatMediaRenamer } if (subIfdDirectory.ContainsTag(ExifDirectoryBase.TagDateTimeDigitized)) { - shotDate = subIfdDirectory.GetDateTime(ExifDirectoryBase.TagDateTimeDigitized); + shotDate = subIfdDirectory.GetDateTime(ExifDirectoryBase.TagDateTime); break; // Exit the loop since we found the shot date } } + if (directory is QuickTimeMovieHeaderDirectory) + { + var subDirectory = directory as QuickTimeMovieHeaderDirectory; + if (subDirectory.ContainsTag(QuickTimeMovieHeaderDirectory.TagCreated)) + { + shotDate = subDirectory.GetDateTime(QuickTimeMovieHeaderDirectory.TagCreated); + break; + } + } + } return shotDate; } + // Write all extracted values to stdout + static void Print(IEnumerable directories) + { + Console.WriteLine(); + Console.WriteLine("-------------------------------------------------"); + Console.WriteLine(); + foreach (var directory in directories) + { + Console.WriteLine($"-------{directory.GetType()}-------"); + foreach (var tag in directory.Tags) + { + Console.WriteLine($"{directory.Name} - {tag.Name}({tag.Type}) = {tag.Description}"); + Console.WriteLine($" Value: {directory.GetType()}"); + } + } + + } + private string _GetDateStringFromProperty(Image image, int propertyId) { if (!Array.Exists(image.PropertyIdList, id => id == propertyId)) return null;