Handle export from phpMyAdmin
This commit is contained in:
parent
5ec29e81a0
commit
8282821c82
@ -379,7 +379,7 @@ public partial class DlibDotNet
|
|||||||
string cResultsFullGroupDirectory,
|
string cResultsFullGroupDirectory,
|
||||||
string dResultsFullGroupDirectory,
|
string dResultsFullGroupDirectory,
|
||||||
List<Tuple<string, DateTime>> sourceDirectoryChanges,
|
List<Tuple<string, DateTime>> sourceDirectoryChanges,
|
||||||
Dictionary<string, List<MappingFromPhotoPrism>> fileNameToCollection,
|
Dictionary<int, List<MappingFromPhotoPrism>> fileNameToCollection,
|
||||||
Container container,
|
Container container,
|
||||||
int index,
|
int index,
|
||||||
Item item,
|
Item item,
|
||||||
@ -460,7 +460,7 @@ public partial class DlibDotNet
|
|||||||
collection = null;
|
collection = null;
|
||||||
else
|
else
|
||||||
_ = idToLocationContainers.TryGetValue(item.Property.Id.Value, out collection);
|
_ = idToLocationContainers.TryGetValue(item.Property.Id.Value, out collection);
|
||||||
if (!fileNameToCollection.TryGetValue(mappingFromItem.RelativePath[1..], out mappingFromPhotoPrismCollection))
|
if (!fileNameToCollection.TryGetValue(mappingFromItem.Id, out mappingFromPhotoPrismCollection))
|
||||||
mappingFromPhotoPrismCollection = null;
|
mappingFromPhotoPrismCollection = null;
|
||||||
faces = _Faces.GetFaces(outputResolution, dResultsFullGroupDirectory, subFileTuples, parseExceptions, property, mappingFromItem, outputResolutionToResize, collection, mappingFromPhotoPrismCollection);
|
faces = _Faces.GetFaces(outputResolution, dResultsFullGroupDirectory, subFileTuples, parseExceptions, property, mappingFromItem, outputResolutionToResize, collection, mappingFromPhotoPrismCollection);
|
||||||
if (_AppSettings.MaxDegreeOfParallelism < 2)
|
if (_AppSettings.MaxDegreeOfParallelism < 2)
|
||||||
@ -501,7 +501,7 @@ public partial class DlibDotNet
|
|||||||
string dResultsFullGroupDirectory,
|
string dResultsFullGroupDirectory,
|
||||||
string d2ResultsFullGroupDirectory,
|
string d2ResultsFullGroupDirectory,
|
||||||
List<Tuple<string, DateTime>> sourceDirectoryChanges,
|
List<Tuple<string, DateTime>> sourceDirectoryChanges,
|
||||||
Dictionary<string, List<MappingFromPhotoPrism>> fileNameToCollection,
|
Dictionary<int, List<MappingFromPhotoPrism>> fileNameToCollection,
|
||||||
Container container,
|
Container container,
|
||||||
Item[] filteredItems,
|
Item[] filteredItems,
|
||||||
string message)
|
string message)
|
||||||
@ -638,7 +638,7 @@ public partial class DlibDotNet
|
|||||||
return new(cResultsFullGroupDirectory, c2ResultsFullGroupDirectory, dResultsFullGroupDirectory, d2ResultsFullGroupDirectory);
|
return new(cResultsFullGroupDirectory, c2ResultsFullGroupDirectory, dResultsFullGroupDirectory, d2ResultsFullGroupDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FullDoWork(string argZero, string propertyRoot, long ticks, string aResultsFullGroupDirectory, string bResultsFullGroupDirectory, int t, Container[] containers, A_Property propertyLogic, B_Metadata metadata, Dictionary<string, List<MappingFromPhotoPrism>> fileNameToCollection, ReadOnlyDictionary<int, List<LocationContainer<MetadataExtractor.Directory>>> idToLocationContainers, MapLogic mapLogic)
|
private void FullDoWork(string argZero, string propertyRoot, long ticks, string aResultsFullGroupDirectory, string bResultsFullGroupDirectory, int t, Container[] containers, A_Property propertyLogic, B_Metadata metadata, Dictionary<int, List<MappingFromPhotoPrism>> fileNameToCollection, ReadOnlyDictionary<int, List<LocationContainer<MetadataExtractor.Directory>>> idToLocationContainers, MapLogic mapLogic)
|
||||||
{
|
{
|
||||||
if (_Log is null)
|
if (_Log is null)
|
||||||
throw new NullReferenceException(nameof(_Log));
|
throw new NullReferenceException(nameof(_Log));
|
||||||
@ -782,7 +782,7 @@ public partial class DlibDotNet
|
|||||||
}
|
}
|
||||||
Dictionary<int, Dictionary<int, Mapping>> idToNormalizedRectangleToMapping = Map.Models.Stateless.Methods.IMapLogic.GetIdToNormalizedRectangleToFace(distinctFilteredMappingCollection);
|
Dictionary<int, Dictionary<int, Mapping>> idToNormalizedRectangleToMapping = Map.Models.Stateless.Methods.IMapLogic.GetIdToNormalizedRectangleToFace(distinctFilteredMappingCollection);
|
||||||
if (Directory.Exists(fPhotoPrismContentDirectory))
|
if (Directory.Exists(fPhotoPrismContentDirectory))
|
||||||
F_PhotoPrism.WriteMatches(fPhotoPrismContentDirectory, _Configuration.PersonBirthdayFormat, ticks, distinctFilteredFaces, mapLogic);
|
F_PhotoPrism.WriteMatches(fPhotoPrismContentDirectory, _Configuration.MappingDefaultName, _Configuration.PersonBirthdayFormat, ticks, distinctFilteredFaces, mapLogic);
|
||||||
if (_Configuration.SaveShortcutsForOutputResolutions.Contains(outputResolution))
|
if (_Configuration.SaveShortcutsForOutputResolutions.Contains(outputResolution))
|
||||||
mapLogic.SaveShortcutsForOutputResolutionsDuringMapLogic(containers, personKeyToIds, dFacesContentDirectory, distinctFilteredMappingCollection);
|
mapLogic.SaveShortcutsForOutputResolutionsDuringMapLogic(containers, personKeyToIds, dFacesContentDirectory, distinctFilteredMappingCollection);
|
||||||
if (!string.IsNullOrEmpty(_Configuration.PersonCharacters))
|
if (!string.IsNullOrEmpty(_Configuration.PersonCharacters))
|
||||||
@ -1099,7 +1099,7 @@ public partial class DlibDotNet
|
|||||||
string fPhotoPrismContentDirectory;
|
string fPhotoPrismContentDirectory;
|
||||||
string fPhotoPrismSingletonDirectory;
|
string fPhotoPrismSingletonDirectory;
|
||||||
Dictionary<long, List<int>> personKeyToIds;
|
Dictionary<long, List<int>> personKeyToIds;
|
||||||
Dictionary<string, List<MappingFromPhotoPrism>> fileNameToCollection;
|
Dictionary<int, List<MappingFromPhotoPrism>> fileNameToCollection;
|
||||||
(aResultsFullGroupDirectory, bResultsFullGroupDirectory) = GetResultsFullGroupDirectories();
|
(aResultsFullGroupDirectory, bResultsFullGroupDirectory) = GetResultsFullGroupDirectories();
|
||||||
string a2PeopleSingletonDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(_Configuration.PropertyConfiguration, nameof(A2_People), "{}");
|
string a2PeopleSingletonDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(_Configuration.PropertyConfiguration, nameof(A2_People), "{}");
|
||||||
a2PeopleContentDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(_Configuration.PropertyConfiguration, nameof(A2_People), "([])");
|
a2PeopleContentDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(_Configuration.PropertyConfiguration, nameof(A2_People), "([])");
|
||||||
|
@ -52,7 +52,7 @@ public record DatabaseFile(
|
|||||||
[property: JsonPropertyName("updated_in")] string UpdatedIn,
|
[property: JsonPropertyName("updated_in")] string UpdatedIn,
|
||||||
[property: JsonPropertyName("published_at")] object PublishedAt,
|
[property: JsonPropertyName("published_at")] object PublishedAt,
|
||||||
[property: JsonPropertyName("deleted_at")] object DeletedAt)
|
[property: JsonPropertyName("deleted_at")] object DeletedAt)
|
||||||
{
|
{
|
||||||
|
|
||||||
internal static Shared.Models.DatabaseFile Map(DatabaseFile databaseFile)
|
internal static Shared.Models.DatabaseFile Map(DatabaseFile databaseFile)
|
||||||
{
|
{
|
||||||
@ -61,51 +61,51 @@ public record DatabaseFile(
|
|||||||
(int fileWidth, int fileHeight) = (int.Parse(databaseFile.FileWidth), int.Parse(databaseFile.FileHeight));
|
(int fileWidth, int fileHeight) = (int.Parse(databaseFile.FileWidth), int.Parse(databaseFile.FileHeight));
|
||||||
result = new(id,
|
result = new(id,
|
||||||
photoId,
|
photoId,
|
||||||
databaseFile.PhotoUid,
|
F_PhotoPrism.HexStringToString(databaseFile.PhotoUid),
|
||||||
databaseFile.PhotoTakenAt,
|
F_PhotoPrism.HexStringToString(databaseFile.PhotoTakenAt),
|
||||||
databaseFile.TimeIndex,
|
F_PhotoPrism.HexStringToString(databaseFile.TimeIndex),
|
||||||
databaseFile.MediaId,
|
F_PhotoPrism.HexStringToString(databaseFile.MediaId),
|
||||||
databaseFile.MediaUtc,
|
F_PhotoPrism.HexStringToString(databaseFile.MediaUtc),
|
||||||
databaseFile.InstanceId,
|
F_PhotoPrism.HexStringToString(databaseFile.InstanceId),
|
||||||
databaseFile.FileUid,
|
F_PhotoPrism.HexStringToString(databaseFile.FileUid),
|
||||||
databaseFile.FileName,
|
F_PhotoPrism.HexStringToString(databaseFile.FileName),
|
||||||
databaseFile.FileRoot,
|
F_PhotoPrism.HexStringToString(databaseFile.FileRoot),
|
||||||
databaseFile.OriginalName,
|
F_PhotoPrism.HexStringToString(databaseFile.OriginalName),
|
||||||
databaseFile.FileHash,
|
F_PhotoPrism.HexStringToString(databaseFile.FileHash),
|
||||||
databaseFile.FileSize,
|
F_PhotoPrism.HexStringToString(databaseFile.FileSize),
|
||||||
databaseFile.FileCodec,
|
F_PhotoPrism.HexStringToString(databaseFile.FileCodec),
|
||||||
databaseFile.FileType,
|
F_PhotoPrism.HexStringToString(databaseFile.FileType),
|
||||||
databaseFile.MediaType,
|
F_PhotoPrism.HexStringToString(databaseFile.MediaType),
|
||||||
databaseFile.FileMime,
|
F_PhotoPrism.HexStringToString(databaseFile.FileMime),
|
||||||
databaseFile.FilePrimary,
|
F_PhotoPrism.HexStringToString(databaseFile.FilePrimary),
|
||||||
databaseFile.FileSidecar,
|
F_PhotoPrism.HexStringToString(databaseFile.FileSidecar),
|
||||||
databaseFile.FileMissing,
|
F_PhotoPrism.HexStringToString(databaseFile.FileMissing),
|
||||||
databaseFile.FilePortrait,
|
F_PhotoPrism.HexStringToString(databaseFile.FilePortrait),
|
||||||
databaseFile.FileVideo,
|
F_PhotoPrism.HexStringToString(databaseFile.FileVideo),
|
||||||
databaseFile.FileDuration,
|
F_PhotoPrism.HexStringToString(databaseFile.FileDuration),
|
||||||
databaseFile.FileFps,
|
F_PhotoPrism.HexStringToString(databaseFile.FileFps),
|
||||||
databaseFile.FileFrames,
|
F_PhotoPrism.HexStringToString(databaseFile.FileFrames),
|
||||||
fileWidth,
|
fileWidth,
|
||||||
fileHeight,
|
fileHeight,
|
||||||
databaseFile.FileOrientation,
|
F_PhotoPrism.HexStringToString(databaseFile.FileOrientation),
|
||||||
databaseFile.FileOrientationSrc,
|
F_PhotoPrism.HexStringToString(databaseFile.FileOrientationSrc),
|
||||||
databaseFile.FileProjection,
|
F_PhotoPrism.HexStringToString(databaseFile.FileProjection),
|
||||||
databaseFile.FileAspectRatio,
|
F_PhotoPrism.HexStringToString(databaseFile.FileAspectRatio),
|
||||||
databaseFile.FileHdr,
|
F_PhotoPrism.HexStringToString(databaseFile.FileHdr),
|
||||||
databaseFile.FileWatermark,
|
F_PhotoPrism.HexStringToString(databaseFile.FileWatermark),
|
||||||
databaseFile.FileColorProfile,
|
F_PhotoPrism.HexStringToString(databaseFile.FileColorProfile),
|
||||||
databaseFile.FileMainColor,
|
F_PhotoPrism.HexStringToString(databaseFile.FileMainColor),
|
||||||
databaseFile.FileColors,
|
F_PhotoPrism.HexStringToString(databaseFile.FileColors),
|
||||||
databaseFile.FileLuminance,
|
F_PhotoPrism.HexStringToString(databaseFile.FileLuminance),
|
||||||
databaseFile.FileDiff,
|
F_PhotoPrism.HexStringToString(databaseFile.FileDiff),
|
||||||
databaseFile.FileChroma,
|
F_PhotoPrism.HexStringToString(databaseFile.FileChroma),
|
||||||
databaseFile.FileSoftware,
|
F_PhotoPrism.HexStringToString(databaseFile.FileSoftware),
|
||||||
databaseFile.FileError,
|
F_PhotoPrism.HexStringToString(databaseFile.FileError),
|
||||||
databaseFile.ModTime,
|
F_PhotoPrism.HexStringToString(databaseFile.ModTime),
|
||||||
databaseFile.CreatedAt,
|
F_PhotoPrism.HexStringToString(databaseFile.CreatedAt),
|
||||||
databaseFile.CreatedIn,
|
F_PhotoPrism.HexStringToString(databaseFile.CreatedIn),
|
||||||
databaseFile.UpdatedAt,
|
F_PhotoPrism.HexStringToString(databaseFile.UpdatedAt),
|
||||||
databaseFile.UpdatedIn,
|
F_PhotoPrism.HexStringToString(databaseFile.UpdatedIn),
|
||||||
databaseFile.PublishedAt,
|
databaseFile.PublishedAt,
|
||||||
databaseFile.DeletedAt);
|
databaseFile.DeletedAt);
|
||||||
return result;
|
return result;
|
||||||
|
@ -32,28 +32,28 @@ public record Marker(
|
|||||||
Shared.Models.Marker result;
|
Shared.Models.Marker result;
|
||||||
(double x, double y, double w, double h, double score) = (double.Parse(marker.X), double.Parse(marker.Y), double.Parse(marker.W), double.Parse(marker.H), double.Parse(marker.Score));
|
(double x, double y, double w, double h, double score) = (double.Parse(marker.X), double.Parse(marker.Y), double.Parse(marker.W), double.Parse(marker.H), double.Parse(marker.Score));
|
||||||
result = new(
|
result = new(
|
||||||
marker.MarkerUid,
|
F_PhotoPrism.HexStringToString(marker.MarkerUid),
|
||||||
marker.FileUid,
|
F_PhotoPrism.HexStringToString(marker.FileUid),
|
||||||
marker.MarkerType,
|
F_PhotoPrism.HexStringToString(marker.MarkerType),
|
||||||
marker.MarkerSrc,
|
F_PhotoPrism.HexStringToString(marker.MarkerSrc),
|
||||||
marker.MarkerName,
|
F_PhotoPrism.HexStringToString(marker.MarkerName),
|
||||||
marker.MarkerReview,
|
F_PhotoPrism.HexStringToString(marker.MarkerReview),
|
||||||
marker.MarkerInvalid,
|
F_PhotoPrism.HexStringToString(marker.MarkerInvalid),
|
||||||
marker.SubjUid,
|
F_PhotoPrism.HexStringToString(marker.SubjUid),
|
||||||
marker.SubjSrc,
|
F_PhotoPrism.HexStringToString(marker.SubjSrc),
|
||||||
marker.FaceId,
|
F_PhotoPrism.HexStringToString(marker.FaceId),
|
||||||
marker.FaceDist,
|
F_PhotoPrism.HexStringToString(marker.FaceDist),
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
w,
|
w,
|
||||||
h,
|
h,
|
||||||
marker.Q,
|
F_PhotoPrism.HexStringToString(marker.Q),
|
||||||
marker.Size,
|
F_PhotoPrism.HexStringToString(marker.Size),
|
||||||
score,
|
score,
|
||||||
marker.Thumb,
|
F_PhotoPrism.HexStringToString(marker.Thumb),
|
||||||
marker.MatchedAt,
|
F_PhotoPrism.HexStringToString(marker.MatchedAt),
|
||||||
marker.CreatedAt,
|
F_PhotoPrism.HexStringToString(marker.CreatedAt),
|
||||||
marker.UpdatedAt);
|
F_PhotoPrism.HexStringToString(marker.UpdatedAt));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,14 +46,29 @@ public class F_PhotoPrism
|
|||||||
private static Dictionary<string, List<Shared.Models.Marker>> GetFileUIdToMarkers(string fPhotoPrismSingletonDirectory)
|
private static Dictionary<string, List<Shared.Models.Marker>> GetFileUIdToMarkers(string fPhotoPrismSingletonDirectory)
|
||||||
{
|
{
|
||||||
Dictionary<string, List<Shared.Models.Marker>> results = new();
|
Dictionary<string, List<Shared.Models.Marker>> results = new();
|
||||||
|
string fileUid;
|
||||||
Marker[]? markers = GetMarkers(fPhotoPrismSingletonDirectory);
|
Marker[]? markers = GetMarkers(fPhotoPrismSingletonDirectory);
|
||||||
if (markers is null)
|
if (markers is null)
|
||||||
throw new NullReferenceException(nameof(markers));
|
throw new NullReferenceException(nameof(markers));
|
||||||
foreach (Marker marker in markers)
|
foreach (Marker marker in markers)
|
||||||
{
|
{
|
||||||
if (!results.ContainsKey(marker.FileUid))
|
fileUid = HexStringToString(marker.FileUid);
|
||||||
results.Add(marker.FileUid, new());
|
if (!results.ContainsKey(fileUid))
|
||||||
results[marker.FileUid].Add(Marker.Map(marker));
|
results.Add(fileUid, new());
|
||||||
|
results[fileUid].Add(Marker.Map(marker));
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Dictionary<int, List<MappingFromPhotoPrism>>? GetCollectionFile(string fileName)
|
||||||
|
{
|
||||||
|
Dictionary<int, List<MappingFromPhotoPrism>>? results;
|
||||||
|
if (!File.Exists(fileName))
|
||||||
|
results = null;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string json = File.ReadAllText(fileName);
|
||||||
|
results = JsonSerializer.Deserialize<Dictionary<int, List<MappingFromPhotoPrism>>>(json);
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
@ -80,43 +95,86 @@ public class F_PhotoPrism
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Dictionary<string, List<MappingFromPhotoPrism>> GetFileNameToCollection(string fPhotoPrismSingletonDirectory)
|
public static Dictionary<int, List<MappingFromPhotoPrism>> GetFileNameToCollection(string fPhotoPrismSingletonDirectory)
|
||||||
{
|
{
|
||||||
Dictionary<string, List<MappingFromPhotoPrism>> results = new();
|
Dictionary<int, List<MappingFromPhotoPrism>>? results;
|
||||||
List<Shared.Models.Marker>? makers;
|
string fileName = Path.Combine(fPhotoPrismSingletonDirectory, "collection.json");
|
||||||
MappingFromPhotoPrism mappingFromPhotoPrism;
|
results = GetCollectionFile(fileName);
|
||||||
List<MappingFromPhotoPrism>? mappingFromPhotoPrismCollection;
|
if (results is null)
|
||||||
List<Shared.Models.DatabaseFile>? databaseFiles = GetDatabaseFiles(fPhotoPrismSingletonDirectory);
|
|
||||||
if (databaseFiles is not null)
|
|
||||||
{
|
{
|
||||||
Dictionary<string, List<Shared.Models.Marker>> fileUIdToMarkers = GetFileUIdToMarkers(fPhotoPrismSingletonDirectory);
|
int id;
|
||||||
foreach (Shared.Models.DatabaseFile databaseFile in databaseFiles)
|
results = new();
|
||||||
|
string fileNameWithoutExtension;
|
||||||
|
List<Shared.Models.Marker>? makers;
|
||||||
|
MappingFromPhotoPrism mappingFromPhotoPrism;
|
||||||
|
List<MappingFromPhotoPrism>? mappingFromPhotoPrismCollection;
|
||||||
|
List<Shared.Models.DatabaseFile>? databaseFiles = GetDatabaseFiles(fPhotoPrismSingletonDirectory);
|
||||||
|
if (databaseFiles is not null)
|
||||||
{
|
{
|
||||||
if (!results.TryGetValue(databaseFile.FileName, out mappingFromPhotoPrismCollection))
|
Dictionary<string, List<Shared.Models.Marker>> fileUIdToMarkers = GetFileUIdToMarkers(fPhotoPrismSingletonDirectory);
|
||||||
|
foreach (Shared.Models.DatabaseFile databaseFile in databaseFiles)
|
||||||
{
|
{
|
||||||
results.Add(databaseFile.FileName, new());
|
if (databaseFile.FileName is null || databaseFile.FileUid is null)
|
||||||
if (!results.TryGetValue(databaseFile.FileName, out mappingFromPhotoPrismCollection))
|
continue;
|
||||||
throw new Exception();
|
fileNameWithoutExtension = Path.GetFileNameWithoutExtension(databaseFile.FileName);
|
||||||
|
if (!int.TryParse(fileNameWithoutExtension, out id))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!results.TryGetValue(id, out mappingFromPhotoPrismCollection))
|
||||||
|
{
|
||||||
|
results.Add(id, new());
|
||||||
|
if (!results.TryGetValue(id, out mappingFromPhotoPrismCollection))
|
||||||
|
throw new Exception();
|
||||||
|
}
|
||||||
|
if (!fileUIdToMarkers.TryGetValue(databaseFile.FileUid, out makers))
|
||||||
|
mappingFromPhotoPrism = new(databaseFile, new());
|
||||||
|
else
|
||||||
|
mappingFromPhotoPrism = new(databaseFile, makers);
|
||||||
|
mappingFromPhotoPrismCollection.Add(mappingFromPhotoPrism);
|
||||||
}
|
}
|
||||||
if (!fileUIdToMarkers.TryGetValue(databaseFile.FileUid, out makers))
|
|
||||||
mappingFromPhotoPrism = new(databaseFile, new());
|
|
||||||
else
|
|
||||||
mappingFromPhotoPrism = new(databaseFile, makers);
|
|
||||||
mappingFromPhotoPrismCollection.Add(mappingFromPhotoPrism);
|
|
||||||
}
|
}
|
||||||
|
string json = JsonSerializer.Serialize(results);
|
||||||
|
_ = IPath.WriteAllText(fileName, json, updateDateWhenMatches: false, compareBeforeWrite: true, updateToWhenMatches: null);
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void WriteMatches(string fPhotoPrismContentDirectory, string personBirthdayFormat, long ticks, List<Face> distinctFilteredFaces, Shared.Models.Methods.IMapLogic mapLogic)
|
private static void PopulateSubjects(string mappingDefaultName, string personBirthdayFormat, List<string> subjects, StringBuilder stringBuilder, PersonContainer[] personContainers, (MappingFromPhotoPrism MappingFromPhotoPrism, Shared.Models.Marker Marker, double Percent)[] sortedCollection)
|
||||||
{
|
{
|
||||||
long? personKey;
|
long? personKey;
|
||||||
|
string personName;
|
||||||
const int zero = 0;
|
const int zero = 0;
|
||||||
int? normalizedRectangle;
|
|
||||||
string personKeyFormatted;
|
string personKeyFormatted;
|
||||||
List<string> subjects = new();
|
|
||||||
PersonBirthday personBirthday;
|
PersonBirthday personBirthday;
|
||||||
string personDisplayDirectoryName;
|
foreach ((MappingFromPhotoPrism mappingFromPhotoPrism, Shared.Models.Marker marker, double percent) in sortedCollection)
|
||||||
|
{
|
||||||
|
foreach (PersonContainer personContainer in personContainers)
|
||||||
|
{
|
||||||
|
if (personContainer.Key is null || personContainer.Birthdays is null || personContainer.Person is null || !personContainer.Birthdays.Any())
|
||||||
|
continue;
|
||||||
|
if (IPerson.IsDefaultName(mappingDefaultName, personContainer.DisplayDirectoryName) || IPerson.IsDefaultName(mappingDefaultName, personContainer.Person))
|
||||||
|
continue;
|
||||||
|
personBirthday = personContainer.Birthdays[zero];
|
||||||
|
personKey = personBirthday.Value.Ticks;
|
||||||
|
personName = personContainer.Person.GetFullName();
|
||||||
|
personKeyFormatted = IPersonBirthday.GetFormatted(personBirthdayFormat, personBirthday);
|
||||||
|
subjects.Add($"update `subjects` set subj_alias = '{personKeyFormatted}' where subj_name = '{personName}';");
|
||||||
|
_ = stringBuilder.
|
||||||
|
Append("update `markers` set subj_src = 'manual', marker_name = '").
|
||||||
|
Append(personName).
|
||||||
|
Append("' where marker_uid = '").
|
||||||
|
Append(marker.MarkerUid).
|
||||||
|
AppendLine("';");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void WriteMatches(string fPhotoPrismContentDirectory, string mappingDefaultName, string personBirthdayFormat, long ticks, List<Face> distinctFilteredFaces, Shared.Models.Methods.IMapLogic mapLogic)
|
||||||
|
{
|
||||||
|
string file;
|
||||||
|
string text;
|
||||||
|
int? normalizedRectangle;
|
||||||
|
List<string> subjects = new();
|
||||||
StringBuilder stringBuilder = new();
|
StringBuilder stringBuilder = new();
|
||||||
PersonContainer[]? personContainers;
|
PersonContainer[]? personContainers;
|
||||||
System.Drawing.Rectangle dlibRectangle;
|
System.Drawing.Rectangle dlibRectangle;
|
||||||
@ -158,28 +216,34 @@ public class F_PhotoPrism
|
|||||||
if (!collection.Any())
|
if (!collection.Any())
|
||||||
continue;
|
continue;
|
||||||
sortedCollection = collection.OrderByDescending(l => l.Percent).ToArray();
|
sortedCollection = collection.OrderByDescending(l => l.Percent).ToArray();
|
||||||
foreach ((MappingFromPhotoPrism mappingFromPhotoPrism, Shared.Models.Marker marker, double percent) in sortedCollection)
|
PopulateSubjects(mappingDefaultName, personBirthdayFormat, subjects, stringBuilder, personContainers, sortedCollection);
|
||||||
{
|
|
||||||
foreach (PersonContainer personContainer in personContainers)
|
|
||||||
{
|
|
||||||
if (personContainer.Key is null || personContainer.Birthdays is null || !personContainer.Birthdays.Any())
|
|
||||||
continue;
|
|
||||||
personBirthday = personContainer.Birthdays[zero];
|
|
||||||
personKey = personBirthday.Value.Ticks;
|
|
||||||
personDisplayDirectoryName = personContainer.DisplayDirectoryName;
|
|
||||||
personKeyFormatted = IPersonBirthday.GetFormatted(personBirthdayFormat, personBirthday);
|
|
||||||
subjects.Add($"update `subjects` set subj_alias = '{personKeyFormatted}' where subj_name = '{personDisplayDirectoryName}';");
|
|
||||||
_ = stringBuilder.
|
|
||||||
Append("update `markers` set subj_src = 'manual', marker_name = '").
|
|
||||||
Append(personDisplayDirectoryName).
|
|
||||||
Append("' where marker_uid = '").
|
|
||||||
Append(marker.MarkerUid).
|
|
||||||
AppendLine("';");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
File.WriteAllLines(Path.Combine(fPhotoPrismContentDirectory, $"{ticks}-subject_alias_update.sql"), subjects.Distinct());
|
if (subjects.Any())
|
||||||
File.WriteAllText(Path.Combine(fPhotoPrismContentDirectory, $"{ticks}-marker_name_update.sql"), stringBuilder.ToString());
|
{
|
||||||
|
file = Path.Combine(fPhotoPrismContentDirectory, $"{ticks}-subject_alias_update.sql");
|
||||||
|
text = string.Join(Environment.NewLine, subjects.Distinct());
|
||||||
|
_ = IPath.WriteAllText(file, text, updateDateWhenMatches: false, compareBeforeWrite: true, updateToWhenMatches: null);
|
||||||
|
file = Path.Combine(fPhotoPrismContentDirectory, $"{ticks}-marker_name_update.sql");
|
||||||
|
text = stringBuilder.ToString();
|
||||||
|
_ = IPath.WriteAllText(file, text, updateDateWhenMatches: false, compareBeforeWrite: true, updateToWhenMatches: null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static string HexStringToString(string text)
|
||||||
|
{
|
||||||
|
string result;
|
||||||
|
if (text.Length < 2 || text[0] != '0' || text[1] != 'x')
|
||||||
|
result = text;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string after = text[2..];
|
||||||
|
byte[] bytes = Enumerable.Range(0, after.Length)
|
||||||
|
.Where(x => x % 2 == 0)
|
||||||
|
.Select(x => Convert.ToByte(after.Substring(x, 2), 16))
|
||||||
|
.ToArray();
|
||||||
|
result = Encoding.UTF8.GetString(bytes);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -5,20 +5,20 @@ public record DatabaseFile(
|
|||||||
int PhotoId,
|
int PhotoId,
|
||||||
string PhotoUid,
|
string PhotoUid,
|
||||||
string PhotoTakenAt,
|
string PhotoTakenAt,
|
||||||
string TimeIndex,
|
string? TimeIndex,
|
||||||
string MediaId,
|
string? MediaId,
|
||||||
string MediaUtc,
|
string MediaUtc,
|
||||||
string InstanceId,
|
string? InstanceId,
|
||||||
string FileUid,
|
string? FileUid,
|
||||||
string FileName,
|
string? FileName,
|
||||||
string FileRoot,
|
string? FileRoot,
|
||||||
string OriginalName,
|
string? OriginalName,
|
||||||
string FileHash,
|
string? FileHash,
|
||||||
string FileSize,
|
string FileSize,
|
||||||
string FileCodec,
|
string? FileCodec,
|
||||||
string FileType,
|
string? FileType,
|
||||||
string MediaType,
|
string? MediaType,
|
||||||
string FileMime,
|
string? FileMime,
|
||||||
string FilePrimary,
|
string FilePrimary,
|
||||||
string FileSidecar,
|
string FileSidecar,
|
||||||
string FileMissing,
|
string FileMissing,
|
||||||
@ -30,19 +30,19 @@ public record DatabaseFile(
|
|||||||
int FileWidth,
|
int FileWidth,
|
||||||
int FileHeight,
|
int FileHeight,
|
||||||
string FileOrientation,
|
string FileOrientation,
|
||||||
string FileOrientationSrc,
|
string? FileOrientationSrc,
|
||||||
string FileProjection,
|
string FileProjection,
|
||||||
string FileAspectRatio,
|
string FileAspectRatio,
|
||||||
string FileHdr,
|
string FileHdr,
|
||||||
string FileWatermark,
|
string FileWatermark,
|
||||||
string FileColorProfile,
|
string? FileColorProfile,
|
||||||
string FileMainColor,
|
string? FileMainColor,
|
||||||
string FileColors,
|
string? FileColors,
|
||||||
string FileLuminance,
|
string? FileLuminance,
|
||||||
string FileDiff,
|
string FileDiff,
|
||||||
string FileChroma,
|
string FileChroma,
|
||||||
string FileSoftware,
|
string FileSoftware,
|
||||||
string FileError,
|
string? FileError,
|
||||||
string ModTime,
|
string ModTime,
|
||||||
string CreatedAt,
|
string CreatedAt,
|
||||||
string CreatedIn,
|
string CreatedIn,
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
namespace View_by_Distance.Shared.Models;
|
namespace View_by_Distance.Shared.Models;
|
||||||
|
|
||||||
public record Marker(
|
public record Marker(
|
||||||
string MarkerUid,
|
string? MarkerUid,
|
||||||
string FileUid,
|
string? FileUid,
|
||||||
string MarkerType,
|
string? MarkerType,
|
||||||
string MarkerSrc,
|
string? MarkerSrc,
|
||||||
string MarkerName,
|
string? MarkerName,
|
||||||
string MarkerReview,
|
string MarkerReview,
|
||||||
string MarkerInvalid,
|
string MarkerInvalid,
|
||||||
string SubjUid,
|
string? SubjUid,
|
||||||
string SubjSrc,
|
string? SubjSrc,
|
||||||
string FaceId,
|
string? FaceId,
|
||||||
string FaceDist,
|
string FaceDist,
|
||||||
double X,
|
double X,
|
||||||
double Y,
|
double Y,
|
||||||
@ -19,7 +19,7 @@ public record Marker(
|
|||||||
string Q,
|
string Q,
|
||||||
string Size,
|
string Size,
|
||||||
double Score,
|
double Score,
|
||||||
string Thumb,
|
string? Thumb,
|
||||||
string MatchedAt,
|
string MatchedAt,
|
||||||
string CreatedAt,
|
string CreatedAt,
|
||||||
string UpdatedAt);
|
string UpdatedAt);
|
Loading…
x
Reference in New Issue
Block a user