Re-write
This commit is contained in:
@ -78,7 +78,7 @@ public class B_Metadata
|
||||
return results;
|
||||
}
|
||||
|
||||
public (int, List<KeyValuePair<string, string>>) GetMetadataCollection(string bResultsFullGroupDirectory, List<Tuple<string, DateTime>> subFileTuples, List<string> parseExceptions, Property.Models.Item item)
|
||||
public (int, List<KeyValuePair<string, string>>) GetMetadataCollection(string bResultsFullGroupDirectory, List<Tuple<string, DateTime>> subFileTuples, List<string> parseExceptions, Shared.Models.Item item)
|
||||
{
|
||||
List<KeyValuePair<string, string>> results = new();
|
||||
if (item.Property?.Id is null)
|
||||
@ -151,7 +151,7 @@ public class B_Metadata
|
||||
json = JsonSerializer.Serialize(dictionary, _WriteIndentedJsonSerializerOptions);
|
||||
bool updateDateWhenMatches = dateTimes.Any() && fileInfo.Exists && dateTimes.Max() > fileInfo.LastWriteTime;
|
||||
DateTime? dateTime = !updateDateWhenMatches ? null : dateTimes.Max();
|
||||
if (Property.Models.Stateless.IPath.WriteAllText(fileInfo.FullName, json, updateDateWhenMatches, compareBeforeWrite: true, updateToWhenMatches: dateTime))
|
||||
if (Shared.Models.Stateless.Methods.IPath.WriteAllText(fileInfo.FullName, json, updateDateWhenMatches, compareBeforeWrite: true, updateToWhenMatches: dateTime))
|
||||
{
|
||||
if (!_ForceMetadataLastWriteTimeToCreationTime && (!fileInfo.Exists || fileInfo.LastWriteTime == fileInfo.CreationTime))
|
||||
subFileTuples.Add(new Tuple<string, DateTime>(nameof(B_Metadata), DateTime.Now));
|
||||
@ -171,29 +171,4 @@ public class B_Metadata
|
||||
return new(dictionary.Count, results);
|
||||
}
|
||||
|
||||
public static List<KeyValuePair<string, string>> GetFiltered(List<KeyValuePair<string, string>> metadataCollection)
|
||||
{
|
||||
List<KeyValuePair<string, string>> results = new();
|
||||
foreach (KeyValuePair<string, string> keyValuePair in metadataCollection)
|
||||
{
|
||||
if (keyValuePair.Key.Contains("File") || keyValuePair.Key.Contains("JPEG") || keyValuePair.Key.Contains("Orientation") || keyValuePair.Key.Contains("Thumbnail"))
|
||||
continue;
|
||||
results.Add(new(keyValuePair.Key, keyValuePair.Value));
|
||||
}
|
||||
if (!results.Any())
|
||||
results = metadataCollection;
|
||||
return results;
|
||||
}
|
||||
|
||||
public static string GetUniqueImageId(List<KeyValuePair<string, string>> metadataCollection)
|
||||
{
|
||||
string result = string.Empty;
|
||||
const string exifSubIFD = "Exif SubIFD";
|
||||
const string uniqueImageID = "42016\tUnique Image ID";
|
||||
List<string> uniqueImageIDs = (from l in metadataCollection where l.Key.StartsWith(exifSubIFD) && l.Key.EndsWith(uniqueImageID) select l.Value).ToList();
|
||||
if (uniqueImageIDs.Any())
|
||||
result = uniqueImageIDs[0];
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user