IntelligentIdRecord
This commit is contained in:
@ -54,8 +54,7 @@ public class Rename : IRename
|
||||
else
|
||||
{
|
||||
CommandTask<CommandResult> commandTask = Cli.Wrap("ffmpeg.exe")
|
||||
// .WithArguments(new[] { "-ss", "00:00:00", "-t", "00:00:00", "-i", files[i], "-qScale:v", "2", "-r", "0.01", $"{fileHolder.Name}-%4d.jpg" })
|
||||
.WithArguments(new[] { "-i", filePath.FullName, "-vFrames", "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)
|
||||
.ExecuteAsync();
|
||||
commandTask.Task.Wait();
|
||||
@ -122,7 +121,7 @@ public class Rename : IRename
|
||||
{
|
||||
rename.Tick();
|
||||
filePath = IId.GetFilePath(renameConfiguration.MetadataConfiguration, file);
|
||||
if (renameConfiguration.SkipIdFiles && filePath.Id is not null && (filePath.IsIdFormat || filePath.IsPaddedIdFormat))
|
||||
if (renameConfiguration.SkipIdFiles && filePath.Id is not null && (filePath.IsIntelligentIdFormat || filePath.SortOrder is not null))
|
||||
continue;
|
||||
(ffmpegFiles, ffmpegFilePath) = rename.ConvertAndGetFfmpegFiles(renameConfiguration, filePath);
|
||||
if (ffmpegFilePath is not null)
|
||||
@ -173,13 +172,13 @@ public class Rename : IRename
|
||||
return results;
|
||||
}
|
||||
|
||||
private static void VerifyIntMinValueLength(ReadOnlyCollection<Record> exifDirectories, int intMinValueLength)
|
||||
private static void VerifyIntMinValueLength(MetadataConfiguration metadataConfiguration, ReadOnlyCollection<Record> exifDirectories)
|
||||
{
|
||||
foreach ((DateTime _, ExifDirectory exifDirectory, string _, string _) in exifDirectories)
|
||||
{
|
||||
if (exifDirectory.Id is null)
|
||||
continue;
|
||||
if (intMinValueLength < exifDirectory.Id.Value.ToString().Length)
|
||||
if (metadataConfiguration.IntMinValueLength < exifDirectory.Id.Value.ToString().Length)
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
@ -189,11 +188,20 @@ public class Rename : IRename
|
||||
string? checkDirectory;
|
||||
if (fileHolder.DirectoryName is null)
|
||||
throw new NullReferenceException(nameof(fileHolder.DirectoryName));
|
||||
(int season, string seasonName) = IDate.GetSeason(record.DateTime.DayOfYear);
|
||||
string maker = IMetadata.GetMaker(record.ExifDirectory.ExifDirectoryBase);
|
||||
string splat = fileHolder.DirectoryName[^3..][1] == '!' ? fileHolder.DirectoryName[^3..] : string.Empty;
|
||||
string directoryName;
|
||||
string year = record.DateTime.Year.ToString();
|
||||
string checkDirectoryName = Path.GetFileName(fileHolder.DirectoryName);
|
||||
if (!checkDirectoryName.Contains(year))
|
||||
throw new NotImplementedException();
|
||||
else
|
||||
{
|
||||
string maker = IMetadata.GetMaker(record.ExifDirectory.ExifDirectoryBase);
|
||||
(int seasonValue, string seasonName) = IDate.GetSeason(record.DateTime.DayOfYear);
|
||||
string splat = fileHolder.DirectoryName[^3..][1] == '!' ? fileHolder.DirectoryName[^3..] : string.Empty;
|
||||
directoryName = $"{year}.{seasonValue} {seasonName} {maker.Split(' ')[0]}{splat}";
|
||||
}
|
||||
string rootDirectory = renameConfiguration.MoveFilesToRoot ? renameConfiguration.MetadataConfiguration.ResultConfiguration.RootDirectory : fileHolder.DirectoryName;
|
||||
checkDirectory = Path.Combine(rootDirectory, "_ Destination _", $"{record.DateTime.Year}.{season} {seasonName} {maker.Split(' ')[0]}{splat}");
|
||||
checkDirectory = Path.Combine(rootDirectory, "_ Destination _", directoryName);
|
||||
return checkDirectory;
|
||||
}
|
||||
|
||||
@ -212,8 +220,7 @@ public class Rename : IRename
|
||||
List<string> distinct = [];
|
||||
const string jpeg = ".jpeg";
|
||||
string jsonFileSubDirectory;
|
||||
int intMinValueLength = int.MinValue.ToString().Length;
|
||||
VerifyIntMinValueLength(exifDirectories, intMinValueLength);
|
||||
VerifyIntMinValueLength(renameConfiguration.MetadataConfiguration, exifDirectories);
|
||||
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++)
|
||||
@ -226,8 +233,8 @@ public class Rename : IRename
|
||||
continue;
|
||||
checkDirectory = GetCheckDirectory(renameConfiguration, record, fileHolder);
|
||||
checkFileExtension = fileHolder.ExtensionLowered == jpeg ? jpg : fileHolder.ExtensionLowered;
|
||||
paddedId = IId.GetPaddedId(renameConfiguration.MetadataConfiguration, i, record.ExifDirectory.Id.Value);
|
||||
jsonFileSubDirectory = Path.GetDirectoryName(Path.GetDirectoryName(record.JsonFile)) ?? throw new Exception();
|
||||
paddedId = IId.GetPaddedId(intMinValueLength, renameConfiguration.MetadataConfiguration.Offset + i, record.ExifDirectory.Id.Value);
|
||||
checkFile = Path.Combine(checkDirectory, $"{paddedId}{checkFileExtension}");
|
||||
if (checkFile == fileHolder.FullName)
|
||||
continue;
|
||||
|
Reference in New Issue
Block a user