Handle export from phpMyAdmin

This commit is contained in:
Mike Phares 2023-06-18 10:54:13 -07:00
parent adb4015ac9
commit 5ec29e81a0
8 changed files with 309 additions and 95 deletions

View File

@ -13,6 +13,7 @@ completedColumns:
## Todo
- [import-know-faces-into-db](tasks/import-know-faces-into-db.md)
## In Progress
@ -21,3 +22,5 @@ completedColumns:
- [run-scan-originals](tasks/run-scan-originals.md)
## Done
- [eof-error](tasks/eof-error.md)

23
.kanbn/tasks/eof-error.md Normal file
View File

@ -0,0 +1,23 @@
---
created: 2023-06-12T15:44:11.932Z
updated: 2023-06-12T15:45:59.891Z
assigned: ""
progress: 0
tags: []
---
# eof-error
```bash
C:/Docker/photoprism/originals/()/_ _ _/84/-50458384.jpg
C:/Docker/photoprism/originals/()/_ _ _/82/2018924182.jpg
C:/Docker/photoprism/originals/()/_ _ _/74/2104544874.jpg
C:/Docker/photoprism/originals/()/_ _ _/52/-2050448352.jpg
C:/Docker/photoprism/originals/()/_ _ _/48/-57428548.jpg
C:/Docker/photoprism/originals/()/_ _ _/43/-1820919743.jpg
C:/Docker/photoprism/originals/()/_ _ _/30/661798030.jpg
C:/Docker/photoprism/originals/()/_ _ _/27/-1959020527.jpg
C:/Docker/photoprism/originals/()/_ _ _/12/1806593512.jpg
C:/Docker/photoprism/originals/()/_ _ _/02/1985552702.jpg
C:/Docker/photoprism/originals/()/_ _ _/00/1794633000.jpg
```

View File

@ -1139,13 +1139,13 @@ public partial class DlibDotNet
propertyRoot = Property.Models.Stateless.IResult.GetResultsGroupDirectory(_Configuration.PropertyConfiguration, nameof(A_Property), create: false);
propertyLogic = new(_AppSettings.MaxDegreeOfParallelism, _Configuration.PropertyConfiguration, _Resize.FileNameExtension, _Configuration.Reverse, aResultsFullGroupDirectory);
}
fileNameToCollection = !Directory.Exists(fPhotoPrismSingletonDirectory) ? fileNameToCollection = new() : F_PhotoPrism.GetFileNameToCollection(fPhotoPrismSingletonDirectory);
B_Metadata metadata = new(_Configuration.PropertyConfiguration, _Configuration.ForceMetadataLastWriteTimeToCreationTime, _Configuration.PropertiesChangedForMetadata, bResultsFullGroupDirectory);
containers = Shared.Models.Stateless.Methods.IContainer.SortContainers(_Configuration.PropertyConfiguration, _Configuration.IgnoreRelativePaths, _ArgZeroIsConfigurationRootDirectory, argZero, containers);
personKeyToIds = mapLogic.GetPersonKeyToIds();
if (!string.IsNullOrEmpty(_Configuration.GenealogicalDataCommunicationFile) && !string.IsNullOrEmpty(a2PeopleContentDirectory) && _GenealogicalDataCommunicationHeaderLines is not null && _GenealogicalDataCommunicationFooterLines is not null && _GenealogicalDataCommunicationHeaderLines.Any() && _GenealogicalDataCommunicationFooterLines.Any())
Shared.Models.Stateless.Methods.IGenealogicalDataCommunication.CreateTree(_Configuration.MappingDefaultName, _Configuration.PersonBirthdayFormat, _Configuration.PropertyConfiguration.ResultAllInOne, _PersonContainers, _GenealogicalDataCommunicationHeaderLines, _GenealogicalDataCommunicationFooterLines, ticks, a2PeopleContentDirectory, personKeyToIds);
ReadOnlyDictionary<int, List<LocationContainer<MetadataExtractor.Directory>>> idToLocationContainers = mapLogic.GetIdToLocationContainers();
fileNameToCollection = !Directory.Exists(fPhotoPrismSingletonDirectory) ? fileNameToCollection = new() : F_PhotoPrism.GetFileNameToCollection(fPhotoPrismSingletonDirectory);
FullDoWork(argZero, propertyRoot, ticks, aResultsFullGroupDirectory, bResultsFullGroupDirectory, t, containers, propertyLogic, metadata, fileNameToCollection, idToLocationContainers, mapLogic);
if (_Configuration.LookForAbandoned)
LookForAbandoned(bResultsFullGroupDirectory, containers, idToLocationContainers);

