RelativePropertyCollectionFile
aMetadataCollectionDirectory Work with video FilePath.IsIgnore Removed IId IsIgnore Keywords RootAmazon SaveAmazon PhysicalFileProvider Message Bump HarFilesDirectory
This commit is contained in:
parent
684ba1f0df
commit
d1557e1d85
2
.gitignore
vendored
2
.gitignore
vendored
@ -468,3 +468,5 @@ globalStorage/
|
|||||||
[Ll]ib/
|
[Ll]ib/
|
||||||
|
|
||||||
Shared/.kanbn
|
Shared/.kanbn
|
||||||
|
|
||||||
|
.vscode/Har-Files
|
0
.vscode/.yml
vendored
Normal file
0
.vscode/.yml
vendored
Normal file
@ -34,8 +34,8 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="MetadataExtractor" Version="2.8.1" />
|
<PackageReference Include="MetadataExtractor" Version="2.8.1" />
|
||||||
<PackageReference Include="System.Text.Json" Version="7.0.3" />
|
<PackageReference Include="System.Text.Json" Version="8.0.3" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Shared\AA.Shared.csproj" />
|
<ProjectReference Include="..\Shared\AA.Shared.csproj" />
|
||||||
|
@ -16,13 +16,13 @@ public class A_Metadata
|
|||||||
public A_Metadata(MetadataConfiguration metadataConfiguration)
|
public A_Metadata(MetadataConfiguration metadataConfiguration)
|
||||||
{
|
{
|
||||||
_MetadataConfiguration = metadataConfiguration;
|
_MetadataConfiguration = metadataConfiguration;
|
||||||
string bResultsFullGroupDirectory = IResult.GetResultsFullGroupDirectory(metadataConfiguration.ResultConfiguration,
|
string aResultsFullGroupDirectory = IResult.GetResultsFullGroupDirectory(metadataConfiguration.ResultConfiguration,
|
||||||
nameof(A_Metadata),
|
nameof(A_Metadata),
|
||||||
string.Empty,
|
string.Empty,
|
||||||
includeResizeGroup: false,
|
includeResizeGroup: false,
|
||||||
includeModel: false,
|
includeModel: false,
|
||||||
includePredictorModel: false);
|
includePredictorModel: false);
|
||||||
_FileGroups = IPath.GetKeyValuePairs(metadataConfiguration.ResultConfiguration, bResultsFullGroupDirectory, [metadataConfiguration.ResultConfiguration.ResultSingleton]);
|
_FileGroups = IPath.GetKeyValuePairs(metadataConfiguration.ResultConfiguration, aResultsFullGroupDirectory, [metadataConfiguration.ResultConfiguration.ResultSingleton]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private (int, FileInfo) GetFileInfo(ResultConfiguration resultConfiguration, FilePath filePath)
|
private (int, FileInfo) GetFileInfo(ResultConfiguration resultConfiguration, FilePath filePath)
|
||||||
@ -132,7 +132,7 @@ public class A_Metadata
|
|||||||
return (fileInfo, result);
|
return (fileInfo, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Action<string> SetExifDirectoryCollection(IRename rename, IRenameConfiguration renameConfiguration, A_Metadata metadata, List<(string, FileInfo, ExifDirectory)> exifDirectories)
|
public static Action<string> SetExifDirectoryCollection(IRename rename, IRenameConfiguration renameConfiguration, A_Metadata metadata, List<(FilePath, FileInfo, ExifDirectory)> exifDirectories)
|
||||||
{
|
{
|
||||||
return file =>
|
return file =>
|
||||||
{
|
{
|
||||||
@ -141,21 +141,31 @@ public class A_Metadata
|
|||||||
FilePath? ffmpegFilePath;
|
FilePath? ffmpegFilePath;
|
||||||
ExifDirectory exifDirectory;
|
ExifDirectory exifDirectory;
|
||||||
FileHolder fileHolder = new(file);
|
FileHolder fileHolder = new(file);
|
||||||
ReadOnlyCollection<string> ffmpegFiles;
|
ReadOnlyCollection<string>? ffmpegFiles;
|
||||||
DeterministicHashCode deterministicHashCode;
|
DeterministicHashCode deterministicHashCode;
|
||||||
FilePath filePath = FilePath.Get(renameConfiguration.MetadataConfiguration, fileHolder, index: null);
|
FilePath filePath = FilePath.Get(renameConfiguration.MetadataConfiguration, fileHolder, index: null);
|
||||||
if (!renameConfiguration.SkipIdFiles || filePath.Id is null || !filePath.IsIntelligentIdFormat && filePath.SortOrder is not null)
|
if (!renameConfiguration.SkipIdFiles || filePath.Id is null || !filePath.IsIntelligentIdFormat && filePath.SortOrder is not null)
|
||||||
{
|
{
|
||||||
(ffmpegFiles, ffmpegFilePath) = rename.ConvertAndGetFfmpegFiles(renameConfiguration, filePath);
|
if (filePath.Id is not null)
|
||||||
if (ffmpegFilePath is not null)
|
{
|
||||||
filePath = ffmpegFilePath;
|
ffmpegFiles = null;
|
||||||
deterministicHashCode = filePath.Id is not null ? deterministicHashCode = new(null, filePath.Id, null) : deterministicHashCode = rename.GetDeterministicHashCode(filePath);
|
deterministicHashCode = new(null, filePath.Id, null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ffmpegFiles = rename.ConvertAndGetFfmpegFiles(renameConfiguration, filePath);
|
||||||
|
ffmpegFilePath = ffmpegFiles.Count == 0 ? null : FilePath.Get(renameConfiguration.MetadataConfiguration, new(ffmpegFiles[0]), index: null);
|
||||||
|
deterministicHashCode = ffmpegFilePath is null ? rename.GetDeterministicHashCode(filePath) : rename.GetDeterministicHashCode(ffmpegFilePath);
|
||||||
|
}
|
||||||
(fileInfo, exifDirectory) = metadata.GetMetadataCollection(renameConfiguration.MetadataConfiguration, filePath, deterministicHashCode);
|
(fileInfo, exifDirectory) = metadata.GetMetadataCollection(renameConfiguration.MetadataConfiguration, filePath, deterministicHashCode);
|
||||||
lock (exifDirectories)
|
lock (exifDirectories)
|
||||||
exifDirectories.Add(new(file, fileInfo, exifDirectory));
|
exifDirectories.Add(new(filePath, fileInfo, exifDirectory));
|
||||||
|
if (ffmpegFiles is not null)
|
||||||
|
{
|
||||||
foreach (string ffmpegFile in ffmpegFiles)
|
foreach (string ffmpegFile in ffmpegFiles)
|
||||||
File.Delete(ffmpegFile);
|
File.Delete(ffmpegFile);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -23,17 +23,16 @@ public class MetadataConfiguration
|
|||||||
{
|
{
|
||||||
if (configuration?.ForceMetadataLastWriteTimeToCreationTime is null)
|
if (configuration?.ForceMetadataLastWriteTimeToCreationTime is null)
|
||||||
{
|
{
|
||||||
|
List<string> paths = [];
|
||||||
foreach (IConfigurationProvider configurationProvider in configurationRoot.Providers)
|
foreach (IConfigurationProvider configurationProvider in configurationRoot.Providers)
|
||||||
{
|
{
|
||||||
if (configurationProvider is not Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider jsonConfigurationProvider)
|
if (configurationProvider is not Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider jsonConfigurationProvider)
|
||||||
continue;
|
continue;
|
||||||
if (jsonConfigurationProvider.Source.FileProvider is not Microsoft.Extensions.FileProviders.PhysicalFileProvider physicalFileProvider)
|
if (jsonConfigurationProvider.Source.FileProvider is not Microsoft.Extensions.FileProviders.PhysicalFileProvider physicalFileProvider)
|
||||||
continue;
|
continue;
|
||||||
if (!physicalFileProvider.Root.Contains("UserSecrets"))
|
paths.Add(physicalFileProvider.Root);
|
||||||
continue;
|
|
||||||
throw new NotSupportedException(physicalFileProvider.Root);
|
|
||||||
}
|
}
|
||||||
throw new NotSupportedException("Not Found!");
|
throw new NotSupportedException($"Not found!{Environment.NewLine}{string.Join(Environment.NewLine, paths.Distinct())}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,17 +29,16 @@ public class ResultConfiguration
|
|||||||
{
|
{
|
||||||
if (configuration?.DateGroup is null)
|
if (configuration?.DateGroup is null)
|
||||||
{
|
{
|
||||||
|
List<string> paths = [];
|
||||||
foreach (IConfigurationProvider configurationProvider in configurationRoot.Providers)
|
foreach (IConfigurationProvider configurationProvider in configurationRoot.Providers)
|
||||||
{
|
{
|
||||||
if (configurationProvider is not Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider jsonConfigurationProvider)
|
if (configurationProvider is not Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider jsonConfigurationProvider)
|
||||||
continue;
|
continue;
|
||||||
if (jsonConfigurationProvider.Source.FileProvider is not Microsoft.Extensions.FileProviders.PhysicalFileProvider physicalFileProvider)
|
if (jsonConfigurationProvider.Source.FileProvider is not Microsoft.Extensions.FileProviders.PhysicalFileProvider physicalFileProvider)
|
||||||
continue;
|
continue;
|
||||||
if (!physicalFileProvider.Root.Contains("UserSecrets"))
|
paths.Add(physicalFileProvider.Root);
|
||||||
continue;
|
|
||||||
throw new NotSupportedException(physicalFileProvider.Root);
|
|
||||||
}
|
}
|
||||||
throw new NotSupportedException("Not Found!");
|
throw new NotSupportedException($"Not found!{Environment.NewLine}{string.Join(Environment.NewLine, paths.Distinct())}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using System.Collections.ObjectModel;
|
||||||
using View_by_Distance.Shared.Models;
|
using View_by_Distance.Shared.Models;
|
||||||
|
|
||||||
namespace View_by_Distance.Metadata.Models.Stateless.Methods;
|
namespace View_by_Distance.Metadata.Models.Stateless.Methods;
|
||||||
@ -5,7 +6,7 @@ namespace View_by_Distance.Metadata.Models.Stateless.Methods;
|
|||||||
internal static class Base
|
internal static class Base
|
||||||
{
|
{
|
||||||
|
|
||||||
internal static string GetMaker(ExifDirectoryBase[]? exifBaseDirectories)
|
internal static string? GetMaker(ExifDirectoryBase[]? exifBaseDirectories)
|
||||||
{
|
{
|
||||||
string? result = null;
|
string? result = null;
|
||||||
if (exifBaseDirectories is not null)
|
if (exifBaseDirectories is not null)
|
||||||
@ -23,12 +24,10 @@ internal static class Base
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(result))
|
|
||||||
result = "Unknown";
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static string GetModel(ExifDirectoryBase[]? exifBaseDirectories)
|
internal static string? GetModel(ExifDirectoryBase[]? exifBaseDirectories)
|
||||||
{
|
{
|
||||||
string? result = null;
|
string? result = null;
|
||||||
if (exifBaseDirectories is not null)
|
if (exifBaseDirectories is not null)
|
||||||
@ -46,9 +45,24 @@ internal static class Base
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(result))
|
|
||||||
result = "Unknown";
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static ReadOnlyCollection<string> GetKeywords(ExifDirectoryBase[]? exifBaseDirectories)
|
||||||
|
{
|
||||||
|
List<string> results = [];
|
||||||
|
if (exifBaseDirectories is not null)
|
||||||
|
{
|
||||||
|
string value;
|
||||||
|
foreach (ExifDirectoryBase exifDirectoryBase in exifBaseDirectories)
|
||||||
|
{
|
||||||
|
value = exifDirectoryBase?.WinKeywords is null ? string.Empty : exifDirectoryBase.WinKeywords.ToString().Trim();
|
||||||
|
if (string.IsNullOrEmpty(value))
|
||||||
|
continue;
|
||||||
|
results.Add(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new(results);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using MetadataExtractor;
|
using MetadataExtractor;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
using View_by_Distance.Shared.Models;
|
using View_by_Distance.Shared.Models;
|
||||||
|
|
||||||
namespace View_by_Distance.Metadata.Models.Stateless.Methods;
|
namespace View_by_Distance.Metadata.Models.Stateless.Methods;
|
||||||
@ -19,16 +20,21 @@ public interface IMetadata
|
|||||||
static ExifDirectory GetExifDirectory(FilePath filePath, DeterministicHashCode deterministicHashCode) =>
|
static ExifDirectory GetExifDirectory(FilePath filePath, DeterministicHashCode deterministicHashCode) =>
|
||||||
Exif.GetExifDirectory(filePath, deterministicHashCode);
|
Exif.GetExifDirectory(filePath, deterministicHashCode);
|
||||||
|
|
||||||
string TestStatic_GetMaker(ExifDirectory? exifDirectory) =>
|
string? TestStatic_GetMaker(ExifDirectory? exifDirectory) =>
|
||||||
GetMaker(exifDirectory);
|
GetMaker(exifDirectory);
|
||||||
static string GetMaker(ExifDirectory? exifDirectory) =>
|
static string? GetMaker(ExifDirectory? exifDirectory) =>
|
||||||
Base.GetMaker(exifDirectory?.ExifBaseDirectories);
|
Base.GetMaker(exifDirectory?.ExifBaseDirectories);
|
||||||
|
|
||||||
string TestStatic_GetModel(ExifDirectory? exifDirectory) =>
|
string? TestStatic_GetModel(ExifDirectory? exifDirectory) =>
|
||||||
GetModel(exifDirectory);
|
GetModel(exifDirectory);
|
||||||
static string GetModel(ExifDirectory? exifDirectory) =>
|
static string? GetModel(ExifDirectory? exifDirectory) =>
|
||||||
Base.GetModel(exifDirectory?.ExifBaseDirectories);
|
Base.GetModel(exifDirectory?.ExifBaseDirectories);
|
||||||
|
|
||||||
|
ReadOnlyCollection<string> TestStatic_GetKeywords(ExifDirectory? exifDirectory) =>
|
||||||
|
GetKeywords(exifDirectory);
|
||||||
|
static ReadOnlyCollection<string> GetKeywords(ExifDirectory? exifDirectory) =>
|
||||||
|
Base.GetKeywords(exifDirectory?.ExifBaseDirectories);
|
||||||
|
|
||||||
string? TestStatic_GetOutputResolution(ExifDirectory? exifDirectory) =>
|
string? TestStatic_GetOutputResolution(ExifDirectory? exifDirectory) =>
|
||||||
GetOutputResolution(exifDirectory);
|
GetOutputResolution(exifDirectory);
|
||||||
static string? GetOutputResolution(ExifDirectory? exifDirectory) =>
|
static string? GetOutputResolution(ExifDirectory? exifDirectory) =>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
@ -34,11 +34,11 @@
|
|||||||
<SupportedPlatform Include="browser" />
|
<SupportedPlatform Include="browser" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CliWrap" Version="3.6.4" />
|
<PackageReference Include="CliWrap" Version="3.6.6" />
|
||||||
<PackageReference Include="runtime.win-x64.Microsoft.DotNet.ILCompiler" Version="8.0.0-rc.2.23479.6" />
|
<PackageReference Include="runtime.win-x64.Microsoft.DotNet.ILCompiler" Version="8.0.4" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
||||||
<PackageReference Include="ShellProgressBar" Version="5.2.0" />
|
<PackageReference Include="ShellProgressBar" Version="5.2.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -4,6 +4,7 @@ using System.Text.Json.Serialization;
|
|||||||
namespace View_by_Distance.Rename.Models;
|
namespace View_by_Distance.Rename.Models;
|
||||||
|
|
||||||
public record AppSettings(string Company,
|
public record AppSettings(string Company,
|
||||||
|
string? HarFilesDirectory,
|
||||||
int MaxDegreeOfParallelism,
|
int MaxDegreeOfParallelism,
|
||||||
bool RequireRootDirectoryExists)
|
bool RequireRootDirectoryExists)
|
||||||
{
|
{
|
||||||
|
@ -8,6 +8,7 @@ public class AppSettings
|
|||||||
{
|
{
|
||||||
|
|
||||||
public string? Company { get; set; }
|
public string? Company { get; set; }
|
||||||
|
public string? HarFilesDirectory { get; set; }
|
||||||
public int? MaxDegreeOfParallelism { get; set; }
|
public int? MaxDegreeOfParallelism { get; set; }
|
||||||
public bool? RequireRootDirectoryExists { get; set; }
|
public bool? RequireRootDirectoryExists { get; set; }
|
||||||
|
|
||||||
@ -21,17 +22,16 @@ public class AppSettings
|
|||||||
{
|
{
|
||||||
if (appSettings?.Company is null)
|
if (appSettings?.Company is null)
|
||||||
{
|
{
|
||||||
|
List<string> paths = [];
|
||||||
foreach (IConfigurationProvider configurationProvider in configurationRoot.Providers)
|
foreach (IConfigurationProvider configurationProvider in configurationRoot.Providers)
|
||||||
{
|
{
|
||||||
if (configurationProvider is not Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider jsonConfigurationProvider)
|
if (configurationProvider is not Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider jsonConfigurationProvider)
|
||||||
continue;
|
continue;
|
||||||
if (jsonConfigurationProvider.Source.FileProvider is not Microsoft.Extensions.FileProviders.PhysicalFileProvider physicalFileProvider)
|
if (jsonConfigurationProvider.Source.FileProvider is not Microsoft.Extensions.FileProviders.PhysicalFileProvider physicalFileProvider)
|
||||||
continue;
|
continue;
|
||||||
if (!physicalFileProvider.Root.Contains("UserSecrets"))
|
paths.Add(physicalFileProvider.Root);
|
||||||
continue;
|
|
||||||
throw new NotSupportedException(physicalFileProvider.Root);
|
|
||||||
}
|
}
|
||||||
throw new NotSupportedException("Not Found!");
|
throw new NotSupportedException($"Not found!{Environment.NewLine}{string.Join(Environment.NewLine, paths.Distinct())}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,6 +48,7 @@ public class AppSettings
|
|||||||
if (appSettings.RequireRootDirectoryExists is null) throw new NullReferenceException(nameof(appSettings.RequireRootDirectoryExists));
|
if (appSettings.RequireRootDirectoryExists is null) throw new NullReferenceException(nameof(appSettings.RequireRootDirectoryExists));
|
||||||
Verify(appSettings);
|
Verify(appSettings);
|
||||||
result = new(appSettings.Company,
|
result = new(appSettings.Company,
|
||||||
|
appSettings.HarFilesDirectory,
|
||||||
appSettings.MaxDegreeOfParallelism.Value,
|
appSettings.MaxDegreeOfParallelism.Value,
|
||||||
appSettings.RequireRootDirectoryExists.Value);
|
appSettings.RequireRootDirectoryExists.Value);
|
||||||
return result;
|
return result;
|
||||||
|
@ -7,8 +7,10 @@ namespace View_by_Distance.Rename.Models.Binder;
|
|||||||
public class RenameConfiguration
|
public class RenameConfiguration
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public string? DefaultMaker { get; set; }
|
||||||
|
public bool? ForceNewId { get; set; }
|
||||||
public string[]? IgnoreExtensions { get; set; }
|
public string[]? IgnoreExtensions { get; set; }
|
||||||
public bool? MoveFilesToRoot { get; set; }
|
public string? RelativePropertyCollectionFile { get; set; }
|
||||||
public bool? SkipIdFiles { get; set; }
|
public bool? SkipIdFiles { get; set; }
|
||||||
public string[]? ValidImageFormatExtensions { get; set; }
|
public string[]? ValidImageFormatExtensions { get; set; }
|
||||||
public string[]? ValidVideoFormatExtensions { get; set; }
|
public string[]? ValidVideoFormatExtensions { get; set; }
|
||||||
@ -21,19 +23,18 @@ public class RenameConfiguration
|
|||||||
|
|
||||||
private static void PreVerify(IConfigurationRoot configurationRoot, RenameConfiguration? configuration)
|
private static void PreVerify(IConfigurationRoot configurationRoot, RenameConfiguration? configuration)
|
||||||
{
|
{
|
||||||
if (configuration?.IgnoreExtensions is null)
|
if (configuration?.DefaultMaker is null)
|
||||||
{
|
{
|
||||||
|
List<string> paths = [];
|
||||||
foreach (IConfigurationProvider configurationProvider in configurationRoot.Providers)
|
foreach (IConfigurationProvider configurationProvider in configurationRoot.Providers)
|
||||||
{
|
{
|
||||||
if (configurationProvider is not Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider jsonConfigurationProvider)
|
if (configurationProvider is not Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider jsonConfigurationProvider)
|
||||||
continue;
|
continue;
|
||||||
if (jsonConfigurationProvider.Source.FileProvider is not Microsoft.Extensions.FileProviders.PhysicalFileProvider physicalFileProvider)
|
if (jsonConfigurationProvider.Source.FileProvider is not Microsoft.Extensions.FileProviders.PhysicalFileProvider physicalFileProvider)
|
||||||
continue;
|
continue;
|
||||||
if (!physicalFileProvider.Root.Contains("UserSecrets"))
|
paths.Add(physicalFileProvider.Root);
|
||||||
continue;
|
|
||||||
throw new NotSupportedException(physicalFileProvider.Root);
|
|
||||||
}
|
}
|
||||||
throw new NotSupportedException("Not Found!");
|
throw new NotSupportedException($"Not found!{Environment.NewLine}{string.Join(Environment.NewLine, paths.Distinct())}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,15 +49,19 @@ public class RenameConfiguration
|
|||||||
{
|
{
|
||||||
Models.RenameConfiguration result;
|
Models.RenameConfiguration result;
|
||||||
if (configuration is null) throw new NullReferenceException(nameof(configuration));
|
if (configuration is null) throw new NullReferenceException(nameof(configuration));
|
||||||
|
if (configuration.DefaultMaker is null) throw new NullReferenceException(nameof(configuration.DefaultMaker));
|
||||||
|
if (configuration.ForceNewId is null) throw new NullReferenceException(nameof(configuration.ForceNewId));
|
||||||
if (configuration.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
if (configuration.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
||||||
if (configuration.MoveFilesToRoot is null) throw new NullReferenceException(nameof(configuration.MoveFilesToRoot));
|
if (configuration.RelativePropertyCollectionFile is null) throw new NullReferenceException(nameof(configuration.RelativePropertyCollectionFile));
|
||||||
if (configuration.SkipIdFiles is null) throw new NullReferenceException(nameof(configuration.SkipIdFiles));
|
if (configuration.SkipIdFiles is null) throw new NullReferenceException(nameof(configuration.SkipIdFiles));
|
||||||
if (configuration.ValidImageFormatExtensions is null) throw new NullReferenceException(nameof(configuration.ValidImageFormatExtensions));
|
if (configuration.ValidImageFormatExtensions is null) throw new NullReferenceException(nameof(configuration.ValidImageFormatExtensions));
|
||||||
if (configuration.ValidVideoFormatExtensions is null) throw new NullReferenceException(nameof(configuration.ValidVideoFormatExtensions));
|
if (configuration.ValidVideoFormatExtensions is null) throw new NullReferenceException(nameof(configuration.ValidVideoFormatExtensions));
|
||||||
Verify(configuration);
|
Verify(configuration);
|
||||||
result = new(metadataConfiguration,
|
result = new(metadataConfiguration,
|
||||||
|
configuration.DefaultMaker,
|
||||||
|
configuration.ForceNewId.Value,
|
||||||
configuration.IgnoreExtensions,
|
configuration.IgnoreExtensions,
|
||||||
configuration.MoveFilesToRoot.Value,
|
configuration.RelativePropertyCollectionFile,
|
||||||
configuration.SkipIdFiles.Value,
|
configuration.SkipIdFiles.Value,
|
||||||
configuration.ValidImageFormatExtensions,
|
configuration.ValidImageFormatExtensions,
|
||||||
configuration.ValidVideoFormatExtensions);
|
configuration.ValidVideoFormatExtensions);
|
||||||
|
27
Rename/Models/Identifier.cs
Normal file
27
Rename/Models/Identifier.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace View_by_Distance.Rename.Models;
|
||||||
|
|
||||||
|
internal record Identifier(int Id, string PaddedId)
|
||||||
|
{
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
string result = JsonSerializer.Serialize(this, IdentifierSourceGenerationContext.Default.Identifier);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(Identifier))]
|
||||||
|
internal partial class IdentifierSourceGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(Identifier[]))]
|
||||||
|
internal partial class IdentifierCollectionSourceGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
@ -5,8 +5,10 @@ using System.Text.Json.Serialization;
|
|||||||
namespace View_by_Distance.Rename.Models;
|
namespace View_by_Distance.Rename.Models;
|
||||||
|
|
||||||
public record RenameConfiguration(Shared.Models.MetadataConfiguration MetadataConfiguration,
|
public record RenameConfiguration(Shared.Models.MetadataConfiguration MetadataConfiguration,
|
||||||
|
string DefaultMaker,
|
||||||
|
bool ForceNewId,
|
||||||
string[] IgnoreExtensions,
|
string[] IgnoreExtensions,
|
||||||
bool MoveFilesToRoot,
|
string RelativePropertyCollectionFile,
|
||||||
bool SkipIdFiles,
|
bool SkipIdFiles,
|
||||||
string[] ValidImageFormatExtensions,
|
string[] ValidImageFormatExtensions,
|
||||||
string[] ValidVideoFormatExtensions) : Shared.Models.Properties.IRenameConfiguration
|
string[] ValidVideoFormatExtensions) : Shared.Models.Properties.IRenameConfiguration
|
||||||
|
306
Rename/Rename.cs
306
Rename/Rename.cs
@ -3,9 +3,11 @@ using Microsoft.Extensions.Configuration;
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using ShellProgressBar;
|
using ShellProgressBar;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Data;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text.Json;
|
||||||
using View_by_Distance.Metadata.Models;
|
using View_by_Distance.Metadata.Models;
|
||||||
using View_by_Distance.Metadata.Models.Stateless.Methods;
|
using View_by_Distance.Metadata.Models.Stateless.Methods;
|
||||||
using View_by_Distance.Rename.Models;
|
using View_by_Distance.Rename.Models;
|
||||||
@ -15,11 +17,11 @@ using View_by_Distance.Shared.Models.Stateless.Methods;
|
|||||||
|
|
||||||
namespace View_by_Distance.Rename;
|
namespace View_by_Distance.Rename;
|
||||||
|
|
||||||
public class Rename : IRename
|
public partial class Rename : IRename
|
||||||
{
|
{
|
||||||
|
|
||||||
private record ToDo(string? Directory, FileHolder FileHolder, string File, bool JsonFile);
|
private record ToDo(string? Directory, FilePath FilePath, string File, bool JsonFile);
|
||||||
private record Record(DateTime DateTime, ExifDirectory ExifDirectory, string File, string JsonFile);
|
private record Record(DateTime DateTime, ExifDirectory ExifDirectory, FilePath FilePath, bool HasDateTimeOriginal, bool HasIgnoreKeyword, string JsonFile);
|
||||||
|
|
||||||
private ProgressBar? _ProgressBar;
|
private ProgressBar? _ProgressBar;
|
||||||
|
|
||||||
@ -42,35 +44,37 @@ public class Rename : IRename
|
|||||||
void IRename.Tick() =>
|
void IRename.Tick() =>
|
||||||
_ProgressBar?.Tick();
|
_ProgressBar?.Tick();
|
||||||
|
|
||||||
(ReadOnlyCollection<string>, FilePath?) IRename.ConvertAndGetFfmpegFiles(IRenameConfiguration renameConfiguration, FilePath filePath)
|
ReadOnlyCollection<string> IRename.ConvertAndGetFfmpegFiles(IRenameConfiguration renameConfiguration, FilePath filePath)
|
||||||
{
|
{
|
||||||
List<string> results = [];
|
List<string> results = [];
|
||||||
FilePath? result;
|
|
||||||
bool isValidVideoFormatExtensions = renameConfiguration.ValidVideoFormatExtensions.Contains(filePath.ExtensionLowered);
|
bool isValidVideoFormatExtensions = renameConfiguration.ValidVideoFormatExtensions.Contains(filePath.ExtensionLowered);
|
||||||
if (!isValidVideoFormatExtensions)
|
if (isValidVideoFormatExtensions)
|
||||||
result = null;
|
{
|
||||||
else
|
bool check;
|
||||||
|
try
|
||||||
{
|
{
|
||||||
CommandTask<CommandResult> commandTask = Cli.Wrap("ffmpeg.exe")
|
CommandTask<CommandResult> commandTask = Cli.Wrap("ffmpeg.exe")
|
||||||
.WithArguments(new[] { "-i", filePath.FullName, "-vf", "select=eq(n\\,0)", "-q:v", "1", $"{filePath.Name}-%4d.jpg" })
|
.WithArguments(new[] { "-i", filePath.FullName, "-vf", "select=eq(n\\,0)", "-q:v", "1", $"{filePath.Name}-%4d.jpg" })
|
||||||
.WithWorkingDirectory(filePath.DirectoryName)
|
.WithWorkingDirectory(filePath.DirectoryName)
|
||||||
.ExecuteAsync();
|
.ExecuteAsync();
|
||||||
commandTask.Task.Wait();
|
commandTask.Task.Wait();
|
||||||
|
check = true;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
check = false;
|
||||||
|
}
|
||||||
|
if (check)
|
||||||
|
{
|
||||||
results.AddRange(Directory.GetFiles(filePath.DirectoryName, $"{filePath.Name}-*.jpg", SearchOption.TopDirectoryOnly));
|
results.AddRange(Directory.GetFiles(filePath.DirectoryName, $"{filePath.Name}-*.jpg", SearchOption.TopDirectoryOnly));
|
||||||
if (results.Count == 0)
|
if (results.Count == 0)
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
FileHolder fileHolder = new(results[0]);
|
File.SetCreationTime(results[0], new(filePath.CreationTicks));
|
||||||
result = FilePath.Get(renameConfiguration.MetadataConfiguration, fileHolder, index: null);
|
File.SetLastWriteTime(results[0], new(filePath.LastWriteTicks));
|
||||||
if (!result.Name.EndsWith("-0001.jpg"))
|
Thread.Sleep(100);
|
||||||
throw new Exception();
|
|
||||||
bool isValidImageFormatExtension = renameConfiguration.ValidImageFormatExtensions.Contains(result.ExtensionLowered);
|
|
||||||
bool isIgnoreExtension = isValidImageFormatExtension && renameConfiguration.IgnoreExtensions.Contains(result.ExtensionLowered);
|
|
||||||
if (isIgnoreExtension || !isValidImageFormatExtension)
|
|
||||||
throw new Exception();
|
|
||||||
if (result.DirectoryName is null)
|
|
||||||
throw new NullReferenceException(nameof(result.DirectoryName));
|
|
||||||
}
|
}
|
||||||
return new(new(results), result);
|
}
|
||||||
|
return new(results);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable CA1416
|
#pragma warning disable CA1416
|
||||||
@ -126,21 +130,24 @@ public class Rename : IRename
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void GetExifDirectoryCollection(IRename rename, RenameConfiguration renameConfiguration, List<(string, FileInfo, ExifDirectory)> exifDirectories, IEnumerable<string> files, A_Metadata metadata)
|
private static List<(FilePath, FileInfo, ExifDirectory)> GetExifDirectoryCollection(IRename rename, RenameConfiguration renameConfiguration, IEnumerable<string> files, A_Metadata metadata)
|
||||||
{
|
{
|
||||||
|
List<(FilePath, FileInfo, ExifDirectory)> results = [];
|
||||||
int index = -1;
|
int index = -1;
|
||||||
FileInfo fileInfo;
|
FileInfo fileInfo;
|
||||||
FilePath filePath;
|
FilePath filePath;
|
||||||
FileHolder fileHolder;
|
FileHolder fileHolder;
|
||||||
FilePath? ffmpegFilePath;
|
FilePath? ffmpegFilePath;
|
||||||
ExifDirectory exifDirectory;
|
ExifDirectory exifDirectory;
|
||||||
ReadOnlyCollection<string> ffmpegFiles;
|
ReadOnlyCollection<string>? ffmpegFiles;
|
||||||
DeterministicHashCode deterministicHashCode;
|
DeterministicHashCode deterministicHashCode;
|
||||||
foreach (string file in files)
|
foreach (string file in files)
|
||||||
{
|
{
|
||||||
index += 1;
|
index += 1;
|
||||||
rename.Tick();
|
rename.Tick();
|
||||||
fileHolder = new(file);
|
fileHolder = new(file);
|
||||||
|
if (renameConfiguration.IgnoreExtensions.Contains(fileHolder.ExtensionLowered))
|
||||||
|
continue;
|
||||||
filePath = FilePath.Get(renameConfiguration.MetadataConfiguration, fileHolder, index);
|
filePath = FilePath.Get(renameConfiguration.MetadataConfiguration, fileHolder, index);
|
||||||
if (filePath.ExtensionLowered == ".url" && filePath.Id is not null)
|
if (filePath.ExtensionLowered == ".url" && filePath.Id is not null)
|
||||||
{
|
{
|
||||||
@ -149,29 +156,43 @@ public class Rename : IRename
|
|||||||
}
|
}
|
||||||
if (renameConfiguration.SkipIdFiles && filePath.Id is not null && (filePath.IsIntelligentIdFormat || filePath.SortOrder is not null))
|
if (renameConfiguration.SkipIdFiles && filePath.Id is not null && (filePath.IsIntelligentIdFormat || filePath.SortOrder is not null))
|
||||||
continue;
|
continue;
|
||||||
(ffmpegFiles, ffmpegFilePath) = rename.ConvertAndGetFfmpegFiles(renameConfiguration, filePath);
|
if (!renameConfiguration.ForceNewId && filePath.Id is not null)
|
||||||
if (ffmpegFilePath is not null)
|
{
|
||||||
filePath = ffmpegFilePath;
|
ffmpegFiles = null;
|
||||||
if (filePath.Id is not null)
|
|
||||||
deterministicHashCode = new(null, filePath.Id, null);
|
deterministicHashCode = new(null, filePath.Id, null);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
deterministicHashCode = rename.GetDeterministicHashCode(filePath);
|
{
|
||||||
|
ffmpegFiles = rename.ConvertAndGetFfmpegFiles(renameConfiguration, filePath);
|
||||||
|
ffmpegFilePath = ffmpegFiles.Count == 0 ? null : FilePath.Get(renameConfiguration.MetadataConfiguration, new(ffmpegFiles[0]), index);
|
||||||
|
deterministicHashCode = ffmpegFilePath is null ? rename.GetDeterministicHashCode(filePath) : rename.GetDeterministicHashCode(ffmpegFilePath);
|
||||||
|
}
|
||||||
(fileInfo, exifDirectory) = metadata.GetMetadataCollection(renameConfiguration.MetadataConfiguration, filePath, deterministicHashCode);
|
(fileInfo, exifDirectory) = metadata.GetMetadataCollection(renameConfiguration.MetadataConfiguration, filePath, deterministicHashCode);
|
||||||
exifDirectories.Add(new(file, fileInfo, exifDirectory));
|
results.Add(new(filePath, fileInfo, exifDirectory));
|
||||||
|
if (ffmpegFiles is not null)
|
||||||
|
{
|
||||||
foreach (string ffmpegFile in ffmpegFiles)
|
foreach (string ffmpegFile in ffmpegFiles)
|
||||||
File.Delete(ffmpegFile);
|
File.Delete(ffmpegFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
private static ReadOnlyCollection<Record> GetExifDirectoryCollection(List<(string, FileInfo, ExifDirectory)> exifDirectories)
|
private static ReadOnlyCollection<Record> GetExifDirectoryCollection(MetadataConfiguration metadataConfiguration, List<(FilePath, FileInfo, ExifDirectory)> exifDirectories)
|
||||||
{
|
{
|
||||||
List<Record> results = [];
|
List<Record> results = [];
|
||||||
DateTime? dateTime;
|
DateTime? dateTime;
|
||||||
foreach ((string file, FileInfo fileInfo, ExifDirectory exifDirectory) in exifDirectories)
|
bool hasIgnoreKeyword;
|
||||||
|
bool hasDateTimeOriginal;
|
||||||
|
ReadOnlyCollection<string> keywords;
|
||||||
|
foreach ((FilePath filePath, FileInfo fileInfo, ExifDirectory exifDirectory) in exifDirectories)
|
||||||
{
|
{
|
||||||
dateTime = IDate.GetDateTimeOriginal(exifDirectory);
|
dateTime = IDate.GetDateTimeOriginal(exifDirectory);
|
||||||
|
hasDateTimeOriginal = dateTime is not null;
|
||||||
dateTime ??= IDate.GetMinimum(exifDirectory);
|
dateTime ??= IDate.GetMinimum(exifDirectory);
|
||||||
results.Add(new(dateTime.Value, exifDirectory, file, fileInfo.FullName));
|
keywords = IMetadata.GetKeywords(exifDirectory);
|
||||||
|
hasIgnoreKeyword = metadataConfiguration.IgnoreRulesKeyWords.Any(l => keywords.Contains(l));
|
||||||
|
results.Add(new(dateTime.Value, exifDirectory, filePath, hasDateTimeOriginal, hasIgnoreKeyword, fileInfo.FullName));
|
||||||
}
|
}
|
||||||
return new(results);
|
return new(results);
|
||||||
}
|
}
|
||||||
@ -179,13 +200,14 @@ public class Rename : IRename
|
|||||||
private ReadOnlyCollection<Record> GetExifDirectoryCollection(IRename rename, AppSettings appSettings, RenameConfiguration renameConfiguration, DirectoryInfo directoryInfo)
|
private ReadOnlyCollection<Record> GetExifDirectoryCollection(IRename rename, AppSettings appSettings, RenameConfiguration renameConfiguration, DirectoryInfo directoryInfo)
|
||||||
{
|
{
|
||||||
ReadOnlyCollection<Record> results;
|
ReadOnlyCollection<Record> results;
|
||||||
List<(string, FileInfo, ExifDirectory)> exifDirectories = [];
|
List<(FilePath, FileInfo, ExifDirectory)> exifDirectories = [];
|
||||||
int appSettingsMaxDegreeOfParallelism = appSettings.MaxDegreeOfParallelism;
|
|
||||||
IEnumerable<string> files = Directory.EnumerateFiles(directoryInfo.FullName, "*", SearchOption.AllDirectories);
|
|
||||||
A_Metadata metadata = new(renameConfiguration.MetadataConfiguration);
|
A_Metadata metadata = new(renameConfiguration.MetadataConfiguration);
|
||||||
_ProgressBar = new(123000, "EnumerateFiles load", new ProgressBarOptions() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true });
|
int appSettingsMaxDegreeOfParallelism = appSettings.MaxDegreeOfParallelism;
|
||||||
|
IEnumerable<string> files = appSettingsMaxDegreeOfParallelism == 1 ? Directory.GetFiles(directoryInfo.FullName, "*", SearchOption.AllDirectories) : Directory.EnumerateFiles(directoryInfo.FullName, "*", SearchOption.AllDirectories);
|
||||||
|
int filesCount = appSettingsMaxDegreeOfParallelism == 1 ? files.Count() : 123000;
|
||||||
|
_ProgressBar = new(filesCount, "EnumerateFiles load", new ProgressBarOptions() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true });
|
||||||
if (appSettingsMaxDegreeOfParallelism == 1)
|
if (appSettingsMaxDegreeOfParallelism == 1)
|
||||||
GetExifDirectoryCollection(rename, renameConfiguration, exifDirectories, files, metadata);
|
exifDirectories.AddRange(GetExifDirectoryCollection(rename, renameConfiguration, files, metadata));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = appSettingsMaxDegreeOfParallelism };
|
ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = appSettingsMaxDegreeOfParallelism };
|
||||||
@ -194,13 +216,13 @@ public class Rename : IRename
|
|||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
}
|
}
|
||||||
_ProgressBar.Dispose();
|
_ProgressBar.Dispose();
|
||||||
results = GetExifDirectoryCollection(exifDirectories);
|
results = GetExifDirectoryCollection(renameConfiguration.MetadataConfiguration, exifDirectories);
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void VerifyIntMinValueLength(MetadataConfiguration metadataConfiguration, ReadOnlyCollection<Record> exifDirectories)
|
private static void VerifyIntMinValueLength(MetadataConfiguration metadataConfiguration, ReadOnlyCollection<Record> exifDirectories)
|
||||||
{
|
{
|
||||||
foreach ((DateTime _, ExifDirectory exifDirectory, string _, string _) in exifDirectories)
|
foreach ((DateTime _, ExifDirectory exifDirectory, FilePath _, bool _, bool _, string _) in exifDirectories)
|
||||||
{
|
{
|
||||||
if (exifDirectory.Id is null)
|
if (exifDirectory.Id is null)
|
||||||
continue;
|
continue;
|
||||||
@ -209,60 +231,78 @@ public class Rename : IRename
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string GetCheckDirectory(RenameConfiguration renameConfiguration, Record record, FileHolder fileHolder)
|
private static string? GetCheckDirectory(RenameConfiguration renameConfiguration, Record record, FilePath filePath, ReadOnlyCollection<int> ids, bool multipleDirectoriesWithFiles)
|
||||||
{
|
{
|
||||||
string? checkDirectory;
|
string? result;
|
||||||
if (fileHolder.DirectoryName is null)
|
if (filePath.DirectoryName is null)
|
||||||
throw new NullReferenceException(nameof(fileHolder.DirectoryName));
|
throw new NullReferenceException(nameof(filePath.DirectoryName));
|
||||||
string directoryName;
|
|
||||||
string year = record.DateTime.Year.ToString();
|
string year = record.DateTime.Year.ToString();
|
||||||
string checkDirectoryName = Path.GetFileName(fileHolder.DirectoryName);
|
string checkDirectoryName = Path.GetFileName(filePath.DirectoryName);
|
||||||
if (!checkDirectoryName.Contains(year))
|
if (multipleDirectoriesWithFiles && !checkDirectoryName.Contains(year))
|
||||||
throw new NotImplementedException();
|
result = null;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string maker = IMetadata.GetMaker(record.ExifDirectory);
|
string? maker = IMetadata.GetMaker(record.ExifDirectory);
|
||||||
(int seasonValue, string seasonName) = IDate.GetSeason(record.DateTime.DayOfYear);
|
(int seasonValue, string seasonName) = IDate.GetSeason(record.DateTime.DayOfYear);
|
||||||
string splat = fileHolder.DirectoryName[^3..][1] == '!' ? fileHolder.DirectoryName[^3..] : string.Empty;
|
string splat = filePath.DirectoryName[^3..][1] == '!' ? filePath.DirectoryName[^3..] : string.Empty;
|
||||||
directoryName = $"{year}.{seasonValue} {seasonName} {maker.Split(' ')[0]}{splat}";
|
string makerSplit = string.IsNullOrEmpty(maker) ? string.IsNullOrEmpty(renameConfiguration.DefaultMaker) ? string.Empty : renameConfiguration.DefaultMaker : $" {maker.Split(' ')[0]}";
|
||||||
|
string directoryName = $"{year}.{seasonValue} {seasonName}{makerSplit}{splat}";
|
||||||
|
result = Path.Combine(renameConfiguration.MetadataConfiguration.ResultConfiguration.RootDirectory, record.ExifDirectory.Id is null || !ids.Contains(record.ExifDirectory.Id.Value) ? "_ Destination _" : "_ Exists _", record.HasDateTimeOriginal ? "Has" : "Not", directoryName);
|
||||||
}
|
}
|
||||||
string rootDirectory = renameConfiguration.MoveFilesToRoot ? renameConfiguration.MetadataConfiguration.ResultConfiguration.RootDirectory : fileHolder.DirectoryName;
|
return result;
|
||||||
checkDirectory = Path.Combine(rootDirectory, "_ Destination _", directoryName);
|
|
||||||
return checkDirectory;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ReadOnlyCollection<ToDo> GetToDoCollection(ILogger<Program>? logger, RenameConfiguration renameConfiguration, long ticks, ReadOnlyCollection<Record> exifDirectories)
|
private static ReadOnlyCollection<ToDo> GetToDoCollection(RenameConfiguration renameConfiguration, Identifier[]? identifiers, ReadOnlyCollection<Record> records)
|
||||||
{
|
{
|
||||||
List<ToDo> results = [];
|
List<ToDo> results = [];
|
||||||
Record record;
|
Record record;
|
||||||
string jsonFile;
|
string jsonFile;
|
||||||
string paddedId;
|
string paddedId;
|
||||||
string checkFile;
|
string checkFile;
|
||||||
|
FilePath filePath;
|
||||||
string directoryName;
|
string directoryName;
|
||||||
FileHolder fileHolder;
|
FileHolder fileHolder;
|
||||||
string? checkDirectory;
|
string? checkDirectory;
|
||||||
const string jpg = ".jpg";
|
const string jpg = ".jpg";
|
||||||
string checkFileExtension;
|
string checkFileExtension;
|
||||||
|
bool multipleDirectoriesWithFiles;
|
||||||
List<string> distinct = [];
|
List<string> distinct = [];
|
||||||
|
bool? directoryCheck = null;
|
||||||
const string jpeg = ".jpeg";
|
const string jpeg = ".jpeg";
|
||||||
string jsonFileSubDirectory;
|
string jsonFileSubDirectory;
|
||||||
VerifyIntMinValueLength(renameConfiguration.MetadataConfiguration, exifDirectories);
|
foreach (string directory in Directory.GetDirectories(renameConfiguration.MetadataConfiguration.ResultConfiguration.RootDirectory, "*", SearchOption.TopDirectoryOnly))
|
||||||
ResultConfiguration resultConfiguration = renameConfiguration.MetadataConfiguration.ResultConfiguration;
|
|
||||||
ReadOnlyCollection<Record> records = new((from l in exifDirectories orderby l.DateTime select l).ToArray());
|
|
||||||
for (int i = 0; i < records.Count; i++)
|
|
||||||
{
|
{
|
||||||
record = records[i];
|
foreach (string _ in Directory.EnumerateFiles(directory, "*", SearchOption.AllDirectories))
|
||||||
|
{
|
||||||
|
if (directoryCheck is null)
|
||||||
|
directoryCheck = false;
|
||||||
|
else if (directoryCheck.Value)
|
||||||
|
directoryCheck = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (directoryCheck is not null && directoryCheck.Value)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
VerifyIntMinValueLength(renameConfiguration.MetadataConfiguration, records);
|
||||||
|
multipleDirectoriesWithFiles = directoryCheck is not null && directoryCheck.Value;
|
||||||
|
ReadOnlyCollection<Record> collection = new((from l in records orderby l.DateTime select l).ToArray());
|
||||||
|
ResultConfiguration resultConfiguration = renameConfiguration.MetadataConfiguration.ResultConfiguration;
|
||||||
|
ReadOnlyCollection<int> ids = identifiers is null ? new([]) : new((from l in identifiers select l.Id).ToArray());
|
||||||
|
for (int i = 0; i < collection.Count; i++)
|
||||||
|
{
|
||||||
|
record = collection[i];
|
||||||
if (record.ExifDirectory.Id is null)
|
if (record.ExifDirectory.Id is null)
|
||||||
continue;
|
continue;
|
||||||
fileHolder = new(record.File);
|
if (record.FilePath.DirectoryName is null)
|
||||||
if (fileHolder.DirectoryName is null)
|
|
||||||
continue;
|
continue;
|
||||||
checkDirectory = GetCheckDirectory(renameConfiguration, record, fileHolder);
|
checkDirectory = GetCheckDirectory(renameConfiguration, record, record.FilePath, ids, multipleDirectoriesWithFiles);
|
||||||
checkFileExtension = fileHolder.ExtensionLowered == jpeg ? jpg : fileHolder.ExtensionLowered;
|
if (string.IsNullOrEmpty(checkDirectory))
|
||||||
paddedId = IId.GetPaddedId(renameConfiguration.MetadataConfiguration, i, record.ExifDirectory.Id.Value);
|
continue;
|
||||||
|
checkFileExtension = record.FilePath.ExtensionLowered == jpeg ? jpg : record.FilePath.ExtensionLowered;
|
||||||
|
paddedId = IId.GetPaddedId(renameConfiguration.MetadataConfiguration, record.ExifDirectory.Id.Value, record.HasIgnoreKeyword, i);
|
||||||
jsonFileSubDirectory = Path.GetDirectoryName(Path.GetDirectoryName(record.JsonFile)) ?? throw new Exception();
|
jsonFileSubDirectory = Path.GetDirectoryName(Path.GetDirectoryName(record.JsonFile)) ?? throw new Exception();
|
||||||
checkFile = Path.Combine(checkDirectory, $"{paddedId}{checkFileExtension}");
|
checkFile = Path.Combine(checkDirectory, $"{paddedId}{checkFileExtension}");
|
||||||
if (checkFile == fileHolder.FullName)
|
if (checkFile == record.FilePath.FullName)
|
||||||
continue;
|
continue;
|
||||||
if (File.Exists(checkFile))
|
if (File.Exists(checkFile))
|
||||||
{
|
{
|
||||||
@ -273,11 +313,15 @@ public class Rename : IRename
|
|||||||
(directoryName, _) = IPath.GetDirectoryNameAndIndex(resultConfiguration, record.ExifDirectory.Id.Value);
|
(directoryName, _) = IPath.GetDirectoryNameAndIndex(resultConfiguration, record.ExifDirectory.Id.Value);
|
||||||
jsonFile = Path.Combine(jsonFileSubDirectory, directoryName, $"{record.ExifDirectory.Id.Value}{checkFileExtension}.json");
|
jsonFile = Path.Combine(jsonFileSubDirectory, directoryName, $"{record.ExifDirectory.Id.Value}{checkFileExtension}.json");
|
||||||
if (record.JsonFile != jsonFile)
|
if (record.JsonFile != jsonFile)
|
||||||
results.Add(new(null, new(record.JsonFile), jsonFile, JsonFile: true));
|
{
|
||||||
|
fileHolder = new(record.JsonFile);
|
||||||
|
filePath = FilePath.Get(renameConfiguration.MetadataConfiguration, fileHolder, index: null);
|
||||||
|
results.Add(new(null, filePath, jsonFile, JsonFile: true));
|
||||||
|
}
|
||||||
if (distinct.Contains(checkFile))
|
if (distinct.Contains(checkFile))
|
||||||
continue;
|
continue;
|
||||||
distinct.Add(checkFile);
|
distinct.Add(checkFile);
|
||||||
results.Add(new(checkDirectory, fileHolder, checkFile, JsonFile: false));
|
results.Add(new(checkDirectory, record.FilePath, checkFile, JsonFile: false));
|
||||||
}
|
}
|
||||||
return new(results);
|
return new(results);
|
||||||
}
|
}
|
||||||
@ -307,7 +351,7 @@ public class Rename : IRename
|
|||||||
{
|
{
|
||||||
if (File.Exists(toDo.File))
|
if (File.Exists(toDo.File))
|
||||||
File.Delete(toDo.File);
|
File.Delete(toDo.File);
|
||||||
File.Move(toDo.FileHolder.FullName, toDo.File);
|
File.Move(toDo.FilePath.FullName, toDo.File);
|
||||||
}
|
}
|
||||||
else if (toDo.Directory is null)
|
else if (toDo.Directory is null)
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
@ -316,22 +360,142 @@ public class Rename : IRename
|
|||||||
if (File.Exists(toDo.File))
|
if (File.Exists(toDo.File))
|
||||||
File.Delete(toDo.File);
|
File.Delete(toDo.File);
|
||||||
try
|
try
|
||||||
{ File.Move(toDo.FileHolder.FullName, toDo.File); }
|
{ File.Move(toDo.FilePath.FullName, toDo.File); }
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{ continue; }
|
{ continue; }
|
||||||
results.Add($"{toDo.FileHolder.FullName}\t{toDo.File}");
|
results.Add($"{toDo.FilePath.FullName}\t{toDo.File}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ProgressBar.Dispose();
|
_ProgressBar.Dispose();
|
||||||
return new(results);
|
return new(results);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void SaveIdentifiersToDisk(long ticks, RenameConfiguration renameConfiguration, string aMetadataCollectionDirectory, ReadOnlyCollection<Record> records)
|
||||||
|
{
|
||||||
|
string paddedId;
|
||||||
|
List<Identifier> identifiers = [];
|
||||||
|
foreach (Record record in records)
|
||||||
|
{
|
||||||
|
if (record.ExifDirectory.Id is null)
|
||||||
|
continue;
|
||||||
|
paddedId = IId.GetPaddedId(renameConfiguration.MetadataConfiguration, record.ExifDirectory.Id.Value, record.FilePath.IsIgnore, index: null);
|
||||||
|
identifiers.Add(new(record.ExifDirectory.Id.Value, paddedId));
|
||||||
|
}
|
||||||
|
string json = JsonSerializer.Serialize(identifiers.OrderBy(l => l.PaddedId).ToArray(), IdentifierCollectionSourceGenerationContext.Default.IdentifierArray);
|
||||||
|
_ = IPath.WriteAllText(Path.Combine(aMetadataCollectionDirectory, $"{ticks}.json"), json, updateDateWhenMatches: false, compareBeforeWrite: true, updateToWhenMatches: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ReadOnlyCollection<(string, string)> GetAggregationLines(string harFile)
|
||||||
|
{
|
||||||
|
List<(string, string)> results = [];
|
||||||
|
if (!File.Exists(harFile))
|
||||||
|
throw new Exception();
|
||||||
|
string lastUrl = string.Empty;
|
||||||
|
string text = "\"text\": \"{";
|
||||||
|
string[] lines = File.ReadAllLines(harFile);
|
||||||
|
foreach (string line in lines)
|
||||||
|
{
|
||||||
|
if (line.Contains("\"url\": \""))
|
||||||
|
lastUrl = line;
|
||||||
|
if (!line.Contains(text))
|
||||||
|
continue;
|
||||||
|
if (!line.Contains("aggregations"))
|
||||||
|
continue;
|
||||||
|
if (lastUrl.Contains("search?asset=NONE"))
|
||||||
|
continue;
|
||||||
|
results.Add(new(lastUrl, line.Trim()[(text.Length - 1)..^1].Replace("\\\"", "\"")));
|
||||||
|
lastUrl = string.Empty;
|
||||||
|
}
|
||||||
|
return new(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SaveAmazon(IReadOnlyList<Datum> data, string personIdFile)
|
||||||
|
{
|
||||||
|
string json;
|
||||||
|
Dictionary<string, Datum> keyValuePairs = [];
|
||||||
|
foreach (Datum datum in data)
|
||||||
|
_ = keyValuePairs.TryAdd(datum.Name.Split('.')[0], datum);
|
||||||
|
json = JsonSerializer.Serialize(keyValuePairs, DictionaryDatumGenerationContext.Default.DictionaryStringDatum);
|
||||||
|
File.WriteAllText(personIdFile, json);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SaveAmazon(AppSettings appSettings, string harFile)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(appSettings.HarFilesDirectory))
|
||||||
|
throw new NullReferenceException(nameof(appSettings.HarFilesDirectory));
|
||||||
|
string offset;
|
||||||
|
string personId;
|
||||||
|
RootAmazon amazon;
|
||||||
|
string? personName;
|
||||||
|
string personIdFile;
|
||||||
|
string personDirectory;
|
||||||
|
PersonAmazon personAmazon;
|
||||||
|
Dictionary<string, string> keyValuePairs = [];
|
||||||
|
ReadOnlyCollection<(string Url, string AggregationLine)> aggregationLines = GetAggregationLines(harFile);
|
||||||
|
foreach ((string url, string aggregationLine) in aggregationLines)
|
||||||
|
{
|
||||||
|
if (aggregationLine.Contains(",\"category\":\"allPeople\"}"))
|
||||||
|
continue;
|
||||||
|
amazon = JsonSerializer.Deserialize(aggregationLine, RootAmazonGenerationContext.Default.RootAmazon) ?? throw new Exception();
|
||||||
|
if (amazon.Aggregations?.People is null || amazon.Aggregations.People.Count < 1)
|
||||||
|
continue;
|
||||||
|
personAmazon = amazon.Aggregations.People[0];
|
||||||
|
if (!url.Contains(personAmazon.Match))
|
||||||
|
continue;
|
||||||
|
personDirectory = Path.Combine(appSettings.HarFilesDirectory, "Amazon", personAmazon.SearchData.ClusterName);
|
||||||
|
_ = Directory.CreateDirectory(personDirectory);
|
||||||
|
personIdFile = Path.Combine(personDirectory, $"000) {personAmazon.Match}.json");
|
||||||
|
_ = keyValuePairs.TryAdd(personAmazon.Match, personAmazon.SearchData.ClusterName);
|
||||||
|
SaveAmazon(amazon.Data, personIdFile);
|
||||||
|
}
|
||||||
|
foreach ((string url, string aggregationLine) in aggregationLines)
|
||||||
|
{
|
||||||
|
if (aggregationLine.Contains(",\"category\":\"allPeople\"}"))
|
||||||
|
continue;
|
||||||
|
amazon = JsonSerializer.Deserialize(aggregationLine, RootAmazonGenerationContext.Default.RootAmazon) ?? throw new Exception();
|
||||||
|
if (amazon.Aggregations?.People is not null && amazon.Aggregations.People.Count > 0)
|
||||||
|
continue;
|
||||||
|
if (!url.Contains("offset="))
|
||||||
|
continue;
|
||||||
|
offset = url.Split("offset=")[1];
|
||||||
|
if (!url.Contains("people%3A("))
|
||||||
|
continue;
|
||||||
|
personId = url.Split("people%3A(")[1].Split(')')[0];
|
||||||
|
if (!keyValuePairs.TryGetValue(personId, out personName))
|
||||||
|
continue;
|
||||||
|
personDirectory = Path.Combine(appSettings.HarFilesDirectory, "Amazon", personName);
|
||||||
|
_ = Directory.CreateDirectory(personDirectory);
|
||||||
|
personIdFile = Path.Combine(personDirectory, $"{offset.Split('&')[0]}) {personId}.json");
|
||||||
|
SaveAmazon(amazon.Data, personIdFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SaveAmazon(ILogger<Program>? logger, AppSettings appSettings, long ticks)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(appSettings.HarFilesDirectory))
|
||||||
|
throw new NullReferenceException(nameof(appSettings.HarFilesDirectory));
|
||||||
|
logger?.LogInformation("{Ticks} a", ticks);
|
||||||
|
string[] harFiles = Directory.GetFiles(appSettings.HarFilesDirectory, "*.har", SearchOption.TopDirectoryOnly);
|
||||||
|
foreach (string harFile in harFiles)
|
||||||
|
SaveAmazon(appSettings, harFile);
|
||||||
|
logger?.LogInformation("{harFiles} count", harFiles.Length);
|
||||||
|
}
|
||||||
|
|
||||||
private void RenameWork(ILogger<Program>? logger, AppSettings appSettings, IRename rename, long ticks, RenameConfiguration renameConfiguration)
|
private void RenameWork(ILogger<Program>? logger, AppSettings appSettings, IRename rename, long ticks, RenameConfiguration renameConfiguration)
|
||||||
{
|
{
|
||||||
|
string aMetadataCollectionDirectory = IResult.GetResultsDateGroupDirectory(renameConfiguration.MetadataConfiguration.ResultConfiguration, nameof(A_Metadata), renameConfiguration.MetadataConfiguration.ResultConfiguration.ResultCollection);
|
||||||
|
string? propertyCollectionFile = string.IsNullOrEmpty(renameConfiguration.RelativePropertyCollectionFile) ? null : Path.GetFullPath(Path.Combine(aMetadataCollectionDirectory, renameConfiguration.RelativePropertyCollectionFile));
|
||||||
|
string? json = !File.Exists(propertyCollectionFile) ? null : File.ReadAllText(propertyCollectionFile);
|
||||||
|
Identifier[]? identifiers = json is null ? null : JsonSerializer.Deserialize(json, IdentifierCollectionSourceGenerationContext.Default.IdentifierArray);
|
||||||
|
if (identifiers is null && !string.IsNullOrEmpty(renameConfiguration.RelativePropertyCollectionFile))
|
||||||
|
throw new Exception($"Invalid {nameof(renameConfiguration.RelativePropertyCollectionFile)}");
|
||||||
DirectoryInfo directoryInfo = new(Path.GetFullPath(renameConfiguration.MetadataConfiguration.ResultConfiguration.RootDirectory));
|
DirectoryInfo directoryInfo = new(Path.GetFullPath(renameConfiguration.MetadataConfiguration.ResultConfiguration.RootDirectory));
|
||||||
logger?.LogInformation("{RootDirectory}", directoryInfo.FullName);
|
logger?.LogInformation("{Ticks} {RootDirectory}", ticks, directoryInfo.FullName);
|
||||||
ReadOnlyCollection<Record> exifDirectories = GetExifDirectoryCollection(rename, appSettings, renameConfiguration, directoryInfo);
|
if (!string.IsNullOrEmpty(appSettings.HarFilesDirectory) && Directory.Exists(appSettings.HarFilesDirectory))
|
||||||
ReadOnlyCollection<ToDo> toDoCollection = GetToDoCollection(logger, renameConfiguration, ticks, exifDirectories);
|
SaveAmazon(logger, appSettings, ticks);
|
||||||
|
ReadOnlyCollection<Record> records = GetExifDirectoryCollection(rename, appSettings, renameConfiguration, directoryInfo);
|
||||||
|
SaveIdentifiersToDisk(ticks, renameConfiguration, aMetadataCollectionDirectory, records);
|
||||||
|
ReadOnlyCollection<ToDo> toDoCollection = GetToDoCollection(renameConfiguration, identifiers, records);
|
||||||
ReadOnlyCollection<string> lines = RenameFilesInDirectories(toDoCollection);
|
ReadOnlyCollection<string> lines = RenameFilesInDirectories(toDoCollection);
|
||||||
if (lines.Count != 0)
|
if (lines.Count != 0)
|
||||||
{
|
{
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
<SupportedPlatform Include="browser" />
|
<SupportedPlatform Include="browser" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
|
<PackageReference Include="System.Drawing.Common" Version="8.0.4" />
|
||||||
<PackageReference Include="System.Text.Json" Version="7.0.3" />
|
<PackageReference Include="System.Text.Json" Version="8.0.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
19
Shared/Models/Aggregations.cs
Normal file
19
Shared/Models/Aggregations.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace View_by_Distance.Shared.Models;
|
||||||
|
|
||||||
|
public record Aggregations(
|
||||||
|
[property: JsonPropertyName("allPeople")] IReadOnlyList<AllPerson> AllPeople,
|
||||||
|
[property: JsonPropertyName("clusterId")] IReadOnlyList<ClusterId> ClusterId,
|
||||||
|
[property: JsonPropertyName("location")] IReadOnlyList<LocationAmazon> Location,
|
||||||
|
[property: JsonPropertyName("people")] IReadOnlyList<PersonAmazon> People,
|
||||||
|
[property: JsonPropertyName("things")] IReadOnlyList<Thing> Things,
|
||||||
|
[property: JsonPropertyName("time")] IReadOnlyList<Time> Time,
|
||||||
|
[property: JsonPropertyName("type")] IReadOnlyList<Type> Type
|
||||||
|
);
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(Aggregations))]
|
||||||
|
public partial class AggregationsGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
15
Shared/Models/AllPerson.cs
Normal file
15
Shared/Models/AllPerson.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace View_by_Distance.Shared.Models;
|
||||||
|
|
||||||
|
public record AllPerson(
|
||||||
|
[property: JsonPropertyName("count")] int Count,
|
||||||
|
[property: JsonPropertyName("match")] string Match,
|
||||||
|
[property: JsonPropertyName("searchData")] SearchData SearchData
|
||||||
|
);
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(AllPerson))]
|
||||||
|
public partial class AllPersonGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
15
Shared/Models/ClusterId.cs
Normal file
15
Shared/Models/ClusterId.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace View_by_Distance.Shared.Models;
|
||||||
|
|
||||||
|
public record ClusterId(
|
||||||
|
[property: JsonPropertyName("count")] int Count,
|
||||||
|
[property: JsonPropertyName("match")] string Match,
|
||||||
|
[property: JsonPropertyName("searchData")] SearchData SearchData
|
||||||
|
);
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(ClusterId))]
|
||||||
|
public partial class ClusterIdGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
20
Shared/Models/ContentProperties.cs
Normal file
20
Shared/Models/ContentProperties.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace View_by_Distance.Shared.Models;
|
||||||
|
|
||||||
|
public record ContentProperties(
|
||||||
|
[property: JsonPropertyName("contentDate")] DateTime ContentDate,
|
||||||
|
[property: JsonPropertyName("contentSignatures")] IReadOnlyList<ContentSignature> ContentSignatures,
|
||||||
|
[property: JsonPropertyName("contentType")] string ContentType,
|
||||||
|
[property: JsonPropertyName("extension")] string Extension,
|
||||||
|
[property: JsonPropertyName("image")] ImageAmazon Image,
|
||||||
|
[property: JsonPropertyName("md5")] string Md5,
|
||||||
|
[property: JsonPropertyName("size")] int Size,
|
||||||
|
[property: JsonPropertyName("version")] int Version
|
||||||
|
);
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(ContentProperties))]
|
||||||
|
public partial class ContentPropertiesGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
14
Shared/Models/ContentSignature.cs
Normal file
14
Shared/Models/ContentSignature.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace View_by_Distance.Shared.Models;
|
||||||
|
|
||||||
|
public record ContentSignature(
|
||||||
|
[property: JsonPropertyName("contentSignature")] string Value,
|
||||||
|
[property: JsonPropertyName("contentSignatureType")] string ContentSignatureType
|
||||||
|
);
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(ContentSignature))]
|
||||||
|
public partial class ContentSignatureGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
45
Shared/Models/Datum.cs
Normal file
45
Shared/Models/Datum.cs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace View_by_Distance.Shared.Models;
|
||||||
|
|
||||||
|
public record Datum(
|
||||||
|
[property: JsonPropertyName("accessRuleIds")] IReadOnlyList<object> AccessRuleIds,
|
||||||
|
[property: JsonPropertyName("childAssetTypeInfo")] IReadOnlyList<object> ChildAssetTypeInfo,
|
||||||
|
[property: JsonPropertyName("contentProperties")] ContentProperties ContentProperties,
|
||||||
|
[property: JsonPropertyName("createdBy")] string CreatedBy,
|
||||||
|
[property: JsonPropertyName("createdDate")] DateTime CreatedDate,
|
||||||
|
[property: JsonPropertyName("eTagResponse")] string ETagResponse,
|
||||||
|
[property: JsonPropertyName("groupPermissions")] IReadOnlyList<object> GroupPermissions,
|
||||||
|
[property: JsonPropertyName("id")] string Id,
|
||||||
|
[property: JsonPropertyName("isRoot")] bool IsRoot,
|
||||||
|
[property: JsonPropertyName("isShared")] bool IsShared,
|
||||||
|
[property: JsonPropertyName("keywords")] IReadOnlyList<object> Keywords,
|
||||||
|
[property: JsonPropertyName("kind")] string Kind,
|
||||||
|
[property: JsonPropertyName("labels")] IReadOnlyList<object> Labels,
|
||||||
|
[property: JsonPropertyName("modifiedDate")] DateTime ModifiedDate,
|
||||||
|
[property: JsonPropertyName("name")] string Name,
|
||||||
|
[property: JsonPropertyName("ownerId")] string OwnerId,
|
||||||
|
[property: JsonPropertyName("parentMap")] ParentMap ParentMap,
|
||||||
|
[property: JsonPropertyName("parents")] IReadOnlyList<string> Parents,
|
||||||
|
[property: JsonPropertyName("protectedFolder")] bool ProtectedFolder,
|
||||||
|
[property: JsonPropertyName("restricted")] bool Restricted,
|
||||||
|
[property: JsonPropertyName("status")] string Status,
|
||||||
|
[property: JsonPropertyName("subKinds")] IReadOnlyList<object> SubKinds,
|
||||||
|
[property: JsonPropertyName("transforms")] IReadOnlyList<string> Transforms,
|
||||||
|
[property: JsonPropertyName("version")] int Version,
|
||||||
|
[property: JsonPropertyName("xAccntParentMap")] XAccntParentMap XAccntParentMap,
|
||||||
|
[property: JsonPropertyName("xAccntParents")] IReadOnlyList<object> XAccntParents,
|
||||||
|
[property: JsonPropertyName("match")] bool? Match
|
||||||
|
);
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(Datum))]
|
||||||
|
public partial class DatumGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(Dictionary<string, Datum>))]
|
||||||
|
public partial class DictionaryDatumGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
@ -45,7 +45,6 @@ public class FileHolder
|
|||||||
{
|
{
|
||||||
if (fileInfo.Exists)
|
if (fileInfo.Exists)
|
||||||
{
|
{
|
||||||
_CreationTime = fileInfo.CreationTime;
|
|
||||||
_CreationTime = fileInfo.CreationTime;
|
_CreationTime = fileInfo.CreationTime;
|
||||||
_LastWriteTime = fileInfo.LastWriteTime;
|
_LastWriteTime = fileInfo.LastWriteTime;
|
||||||
_Length = fileInfo.Length;
|
_Length = fileInfo.Length;
|
||||||
|
@ -10,6 +10,7 @@ public record FilePath(long CreationTicks,
|
|||||||
string FileNameFirstSegment,
|
string FileNameFirstSegment,
|
||||||
string FullName,
|
string FullName,
|
||||||
int? Id,
|
int? Id,
|
||||||
|
bool? IsIgnore,
|
||||||
bool IsIntelligentIdFormat,
|
bool IsIntelligentIdFormat,
|
||||||
long LastWriteTicks,
|
long LastWriteTicks,
|
||||||
long Length,
|
long Length,
|
||||||
@ -26,6 +27,8 @@ public record FilePath(long CreationTicks,
|
|||||||
|
|
||||||
public static FilePath Get(MetadataConfiguration metadataConfiguration, FileHolder fileHolder, int? index)
|
public static FilePath Get(MetadataConfiguration metadataConfiguration, FileHolder fileHolder, int? index)
|
||||||
{
|
{
|
||||||
|
if (fileHolder.CreationTime is null)
|
||||||
|
fileHolder = new(fileHolder.FullName);
|
||||||
if (fileHolder.CreationTime is null)
|
if (fileHolder.CreationTime is null)
|
||||||
throw new NullReferenceException(nameof(fileHolder.CreationTime));
|
throw new NullReferenceException(nameof(fileHolder.CreationTime));
|
||||||
if (fileHolder.LastWriteTime is null)
|
if (fileHolder.LastWriteTime is null)
|
||||||
@ -38,14 +41,15 @@ public record FilePath(long CreationTicks,
|
|||||||
string fileNameFirstSegment = fileHolder.Name.Split('.')[0];
|
string fileNameFirstSegment = fileHolder.Name.Split('.')[0];
|
||||||
int sortOrderOnlyLengthIndex = metadataConfiguration.Offset.ToString().Length;
|
int sortOrderOnlyLengthIndex = metadataConfiguration.Offset.ToString().Length;
|
||||||
string fileDirectoryName = fileHolder.DirectoryName ?? throw new NullReferenceException();
|
string fileDirectoryName = fileHolder.DirectoryName ?? throw new NullReferenceException();
|
||||||
bool fileNameFirstSegmentIsIntelligentIdFormat = IId.NameWithoutExtensionIsIntelligentIdFormat(metadataConfiguration, fileNameFirstSegment);
|
bool isIntelligentIdFormat = IId.NameWithoutExtensionIsIntelligentIdFormat(metadataConfiguration, fileNameFirstSegment);
|
||||||
bool fileNameFirstSegmentIsPaddedIntelligentIdFormat = IId.NameWithoutExtensionIsPaddedIntelligentIdFormat(metadataConfiguration, sortOrderOnlyLengthIndex, fileNameFirstSegment);
|
bool isPaddedIntelligentIdFormat = IId.NameWithoutExtensionIsPaddedIntelligentIdFormat(metadataConfiguration, sortOrderOnlyLengthIndex, fileNameFirstSegment);
|
||||||
bool fileNameFirstSegmentIsIdFormat = !fileNameFirstSegmentIsPaddedIntelligentIdFormat && !fileNameFirstSegmentIsIntelligentIdFormat && IId.NameWithoutExtensionIsIdFormat(metadataConfiguration, fileHolder);
|
bool fileNameFirstSegmentIsIdFormat = !isPaddedIntelligentIdFormat && !isIntelligentIdFormat && IId.NameWithoutExtensionIsIdFormat(metadataConfiguration, fileHolder);
|
||||||
if (!fileNameFirstSegmentIsIdFormat && !fileNameFirstSegmentIsIntelligentIdFormat && !fileNameFirstSegmentIsPaddedIntelligentIdFormat)
|
bool? isIgnore = !isIntelligentIdFormat && !isPaddedIntelligentIdFormat ? null : fileNameFirstSegment[^1] is '2' or '8';
|
||||||
|
if (!fileNameFirstSegmentIsIdFormat && !isIntelligentIdFormat && !isPaddedIntelligentIdFormat)
|
||||||
(id, sortOder) = (null, null);
|
(id, sortOder) = (null, null);
|
||||||
else if (fileNameFirstSegmentIsIntelligentIdFormat)
|
else if (isIntelligentIdFormat)
|
||||||
(id, sortOder) = (IId.GetId(metadataConfiguration, fileNameFirstSegment), null);
|
(id, sortOder) = (IId.GetId(metadataConfiguration, fileNameFirstSegment), null);
|
||||||
else if (fileNameFirstSegmentIsPaddedIntelligentIdFormat)
|
else if (isPaddedIntelligentIdFormat)
|
||||||
{
|
{
|
||||||
if (!int.TryParse(fileNameFirstSegment[..sortOrderOnlyLengthIndex], out int absoluteValueOfSortOrder))
|
if (!int.TryParse(fileNameFirstSegment[..sortOrderOnlyLengthIndex], out int absoluteValueOfSortOrder))
|
||||||
(id, sortOder) = (null, null);
|
(id, sortOder) = (null, null);
|
||||||
@ -68,7 +72,8 @@ public record FilePath(long CreationTicks,
|
|||||||
fileNameFirstSegment,
|
fileNameFirstSegment,
|
||||||
fileHolder.FullName,
|
fileHolder.FullName,
|
||||||
id,
|
id,
|
||||||
fileNameFirstSegmentIsIntelligentIdFormat,
|
isIgnore,
|
||||||
|
isIntelligentIdFormat,
|
||||||
fileHolder.LastWriteTime.Value.Ticks,
|
fileHolder.LastWriteTime.Value.Ticks,
|
||||||
fileHolder.Length.Value,
|
fileHolder.Length.Value,
|
||||||
fileHolder.Name,
|
fileHolder.Name,
|
||||||
|
36
Shared/Models/ImageAmazon.cs
Normal file
36
Shared/Models/ImageAmazon.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace View_by_Distance.Shared.Models;
|
||||||
|
|
||||||
|
public record ImageAmazon(
|
||||||
|
[property: JsonPropertyName("colorSpace")] string ColorSpace,
|
||||||
|
[property: JsonPropertyName("dateTime")] DateTime DateTime,
|
||||||
|
[property: JsonPropertyName("dateTimeDigitized")] DateTime DateTimeDigitized,
|
||||||
|
[property: JsonPropertyName("dateTimeOriginal")] DateTime DateTimeOriginal,
|
||||||
|
[property: JsonPropertyName("exposureMode")] string ExposureMode,
|
||||||
|
[property: JsonPropertyName("exposureProgram")] string ExposureProgram,
|
||||||
|
[property: JsonPropertyName("exposureTime")] string ExposureTime,
|
||||||
|
[property: JsonPropertyName("flash")] string Flash,
|
||||||
|
[property: JsonPropertyName("focalLength")] string FocalLength,
|
||||||
|
[property: JsonPropertyName("height")] int Height,
|
||||||
|
[property: JsonPropertyName("make")] string Make,
|
||||||
|
[property: JsonPropertyName("meteringMode")] string MeteringMode,
|
||||||
|
[property: JsonPropertyName("model")] string Model,
|
||||||
|
[property: JsonPropertyName("orientation")] string Orientation,
|
||||||
|
[property: JsonPropertyName("resolutionUnit")] string ResolutionUnit,
|
||||||
|
[property: JsonPropertyName("sensingMethod")] string SensingMethod,
|
||||||
|
[property: JsonPropertyName("sharpness")] string Sharpness,
|
||||||
|
[property: JsonPropertyName("software")] string Software,
|
||||||
|
[property: JsonPropertyName("subSecTime")] string SubSecTime,
|
||||||
|
[property: JsonPropertyName("subSecTimeDigitized")] string SubSecTimeDigitized,
|
||||||
|
[property: JsonPropertyName("subSecTimeOriginal")] string SubSecTimeOriginal,
|
||||||
|
[property: JsonPropertyName("whiteBalance")] string WhiteBalance,
|
||||||
|
[property: JsonPropertyName("width")] int Width,
|
||||||
|
[property: JsonPropertyName("apertureValue")] string ApertureValue
|
||||||
|
);
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(ImageAmazon))]
|
||||||
|
public partial class ImageAmazonGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
15
Shared/Models/LocationAmazon.cs
Normal file
15
Shared/Models/LocationAmazon.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace View_by_Distance.Shared.Models;
|
||||||
|
|
||||||
|
public record LocationAmazon(
|
||||||
|
[property: JsonPropertyName("count")] int Count,
|
||||||
|
[property: JsonPropertyName("match")] string Match,
|
||||||
|
[property: JsonPropertyName("searchData")] SearchData SearchData
|
||||||
|
);
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(LocationAmazon))]
|
||||||
|
public partial class LocationAmazonGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
17
Shared/Models/LocationInfo.cs
Normal file
17
Shared/Models/LocationInfo.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace View_by_Distance.Shared.Models;
|
||||||
|
|
||||||
|
public record LocationInfo(
|
||||||
|
[property: JsonPropertyName("city")] string City,
|
||||||
|
[property: JsonPropertyName("country")] string Country,
|
||||||
|
[property: JsonPropertyName("countryIso3Code")] string CountryIso3Code,
|
||||||
|
[property: JsonPropertyName("state")] string State,
|
||||||
|
[property: JsonPropertyName("stateCode")] string StateCode
|
||||||
|
);
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(LocationInfo))]
|
||||||
|
public partial class LocationInfoGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
25
Shared/Models/MappingFromFilter.cs
Normal file
25
Shared/Models/MappingFromFilter.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace View_by_Distance.Shared.Models;
|
||||||
|
|
||||||
|
public record MappingFromFilter(bool? IsFocusModel,
|
||||||
|
bool? IsFocusPerson,
|
||||||
|
bool? IsFocusRelativePath,
|
||||||
|
bool? InSkipCollection,
|
||||||
|
bool? IsUsed)
|
||||||
|
{
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
string result = JsonSerializer.Serialize(this, MappingFromFilterGenerationContext.Default.MappingFromFilter);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(MappingFromFilter))]
|
||||||
|
public partial class MappingFromFilterGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
13
Shared/Models/ParentMap.cs
Normal file
13
Shared/Models/ParentMap.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace View_by_Distance.Shared.Models;
|
||||||
|
|
||||||
|
public record ParentMap(
|
||||||
|
[property: JsonPropertyName("FOLDER")] IReadOnlyList<string> FOLDER
|
||||||
|
);
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(ParentMap))]
|
||||||
|
public partial class ParentMapGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
15
Shared/Models/PersonAmazon.cs
Normal file
15
Shared/Models/PersonAmazon.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace View_by_Distance.Shared.Models;
|
||||||
|
|
||||||
|
public record PersonAmazon(
|
||||||
|
[property: JsonPropertyName("count")] int Count,
|
||||||
|
[property: JsonPropertyName("match")] string Match,
|
||||||
|
[property: JsonPropertyName("searchData")] SearchData SearchData
|
||||||
|
);
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(PersonAmazon))]
|
||||||
|
public partial class PersonAmazonGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
15
Shared/Models/RootAmazon.cs
Normal file
15
Shared/Models/RootAmazon.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace View_by_Distance.Shared.Models;
|
||||||
|
|
||||||
|
public record RootAmazon(
|
||||||
|
[property: JsonPropertyName("aggregations")] Aggregations Aggregations,
|
||||||
|
[property: JsonPropertyName("count")] int Count,
|
||||||
|
[property: JsonPropertyName("data")] IReadOnlyList<Datum> Data
|
||||||
|
);
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(RootAmazon))]
|
||||||
|
public partial class RootAmazonGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
16
Shared/Models/SearchData.cs
Normal file
16
Shared/Models/SearchData.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace View_by_Distance.Shared.Models;
|
||||||
|
|
||||||
|
public record SearchData(
|
||||||
|
[property: JsonPropertyName("clusterName")] string ClusterName,
|
||||||
|
[property: JsonPropertyName("locationId")] string LocationId,
|
||||||
|
[property: JsonPropertyName("locationInfo")] LocationInfo LocationInfo,
|
||||||
|
[property: JsonPropertyName("thingId")] string ThingId
|
||||||
|
);
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(SearchData))]
|
||||||
|
public partial class SearchDataGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
@ -35,7 +35,7 @@ internal abstract class Id
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static string GetIntelligentId(MetadataConfiguration metadataConfiguration, long id, bool ignore)
|
internal static string GetIntelligentId(MetadataConfiguration metadataConfiguration, long id, bool? ignore)
|
||||||
{
|
{
|
||||||
string result;
|
string result;
|
||||||
StringBuilder stringBuilder = new();
|
StringBuilder stringBuilder = new();
|
||||||
@ -46,12 +46,12 @@ internal abstract class Id
|
|||||||
List<char> resultAllInOneSubdirectoryChars = [];
|
List<char> resultAllInOneSubdirectoryChars = [];
|
||||||
if (id > -1)
|
if (id > -1)
|
||||||
{
|
{
|
||||||
key = ignore ? 8 : 9;
|
key = ignore is not null && ignore.Value ? 8 : 9;
|
||||||
value = id.ToString().PadLeft(metadataConfiguration.IntMinValueLength, '0');
|
value = id.ToString().PadLeft(metadataConfiguration.IntMinValueLength, '0');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
key = ignore ? 2 : 1;
|
key = ignore is not null && ignore.Value ? 2 : 1;
|
||||||
value = id.ToString()[1..].PadLeft(metadataConfiguration.IntMinValueLength, '0');
|
value = id.ToString()[1..].PadLeft(metadataConfiguration.IntMinValueLength, '0');
|
||||||
}
|
}
|
||||||
for (int i = value.Length - metadataConfiguration.ResultConfiguration.ResultAllInOneSubdirectoryLength - 1; i > -1; i--)
|
for (int i = value.Length - metadataConfiguration.ResultConfiguration.ResultAllInOneSubdirectoryLength - 1; i > -1; i--)
|
||||||
@ -62,14 +62,19 @@ internal abstract class Id
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static string GetPaddedId(MetadataConfiguration metadataConfiguration, int index, int id)
|
internal static string GetPaddedId(MetadataConfiguration metadataConfiguration, int id, bool? ignore, int? index)
|
||||||
{
|
{
|
||||||
string result;
|
string result;
|
||||||
string intelligentId = GetIntelligentId(metadataConfiguration, id, ignore: false);
|
if (metadataConfiguration.Offset < 0)
|
||||||
|
result = Guid.NewGuid().ToString();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string intelligentId = GetIntelligentId(metadataConfiguration, id, ignore);
|
||||||
int check = GetId(metadataConfiguration, intelligentId);
|
int check = GetId(metadataConfiguration, intelligentId);
|
||||||
if (check != id)
|
if (check != id)
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
result = $"{metadataConfiguration.Offset + index}{intelligentId}";
|
result = index is null || metadataConfiguration.Offset == 9876543 ? intelligentId : $"{metadataConfiguration.Offset + index}{intelligentId}";
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,15 +13,10 @@ public interface IId
|
|||||||
static int GetId(MetadataConfiguration metadataConfiguration, string intelligentId) =>
|
static int GetId(MetadataConfiguration metadataConfiguration, string intelligentId) =>
|
||||||
Id.GetId(metadataConfiguration, intelligentId);
|
Id.GetId(metadataConfiguration, intelligentId);
|
||||||
|
|
||||||
string TestStatic_GetPaddedId(MetadataConfiguration metadataConfiguration, int index, int id) =>
|
string TestStatic_GetPaddedId(MetadataConfiguration metadataConfiguration, int id, bool? ignore, int? index) =>
|
||||||
GetPaddedId(metadataConfiguration, index, id);
|
GetPaddedId(metadataConfiguration, id, ignore, index);
|
||||||
static string GetPaddedId(MetadataConfiguration metadataConfiguration, int index, int id) =>
|
static string GetPaddedId(MetadataConfiguration metadataConfiguration, int id, bool? ignore, int? index) =>
|
||||||
Id.GetPaddedId(metadataConfiguration, index, id);
|
Id.GetPaddedId(metadataConfiguration, id, ignore, index);
|
||||||
|
|
||||||
bool TestStatic_IsIgnore(FilePath filePath) =>
|
|
||||||
IsIgnore(filePath);
|
|
||||||
static bool IsIgnore(FilePath filePath) =>
|
|
||||||
filePath.FileNameFirstSegment[^1] is '2' or '8';
|
|
||||||
|
|
||||||
string TestStatic_GetIgnoreFullPath(FilePath filePath, FileHolder fileHolder) =>
|
string TestStatic_GetIgnoreFullPath(FilePath filePath, FileHolder fileHolder) =>
|
||||||
GetIgnoreFullPath(filePath, fileHolder);
|
GetIgnoreFullPath(filePath, fileHolder);
|
||||||
|
@ -6,7 +6,7 @@ namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
|||||||
public interface IRename
|
public interface IRename
|
||||||
{
|
{
|
||||||
|
|
||||||
(ReadOnlyCollection<string>, FilePath?) ConvertAndGetFfmpegFiles(IRenameConfiguration renameConfiguration, FilePath filePath);
|
ReadOnlyCollection<string> ConvertAndGetFfmpegFiles(IRenameConfiguration renameConfiguration, FilePath filePath);
|
||||||
DeterministicHashCode GetDeterministicHashCode(FilePath filePath);
|
DeterministicHashCode GetDeterministicHashCode(FilePath filePath);
|
||||||
void Tick();
|
void Tick();
|
||||||
|
|
||||||
|
@ -67,13 +67,21 @@ internal abstract class XDate
|
|||||||
foreach (QuickTimeMovieHeaderDirectory quickTimeMovieHeaderDirectory in exifDirectory.QuickTimeMovieHeaderDirectories)
|
foreach (QuickTimeMovieHeaderDirectory quickTimeMovieHeaderDirectory in exifDirectory.QuickTimeMovieHeaderDirectories)
|
||||||
{
|
{
|
||||||
if (quickTimeMovieHeaderDirectory.Created is not null)
|
if (quickTimeMovieHeaderDirectory.Created is not null)
|
||||||
|
{
|
||||||
|
if (quickTimeMovieHeaderDirectory.Created.Value.Year == 1904 && quickTimeMovieHeaderDirectory.Created.Value.Month == 1 && quickTimeMovieHeaderDirectory.Created.Value.Day == 1)
|
||||||
|
continue;
|
||||||
results.Add(quickTimeMovieHeaderDirectory.Created.Value);
|
results.Add(quickTimeMovieHeaderDirectory.Created.Value);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
foreach (QuickTimeTrackHeaderDirectory quickTimeTrackHeaderDirectory in exifDirectory.QuickTimeTrackHeaderDirectories)
|
foreach (QuickTimeTrackHeaderDirectory quickTimeTrackHeaderDirectory in exifDirectory.QuickTimeTrackHeaderDirectories)
|
||||||
{
|
{
|
||||||
if (quickTimeTrackHeaderDirectory.Created is not null)
|
if (quickTimeTrackHeaderDirectory.Created is not null)
|
||||||
|
{
|
||||||
|
if ((quickTimeTrackHeaderDirectory.Created.Value.Year is 1904 or 1970) && quickTimeTrackHeaderDirectory.Created.Value.Month == 1 && quickTimeTrackHeaderDirectory.Created.Value.Day == 1)
|
||||||
|
continue;
|
||||||
results.Add(quickTimeTrackHeaderDirectory.Created.Value);
|
results.Add(quickTimeTrackHeaderDirectory.Created.Value);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
result = results.Count == 0 ? null : results.Min();
|
result = results.Count == 0 ? null : results.Min();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -146,13 +154,21 @@ internal abstract class XDate
|
|||||||
foreach (QuickTimeMovieHeaderDirectory quickTimeMovieHeaderDirectory in exifDirectory.QuickTimeMovieHeaderDirectories)
|
foreach (QuickTimeMovieHeaderDirectory quickTimeMovieHeaderDirectory in exifDirectory.QuickTimeMovieHeaderDirectories)
|
||||||
{
|
{
|
||||||
if (quickTimeMovieHeaderDirectory.Created is not null)
|
if (quickTimeMovieHeaderDirectory.Created is not null)
|
||||||
|
{
|
||||||
|
if (quickTimeMovieHeaderDirectory.Created.Value.Year == 1904 && quickTimeMovieHeaderDirectory.Created.Value.Month == 1 && quickTimeMovieHeaderDirectory.Created.Value.Day == 1)
|
||||||
|
continue;
|
||||||
results.Add(quickTimeMovieHeaderDirectory.Created.Value);
|
results.Add(quickTimeMovieHeaderDirectory.Created.Value);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
foreach (QuickTimeTrackHeaderDirectory quickTimeTrackHeaderDirectory in exifDirectory.QuickTimeTrackHeaderDirectories)
|
foreach (QuickTimeTrackHeaderDirectory quickTimeTrackHeaderDirectory in exifDirectory.QuickTimeTrackHeaderDirectories)
|
||||||
{
|
{
|
||||||
if (quickTimeTrackHeaderDirectory.Created is not null)
|
if (quickTimeTrackHeaderDirectory.Created is not null)
|
||||||
|
{
|
||||||
|
if ((quickTimeTrackHeaderDirectory.Created.Value.Year is 1904 or 1970) && quickTimeTrackHeaderDirectory.Created.Value.Month == 1 && quickTimeTrackHeaderDirectory.Created.Value.Day == 1)
|
||||||
|
continue;
|
||||||
results.Add(quickTimeTrackHeaderDirectory.Created.Value);
|
results.Add(quickTimeTrackHeaderDirectory.Created.Value);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (results.Count == 0)
|
if (results.Count == 0)
|
||||||
{
|
{
|
||||||
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(exifDirectory.OriginalFileName);
|
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(exifDirectory.OriginalFileName);
|
||||||
|
15
Shared/Models/Thing.cs
Normal file
15
Shared/Models/Thing.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace View_by_Distance.Shared.Models;
|
||||||
|
|
||||||
|
public record Thing(
|
||||||
|
[property: JsonPropertyName("count")] int Count,
|
||||||
|
[property: JsonPropertyName("match")] string Match,
|
||||||
|
[property: JsonPropertyName("searchData")] SearchData SearchData
|
||||||
|
);
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(Thing))]
|
||||||
|
public partial class ThingGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
15
Shared/Models/Time.cs
Normal file
15
Shared/Models/Time.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace View_by_Distance.Shared.Models;
|
||||||
|
|
||||||
|
public record Time(
|
||||||
|
[property: JsonPropertyName("count")] int Count,
|
||||||
|
[property: JsonPropertyName("match")] string Match,
|
||||||
|
[property: JsonPropertyName("searchData")] SearchData SearchData
|
||||||
|
);
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(Time))]
|
||||||
|
public partial class TimeGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
15
Shared/Models/Type.cs
Normal file
15
Shared/Models/Type.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace View_by_Distance.Shared.Models;
|
||||||
|
|
||||||
|
public record Type(
|
||||||
|
[property: JsonPropertyName("count")] int Count,
|
||||||
|
[property: JsonPropertyName("match")] string Match,
|
||||||
|
[property: JsonPropertyName("searchData")] SearchData SearchData
|
||||||
|
);
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(Type))]
|
||||||
|
public partial class TypeGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
13
Shared/Models/XAccntParentMap.cs
Normal file
13
Shared/Models/XAccntParentMap.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace View_by_Distance.Shared.Models;
|
||||||
|
|
||||||
|
public record XAccntParentMap(
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
|
[JsonSerializable(typeof(XAccntParentMap))]
|
||||||
|
public partial class XAccntParentMapGenerationContext : JsonSerializerContext
|
||||||
|
{
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user