Documentation
¶
Overview ¶
Package lib implements libraries to sort media by date using exif and modtime information.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExifTimeGet ¶
ExifTimeGet accepts a filepath, returns the 'IFD/EXIF/DateTimeOriginal' contained in its metadata.
func ExtensionsMovie ¶
func ExtensionsMovie() []string
ExtensionsMovie returns the set of extensions for files that take a long time to extract "IFD/EXIF/DateTimeOriginal" so we only check modTime. Set includes: 3g2, 3gp, avi, m4v, mov, mp4, mpg, wmv.
func ExtensionsPhoto ¶
func ExtensionsPhoto() []string
ExtensionsPhoto returns set of supported Extensions that we process by checking "IFD/EXIF/DateTimeOriginal" data then if needed modTime.
Set includes: bmp, cr2, dng, gif, jpeg, jpg, nef, png, psd, raf, raw, tif, tiff.
func SynologySkip ¶
func SynologySkip() []string
SynologySkip returns the set of files or directories that contain strings we find on Synology file servers and ignore. The check is case insensitive.
Set includes: @eadir, @syno, synofile_thumb
Types ¶
type Action ¶
type Action int
Action user specifies to transfer files from src to dst.
const ( // ActionCopy : Copying files from src to dst ActionCopy Action = iota // ActionMove : Moving files from src to dst ActionMove // ActionNone : Error Value ActionNone )
User can specify how to transfer files from one directory to another.
func ActionParse ¶
ActionParse returns Action from string (must be lower case). Returns ActionNone if invalid.
type Merger ¶
type Merger struct { Merged map[string]string Errors map[string]string Removed []string // contains filtered or unexported fields }
Merger holds the API and statistics to merge sorted directories.
func NewMerger ¶
NewMerger returns a Merger to execute a merge of two sorted directories. src is the sorted directory to transfer from. dst is the sorted directory to transfer to. action is how to transfer files. filter is a regexp to use to filter which files to transfer
func (*Merger) Merge ¶
Merge performs several actions. It checks that its src and dst directories are correctly sorted and determines by what method for each. If the directories' sort methods don't match an error is returned. Src directory is walked and all files are transferred to the appropriate directory in dst. New directories are made if necessary. If the move action was specified then duplicate files are removd from src. If files have the same filename and end up in the same dst directory they will be renamed to not collide.
type Method ¶
type Method int
Method user specifies indexing and structuring sorted directories.
func MethodParse ¶
MethodParse returns Method from string (must be lower case). Returns MethodNone if invalid.
type Scanner ¶
type Scanner struct { Input ScannerInput SkippedCount int Data map[string]time.Time NumDataTypes map[string]int ExifErrors map[string]string NumExifErrorTypes map[string]int ScanErrors map[string]string }
Scanner is your API to scan directory of media.
It holds errors and data results of the scan after scanning.
func (*Scanner) ScanDir ¶
ScanDir will examine the contents of every file in the src directory and print it's time of creation as stored by exifdata as it scans.
ScanDir only scans media files listed as constants as documented, other files are skipped.
logger specifies where to send output while scanning.
func (*Scanner) ScanFile ¶
ScanFile accepts a filepath, reads the exifdata stored inside and returns the 'Exif/DateTimeOriginal' value as a golang time.Time format. If the exifData is not valid it will return the time based on FileInfo's ModTime.
It returns an error if the file has no exif data and cannot be statted.
type ScannerInput ¶
type ScannerInput int
ScannerInput specifies how scanner receives data
const ( // ScannerInputJSON : Input via JSON file ScannerInputJSON ScannerInput = iota // ScannerInputDir : Input via dir ScannerInputDir // ScannerInputNone : Error valueI ScannerInputNone )
type Sorter ¶
type Sorter struct { IndexErrors map[string]string TransferErrors map[string]string Duplicates []string // contains filtered or unexported fields }
Sorter is your API to perform sorting actions after a scan.
Sorting is composed of two stages. The first is "indexing", where the scanned data is organized by the specified method. The second is "transferring", where the media is transferred from the src to the dst directory.
It holds the index of sorted media and errors found in constructing or transferring it.
func NewSorter ¶
NewSorter creates the sorter based on the WalkState generated by a scan and the method desired to sort.
The structure of how it will organize the the dst directory is specified by 'method'. This routine will index via the method speficied.