View File

@ -0,0 +1,114 @@
using System.Text.Json.Serialization;
namespace View_by_Distance.PhotoPrism.Models;
public record DatabaseFile(
[property: JsonPropertyName("id")] string Id,
[property: JsonPropertyName("photo_id")] string PhotoId,
[property: JsonPropertyName("photo_uid")] string PhotoUid,
[property: JsonPropertyName("photo_taken_at")] string PhotoTakenAt,
[property: JsonPropertyName("time_index")] string TimeIndex,
[property: JsonPropertyName("media_id")] string MediaId,
[property: JsonPropertyName("media_utc")] string MediaUtc,
[property: JsonPropertyName("instance_id")] string InstanceId,
[property: JsonPropertyName("file_uid")] string FileUid,
[property: JsonPropertyName("file_name")] string FileName,
[property: JsonPropertyName("file_root")] string FileRoot,
[property: JsonPropertyName("original_name")] string OriginalName,
[property: JsonPropertyName("file_hash")] string FileHash,
[property: JsonPropertyName("file_size")] string FileSize,
[property: JsonPropertyName("file_codec")] string FileCodec,
[property: JsonPropertyName("file_type")] string FileType,
[property: JsonPropertyName("media_type")] string MediaType,
[property: JsonPropertyName("file_mime")] string FileMime,
[property: JsonPropertyName("file_primary")] string FilePrimary,
[property: JsonPropertyName("file_sidecar")] string FileSidecar,
[property: JsonPropertyName("file_missing")] string FileMissing,
[property: JsonPropertyName("file_portrait")] string FilePortrait,
[property: JsonPropertyName("file_video")] string FileVideo,
[property: JsonPropertyName("file_duration")] string FileDuration,
[property: JsonPropertyName("file_fps")] string FileFps,
[property: JsonPropertyName("file_frames")] string FileFrames,
[property: JsonPropertyName("file_width")] string FileWidth,
[property: JsonPropertyName("file_height")] string FileHeight,
[property: JsonPropertyName("file_orientation")] string FileOrientation,
[property: JsonPropertyName("file_orientation_src")] string FileOrientationSrc,
[property: JsonPropertyName("file_projection")] string FileProjection,
[property: JsonPropertyName("file_aspect_ratio")] string FileAspectRatio,
[property: JsonPropertyName("file_hdr")] string FileHdr,
[property: JsonPropertyName("file_watermark")] string FileWatermark,
[property: JsonPropertyName("file_color_profile")] string FileColorProfile,
[property: JsonPropertyName("file_main_color")] string FileMainColor,
[property: JsonPropertyName("file_colors")] string FileColors,
[property: JsonPropertyName("File_luminance")] string FileLuminance,
[property: JsonPropertyName("file_diff")] string FileDiff,
[property: JsonPropertyName("file_chroma")] string FileChroma,
[property: JsonPropertyName("file_software")] string FileSoftware,
[property: JsonPropertyName("file_error")] string FileError,
[property: JsonPropertyName("mod_time")] string ModTime,
[property: JsonPropertyName("created_at")] string CreatedAt,
[property: JsonPropertyName("created_in")] string CreatedIn,
[property: JsonPropertyName("updated_at")] string UpdatedAt,
[property: JsonPropertyName("updated_in")] string UpdatedIn,
[property: JsonPropertyName("published_at")] object PublishedAt,
[property: JsonPropertyName("deleted_at")] object DeletedAt)
{
internal static Shared.Models.DatabaseFile Map(DatabaseFile databaseFile)
{
Shared.Models.DatabaseFile result;
(int id, int photoId) = (int.Parse(databaseFile.Id), int.Parse(databaseFile.PhotoId));
(int fileWidth, int fileHeight) = (int.Parse(databaseFile.FileWidth), int.Parse(databaseFile.FileHeight));
result = new(id,
photoId,
databaseFile.PhotoUid,
databaseFile.PhotoTakenAt,
databaseFile.TimeIndex,
databaseFile.MediaId,
databaseFile.MediaUtc,
databaseFile.InstanceId,
databaseFile.FileUid,
databaseFile.FileName,
databaseFile.FileRoot,
databaseFile.OriginalName,
databaseFile.FileHash,
databaseFile.FileSize,
databaseFile.FileCodec,
databaseFile.FileType,
databaseFile.MediaType,
databaseFile.FileMime,
databaseFile.FilePrimary,
databaseFile.FileSidecar,
databaseFile.FileMissing,
databaseFile.FilePortrait,
databaseFile.FileVideo,
databaseFile.FileDuration,
databaseFile.FileFps,
databaseFile.FileFrames,
fileWidth,
fileHeight,
databaseFile.FileOrientation,
databaseFile.FileOrientationSrc,
databaseFile.FileProjection,
databaseFile.FileAspectRatio,
databaseFile.FileHdr,
databaseFile.FileWatermark,
databaseFile.FileColorProfile,
databaseFile.FileMainColor,
databaseFile.FileColors,
databaseFile.FileLuminance,
databaseFile.FileDiff,
databaseFile.FileChroma,
databaseFile.FileSoftware,
databaseFile.FileError,
databaseFile.ModTime,
databaseFile.CreatedAt,
databaseFile.CreatedIn,
databaseFile.UpdatedAt,
databaseFile.UpdatedIn,
databaseFile.PublishedAt,
databaseFile.DeletedAt);
return result;
}
}

