private DngImageFile( CameraFilePath fullName, DateTime created) : base(fullName) { Created = created; }
private Result <ICameraFile> GetCameraFile( CameraFilePath cameraFilePath) { var metadataTags = _metadataReader.ExtractTags(cameraFilePath); return(_cameraFileFactory.Create(cameraFilePath, metadataTags)); }
internal Result TransferFile(Args args) { var convertResult = _cameraFileNameConverter.Convert(args); if (convertResult.IsFailure) { return(convertResult); } var(destinationDirectory, destinationFileName) = convertResult.Value; if (!_fileSystem.Directory.Exists(destinationDirectory) && !args.DryRun) { _fileSystem.Directory.CreateDirectory(destinationDirectory); OnDirectoryCreated(this, destinationDirectory); } var destinationFilePath = new CameraFilePath(_fileSystem.Path.Combine(destinationDirectory, destinationFileName)); var destinationAlreadyExists = _fileSystem.File.Exists(destinationFilePath); if (destinationAlreadyExists && !args.Overwrite) { OnFileSkipped(this, (args.CameraFilePath, destinationFilePath)); return(Result.Success()); } if (!args.DryRun) { _transferFiles(args.CameraFilePath, destinationFilePath, args.Overwrite); } OnFileTransferred(this, (args.CameraFilePath, destinationFilePath, args.DryRun)); return(Result.Success()); }
private VideoFile( CameraFilePath fullName, DateTime created) : base(fullName) { Created = created; }
internal void HandleException( CameraFilePath sourceCameraFilePath, Exception exception) { WriteLine( $"Failed {sourceCameraFilePath}: {exception.Message}", ConsoleColor.Red); }
internal void HandleFileSkipped( CameraFilePath sourcePath, CameraFilePath destinationPath) { WriteLine( $"Skipped {sourcePath} ({destinationPath} already exists)", ConsoleColor.Yellow); }
protected AbstractCameraFile( CameraFilePath fullName) { if (string.IsNullOrWhiteSpace(fullName)) { throw new ArgumentException("Value cannot be null or whitespace.", nameof(fullName)); } FullName = fullName; Extension = fullName.GetExtension(); if (string.IsNullOrWhiteSpace(Extension)) { throw new ArgumentException($"File {fullName} has no extension", nameof(fullName)); } }
internal Result <ICameraFile> Create( CameraFilePath filePath, IEnumerable <ITag> metadata) { switch (filePath.GetExtension().ToLowerInvariant()) { case ".jpg": case ".jpeg": case ".cr2": return(ImageFile.Create(filePath, metadata)); case ".dng": return(DngImageFile.Create(filePath, metadata)); case ".mp4": case ".mov": return(VideoFile.Create(filePath, metadata)); default: throw new InvalidPathException($"Unknown file type {filePath}"); } }
internal static Result <ICameraFile> Create( CameraFilePath fullName, IEnumerable <ITag> exifTags) { var dateTimeOriginal = exifTags.FirstOrDefault(t => t.Type == DateTimeOriginalTagType); if (dateTimeOriginal is null) { return(Result.Failure <ICameraFile>("Metadata not found")); } if (DateTime.TryParseExact( dateTimeOriginal.Value, "yyyy:MM:dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out var parsedDateTime)) { return(new DngImageFile(fullName, parsedDateTime)); } return(Result.Failure <ICameraFile>("Invalid metadata")); }
public static Result <ICameraFile> Create( CameraFilePath fullName, IEnumerable <ITag> exifTags) { var enumeratedExifTags = exifTags.ToList(); var dateTimeOriginalResult = FindCreatedDateTimeTag(enumeratedExifTags); if (dateTimeOriginalResult.IsFailure) { return(Result.Failure <ICameraFile>(dateTimeOriginalResult.Error)); } var parsedDateTimeResult = ParseCreatedDateTime(dateTimeOriginalResult.Value); if (parsedDateTimeResult.IsFailure) { return(Result.Failure <ICameraFile>(parsedDateTimeResult.Error)); } return(new ImageFile( fullName, parsedDateTimeResult.Value.Add(FindSubSeconds(enumeratedExifTags)))); }
internal static Result <ICameraFile> Create( CameraFilePath fullName, IEnumerable <ITag> exifTags) { var createdTag = exifTags.FirstOrDefault(t => t.Directory == "QuickTime Movie Header" && t.Type == QuickTimeCreatedTag); if (createdTag is null) { return(Result.Failure <ICameraFile>("Metadata not found")); } if (DateTime.TryParseExact( createdTag.Value, "ddd MMM dd HH.mm.ss yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out var parsedDateTime)) { return(new VideoFile(fullName, parsedDateTime)); } return(Result.Failure <ICameraFile>("Invalid metadata")); }
IEnumerable <ITag> IMetadataReader.ExtractTags(CameraFilePath filePath) { return(ImageMetadataReader.ReadMetadata(filePath) .SelectMany(tagDirectory => tagDirectory.Tags) .Select(tag => new MetadataExtractorTagAdapter(tag))); }
internal void HandleFileMoved( CameraFilePath sourcePath, CameraFilePath destinationPath) { WriteLine($"{sourcePath} -> {destinationPath}"); }