View File

@ -0,0 +1,60 @@
using System.Text.Json.Serialization;
namespace View_by_Distance.PhotoPrism.Models;
public record Marker(
[property: JsonPropertyName("marker_uid")] string MarkerUid,
[property: JsonPropertyName("file_uid")] string FileUid,
[property: JsonPropertyName("marker_type")] string MarkerType,
[property: JsonPropertyName("marker_src")] string MarkerSrc,
[property: JsonPropertyName("marker_name")] string MarkerName,
[property: JsonPropertyName("marker_review")] string MarkerReview,
[property: JsonPropertyName("marker_invalid")] string MarkerInvalid,
[property: JsonPropertyName("subj_uid")] string SubjUid,
[property: JsonPropertyName("subj_src")] string SubjSrc,
[property: JsonPropertyName("face_id")] string FaceId,
[property: JsonPropertyName("face_dist")] string FaceDist,
[property: JsonPropertyName("x")] string X,
[property: JsonPropertyName("y")] string Y,
[property: JsonPropertyName("w")] string W,
[property: JsonPropertyName("h")] string H,
[property: JsonPropertyName("q")] string Q,
[property: JsonPropertyName("size")] string Size,
[property: JsonPropertyName("score")] string Score,
[property: JsonPropertyName("thumb")] string Thumb,
[property: JsonPropertyName("matched_at")] string MatchedAt,
[property: JsonPropertyName("created_at")] string CreatedAt,
[property: JsonPropertyName("updated_at")] string UpdatedAt)
{
internal static Shared.Models.Marker Map(Marker marker)
{
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));
result = new(
marker.MarkerUid,
marker.FileUid,
marker.MarkerType,
marker.MarkerSrc,
marker.MarkerName,
marker.MarkerReview,
marker.MarkerInvalid,
marker.SubjUid,
marker.SubjSrc,
marker.FaceId,
marker.FaceDist,
x,
y,
w,
h,
marker.Q,
marker.Size,
score,
marker.Thumb,
marker.MatchedAt,
marker.CreatedAt,
marker.UpdatedAt);
return result;
}
}

View File

@ -16,8 +16,17 @@ public class F_PhotoPrism
else
{
string json = File.ReadAllText(fileName);
JsonElement? jsonElement = JsonSerializer.Deserialize<JsonElement>(json);
results = jsonElement.Value.EnumerateObject().ToArray();
JsonElement[]? jsonElements = JsonSerializer.Deserialize<JsonElement[]>(json);
if (jsonElements is null || !jsonElements.Any())
results = Array.Empty<JsonProperty>();
else
{
JsonElement jsonElement = jsonElements.Last();
if (jsonElement.ValueKind != JsonValueKind.Object)
results = Array.Empty<JsonProperty>();
else
results = jsonElement.EnumerateObject().ToArray();
}
}
return results;
}
@ -30,13 +39,13 @@ public class F_PhotoPrism
if (!jsonProperties.Any())
results = null;
else
results = JsonSerializer.Deserialize<Marker[]>(jsonProperties[1].Value);
results = JsonSerializer.Deserialize<Marker[]>(jsonProperties.Last().Value);
return results;
}
private static Dictionary<string, List<Marker>> GetFileUIdToMarkers(string fPhotoPrismSingletonDirectory)
private static Dictionary<string, List<Shared.Models.Marker>> GetFileUIdToMarkers(string fPhotoPrismSingletonDirectory)
{
Dictionary<string, List<Marker>> results = new();
Dictionary<string, List<Shared.Models.Marker>> results = new();
Marker[]? markers = GetMarkers(fPhotoPrismSingletonDirectory);
if (markers is null)
throw new NullReferenceException(nameof(markers));
@ -44,34 +53,44 @@ public class F_PhotoPrism
{
if (!results.ContainsKey(marker.FileUid))
results.Add(marker.FileUid, new());
results[marker.FileUid].Add(marker);
results[marker.FileUid].Add(Marker.Map(marker));
}
return results;
}
private static DatabaseFile[]? GetDatabaseFiles(string fPhotoPrismSingletonDirectory)
private static List<Shared.Models.DatabaseFile>? GetDatabaseFiles(string fPhotoPrismSingletonDirectory)
{
DatabaseFile[]? results;
List<Shared.Models.DatabaseFile>? results;
string file = Path.Combine(fPhotoPrismSingletonDirectory, "files.json");
JsonProperty[] jsonProperties = GetJsonProperty(file);
if (!jsonProperties.Any())
results = null;
else
results = JsonSerializer.Deserialize<DatabaseFile[]>(jsonProperties[1].Value);
{
results = new();
DatabaseFile[]? databaseFiles = JsonSerializer.Deserialize<DatabaseFile[]>(jsonProperties.Last().Value);
if (databaseFiles is null)
results = null;
else
{
foreach (DatabaseFile databaseFile in databaseFiles)
results.Add(DatabaseFile.Map(databaseFile));
}
}
return results;
}
public static Dictionary<string, List<MappingFromPhotoPrism>> GetFileNameToCollection(string fPhotoPrismSingletonDirectory)
{
Dictionary<string, List<MappingFromPhotoPrism>> results = new();
List<Marker>? makers;
List<Shared.Models.Marker>? makers;
MappingFromPhotoPrism mappingFromPhotoPrism;
List<MappingFromPhotoPrism>? mappingFromPhotoPrismCollection;
DatabaseFile[]? databaseFiles = GetDatabaseFiles(fPhotoPrismSingletonDirectory);
List<Shared.Models.DatabaseFile>? databaseFiles = GetDatabaseFiles(fPhotoPrismSingletonDirectory);
if (databaseFiles is not null)
{
Dictionary<string, List<Marker>> fileUIdToMarkers = GetFileUIdToMarkers(fPhotoPrismSingletonDirectory);
foreach (DatabaseFile databaseFile in databaseFiles)
Dictionary<string, List<Shared.Models.Marker>> fileUIdToMarkers = GetFileUIdToMarkers(fPhotoPrismSingletonDirectory);
foreach (Shared.Models.DatabaseFile databaseFile in databaseFiles)
{
if (!results.TryGetValue(databaseFile.FileName, out mappingFromPhotoPrismCollection))
{
@ -104,8 +123,8 @@ public class F_PhotoPrism
System.Drawing.Rectangle? prismRectangle;
System.Drawing.Rectangle intersectRectangle;
Dictionary<int, PersonContainer[]>? normalizedRectangleToPersonContainers;
(MappingFromPhotoPrism MappingFromPhotoPrism, Marker Marker, double Percent)[] sortedCollection;
List<(MappingFromPhotoPrism MappingFromPhotoPrism, Marker Marker, double Percent)> collection = new();
(MappingFromPhotoPrism MappingFromPhotoPrism, Shared.Models.Marker Marker, double Percent)[] sortedCollection;
List<(MappingFromPhotoPrism MappingFromPhotoPrism, Shared.Models.Marker Marker, double Percent)> collection = new();
foreach (Face face in distinctFilteredFaces)
{
collection.Clear();
@ -122,7 +141,7 @@ public class F_PhotoPrism
dlibRectangle = new(face.Location.Left, face.Location.Top, face.Location.Right - face.Location.Left, face.Location.Bottom - face.Location.Top);
foreach (MappingFromPhotoPrism mappingFromPhotoPrism in face.Mapping.MappingFromPhotoPrismCollection)
{
foreach (Marker marker in mappingFromPhotoPrism.Markers)
foreach (Shared.Models.Marker marker in mappingFromPhotoPrism.Markers)
{
prismRectangle = ILocation.GetRectangle(face.OutputResolution, mappingFromPhotoPrism.DatabaseFile, marker);
if (prismRectangle is null)
@ -139,7 +158,7 @@ public class F_PhotoPrism
if (!collection.Any())
continue;
sortedCollection = collection.OrderByDescending(l => l.Percent).ToArray();
foreach ((MappingFromPhotoPrism mappingFromPhotoPrism, Marker marker, double percent) in sortedCollection)
foreach ((MappingFromPhotoPrism mappingFromPhotoPrism, Shared.Models.Marker marker, double percent) in sortedCollection)
{
foreach (PersonContainer personContainer in personContainers)
{

View File

@ -1,54 +1,52 @@
using System.Text.Json.Serialization;
namespace View_by_Distance.Shared.Models;
public record DatabaseFile(
[property: JsonPropertyName("id")] int Id,
[property: JsonPropertyName("photo_id")] int PhotoId,
[property: JsonPropertyName("photo_uid")] string PhotoUid,
[property: JsonPropertyName("photo_taken_at")] string PhotoTakenAt,
[property: JsonPropertyName("time_index")] string TimeIndex,
[property: JsonPropertyName("media_id")] string MediaId,
[property: JsonPropertyName("media_utc")] object MediaUtc,
[property: JsonPropertyName("instance_id")] string InstanceId,
[property: JsonPropertyName("file_uid")] string FileUid,
[property: JsonPropertyName("file_name")] string FileName,
[property: JsonPropertyName("file_root")] string FileRoot,
[property: JsonPropertyName("original_name")] string OriginalName,
[property: JsonPropertyName("file_hash")] string FileHash,
[property: JsonPropertyName("file_size")] int FileSize,
[property: JsonPropertyName("file_codec")] string FileCodec,
[property: JsonPropertyName("file_type")] string FileType,
[property: JsonPropertyName("media_type")] string MediaType,
[property: JsonPropertyName("file_mime")] string FileMime,
[property: JsonPropertyName("file_primary")] long FilePrimary,
[property: JsonPropertyName("file_sidecar")] long FileSidecar,
[property: JsonPropertyName("file_missing")] long FileMissing,
[property: JsonPropertyName("file_portrait")] long FilePortrait,
[property: JsonPropertyName("file_video")] long FileVideo,
[property: JsonPropertyName("file_duration")] long FileDuration,
[property: JsonPropertyName("file_fps")] object FileFps,
[property: JsonPropertyName("file_frames")] object FileFrames,
[property: JsonPropertyName("file_width")] int FileWidth,
[property: JsonPropertyName("file_height")] int FileHeight,
[property: JsonPropertyName("file_orientation")] int FileOrientation,
[property: JsonPropertyName("file_projection")] string FileProjection,
[property: JsonPropertyName("file_aspect_ratio")] double FileAspectRatio,
[property: JsonPropertyName("file_hdr")] long FileHdr,
[property: JsonPropertyName("file_watermark")] long FileWatermark,
[property: JsonPropertyName("file_color_profile")] string FileColorProfile,
[property: JsonPropertyName("file_main_color")] string FileMainColor,
[property: JsonPropertyName("file_colors")] string FileColors,
[property: JsonPropertyName("file_luminance")] string FileLuminance,
[property: JsonPropertyName("file_diff")] long FileDiff,
[property: JsonPropertyName("file_chroma")] long FileChroma,
[property: JsonPropertyName("file_software")] string FileSoftware,
[property: JsonPropertyName("file_error")] string FileError,
[property: JsonPropertyName("mod_time")] long ModTime,
[property: JsonPropertyName("created_at")] string CreatedAt,
[property: JsonPropertyName("created_in")] long CreatedIn,
[property: JsonPropertyName("updated_at")] string UpdatedAt,
[property: JsonPropertyName("updated_in")] long UpdatedIn,
[property: JsonPropertyName("published_at")] object PublishedAt,
[property: JsonPropertyName("deleted_at")] object DeletedAt
);
int Id,
int PhotoId,
string PhotoUid,
string PhotoTakenAt,
string TimeIndex,
string MediaId,
string MediaUtc,
string InstanceId,
string FileUid,
string FileName,
string FileRoot,
string OriginalName,
string FileHash,
string FileSize,
string FileCodec,
string FileType,
string MediaType,
string FileMime,
string FilePrimary,
string FileSidecar,
string FileMissing,
string FilePortrait,
string FileVideo,
string FileDuration,
string FileFps,
string FileFrames,
int FileWidth,
int FileHeight,
string FileOrientation,
string FileOrientationSrc,
string FileProjection,
string FileAspectRatio,
string FileHdr,
string FileWatermark,
string FileColorProfile,
string FileMainColor,
string FileColors,
string FileLuminance,
string FileDiff,
string FileChroma,
string FileSoftware,
string FileError,
string ModTime,
string CreatedAt,
string CreatedIn,
string UpdatedAt,
string UpdatedIn,
object PublishedAt,
object DeletedAt);

View File

@ -1,28 +1,25 @@
using System.Text.Json.Serialization;
namespace View_by_Distance.Shared.Models;
namespace View_by_Distance.Shared.Models;
public record Marker(
[property: JsonPropertyName("marker_uid")] string MarkerUid,
[property: JsonPropertyName("file_uid")] string FileUid,
[property: JsonPropertyName("marker_type")] string MarkerType,
[property: JsonPropertyName("marker_src")] string MarkerSrc,
[property: JsonPropertyName("marker_name")] string MarkerName,
[property: JsonPropertyName("marker_review")] int MarkerReview,
[property: JsonPropertyName("marker_invalid")] int MarkerInvalid,
[property: JsonPropertyName("subj_uid")] string SubjUid,
[property: JsonPropertyName("subj_src")] string SubjSrc,
[property: JsonPropertyName("face_id")] string FaceId,
[property: JsonPropertyName("face_dist")] double FaceDist,
[property: JsonPropertyName("x")] double X,
[property: JsonPropertyName("y")] double Y,
[property: JsonPropertyName("w")] double W,
[property: JsonPropertyName("h")] double H,
[property: JsonPropertyName("q")] int Q,
[property: JsonPropertyName("size")] int Size,
[property: JsonPropertyName("score")] int Score,
[property: JsonPropertyName("thumb")] string Thumb,
[property: JsonPropertyName("matched_at")] string MatchedAt,
[property: JsonPropertyName("created_at")] string CreatedAt,
[property: JsonPropertyName("updated_at")] string UpdatedAt
);
string MarkerUid,
string FileUid,
string MarkerType,
string MarkerSrc,
string MarkerName,
string MarkerReview,
string MarkerInvalid,
string SubjUid,
string SubjSrc,
string FaceId,
string FaceDist,
double X,
double Y,
double W,
double H,
string Q,
string Size,
double Score,
string Thumb,
string MatchedAt,
string CreatedAt,
string UpdatedAt);