Skip to content

Commit 6b608e8

Browse files
committed
feat: add commands to handle iCloud and Picasa album imports
1 parent ca2107e commit 6b608e8

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

adapters/folder/options.go

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ func (o *ImportFolderOptions) AddFromFolderFlags(cmd *cobra.Command, parent *cob
103103
`/._*`, // MacOS resource files
104104
`.photostructure/`, // PhotoStructure
105105
)
106+
107+
o.ICloudTakeout = false
108+
o.PicasaAlbum = false
106109
cmd.Flags().StringVar(&o.ImportIntoAlbum, "into-album", "", "Specify an album to import all files into")
107110
cmd.Flags().Var(&o.UsePathAsAlbumName, "folder-as-album", "Import all files in albums defined by the folder structure. Can be set to 'FOLDER' to use the folder name as the album name, or 'PATH' to use the full path as the album name")
108111
cmd.Flags().StringVar(&o.AlbumNamePathSeparator, "album-path-joiner", " / ", "Specify a string to use when joining multiple folder names to create an album name (e.g. ' ',' - ')")
@@ -130,6 +133,86 @@ func (o *ImportFolderOptions) AddFromFolderFlags(cmd *cobra.Command, parent *cob
130133
}
131134
}
132135

136+
func (o *ImportFolderOptions) AddFromICloudFlags(cmd *cobra.Command, parent *cobra.Command) {
137+
o.ManageHEICJPG = filters.HeicJpgNothing
138+
o.ManageRawJPG = filters.RawJPGNothing
139+
o.ManageBurst = filters.BurstNothing
140+
o.Recursive = true
141+
o.SupportedMedia = filetypes.DefaultSupportedMedia
142+
o.UsePathAsAlbumName = FolderModeNone
143+
o.BannedFiles, _ = namematcher.New(
144+
`@eaDir/`,
145+
`@__thumb/`, // QNAP
146+
`SYNOFILE_THUMB_*.*`, // SYNOLOGY
147+
`Lightroom Catalog/`, // LR
148+
`thumbnails/`, // Android photo
149+
`.DS_Store/`, // Mac OS custom attributes
150+
`/._*`, // MacOS resource files
151+
`.photostructure/`, // PhotoStructure
152+
)
153+
154+
o.ICloudTakeout = true
155+
o.PicasaAlbum = false
156+
cmd.Flags().StringVar(&o.ImportIntoAlbum, "into-album", "", "Specify an album to import all files into")
157+
158+
cmd.Flags().Var(&o.BannedFiles, "ban-file", "Exclude a file based on a pattern (case-insensitive). Can be specified multiple times.")
159+
cmd.Flags().StringSliceVar(&o.Tags, "tag", nil, "Add tags to the imported assets. Can be specified multiple times. Hierarchy is supported using a / separator (e.g. 'tag1/subtag1')")
160+
cmd.Flags().BoolVar(&o.SessionTag, "session-tag", false, "Tag uploaded photos with a tag \"{immich-go}/YYYY-MM-DD HH-MM-SS\"")
161+
162+
cliflags.AddInclusionFlags(cmd, &o.InclusionFlags)
163+
cmd.Flags().BoolVar(&o.TakeDateFromFilename, "date-from-name", true, "Use the date from the filename if the date isn't available in the metadata (Only for jpg, mp4, heic, dng, cr2, cr3, arw, raf, nef, mov)")
164+
165+
if parent != nil && parent.Name() == "upload" {
166+
cmd.Flags().Var(&o.ManageHEICJPG, "manage-heic-jpeg", "Manage coupled HEIC and JPEG files. Possible values: NoStack, KeepHeic, KeepJPG, StackCoverHeic, StackCoverJPG")
167+
cmd.Flags().Var(&o.ManageRawJPG, "manage-raw-jpeg", "Manage coupled RAW and JPEG files. Possible values: NoStack, KeepRaw, KeepJPG, StackCoverRaw, StackCoverJPG")
168+
cmd.Flags().Var(&o.ManageBurst, "manage-burst", "Manage burst photos. Possible values: NoStack, Stack, StackKeepRaw, StackKeepJPEG")
169+
}
170+
}
171+
172+
func (o *ImportFolderOptions) AddFromPicasaFlags(cmd *cobra.Command, parent *cobra.Command) {
173+
o.ManageHEICJPG = filters.HeicJpgNothing
174+
o.ManageRawJPG = filters.RawJPGNothing
175+
o.ManageBurst = filters.BurstNothing
176+
o.Recursive = true
177+
o.SupportedMedia = filetypes.DefaultSupportedMedia
178+
o.UsePathAsAlbumName = FolderModeNone
179+
o.BannedFiles, _ = namematcher.New(
180+
`@eaDir/`,
181+
`@__thumb/`, // QNAP
182+
`SYNOFILE_THUMB_*.*`, // SYNOLOGY
183+
`Lightroom Catalog/`, // LR
184+
`thumbnails/`, // Android photo
185+
`.DS_Store/`, // Mac OS custom attributes
186+
`/._*`, // MacOS resource files
187+
`.photostructure/`, // PhotoStructure
188+
)
189+
190+
o.ICloudTakeout = false
191+
o.PicasaAlbum = true
192+
cmd.Flags().StringVar(&o.ImportIntoAlbum, "into-album", "", "Specify an album to import all files into")
193+
cmd.Flags().Var(&o.UsePathAsAlbumName, "folder-as-album", "Import all files in albums defined by the folder structure. Can be set to 'FOLDER' to use the folder name as the album name, or 'PATH' to use the full path as the album name")
194+
cmd.Flags().StringVar(&o.AlbumNamePathSeparator, "album-path-joiner", " / ", "Specify a string to use when joining multiple folder names to create an album name (e.g. ' ',' - ')")
195+
cmd.Flags().BoolVar(&o.Recursive, "recursive", true, "Explore the folder and all its sub-folders")
196+
cmd.Flags().Var(&o.BannedFiles, "ban-file", "Exclude a file based on a pattern (case-insensitive). Can be specified multiple times.")
197+
cmd.Flags().BoolVar(&o.IgnoreSideCarFiles, "ignore-sidecar-files", false, "Don't upload sidecar with the photo.")
198+
199+
cmd.Flags().StringSliceVar(&o.Tags, "tag", nil, "Add tags to the imported assets. Can be specified multiple times. Hierarchy is supported using a / separator (e.g. 'tag1/subtag1')")
200+
cmd.Flags().BoolVar(&o.FolderAsTags, "folder-as-tags", false, "Use the folder structure as tags, (ex: the file holiday/summer 2024/file.jpg will have the tag holiday/summer 2024)")
201+
cmd.Flags().BoolVar(&o.SessionTag, "session-tag", false, "Tag uploaded photos with a tag \"{immich-go}/YYYY-MM-DD HH-MM-SS\"")
202+
203+
cliflags.AddInclusionFlags(cmd, &o.InclusionFlags)
204+
cmd.Flags().BoolVar(&o.TakeDateFromFilename, "date-from-name", true, "Use the date from the filename if the date isn't available in the metadata (Only for jpg, mp4, heic, dng, cr2, cr3, arw, raf, nef, mov)")
205+
206+
// exif.AddExifToolFlags(cmd, &o.ExifToolFlags) // disabled for now
207+
208+
// upload specific flags, not for archive to folder
209+
if parent != nil && parent.Name() == "upload" {
210+
cmd.Flags().Var(&o.ManageHEICJPG, "manage-heic-jpeg", "Manage coupled HEIC and JPEG files. Possible values: NoStack, KeepHeic, KeepJPG, StackCoverHeic, StackCoverJPG")
211+
cmd.Flags().Var(&o.ManageRawJPG, "manage-raw-jpeg", "Manage coupled RAW and JPEG files. Possible values: NoStack, KeepRaw, KeepJPG, StackCoverRaw, StackCoverJPG")
212+
cmd.Flags().Var(&o.ManageBurst, "manage-burst", "Manage burst photos. Possible values: NoStack, Stack, StackKeepRaw, StackKeepJPEG")
213+
}
214+
}
215+
133216
// AlbumFolderMode represents the mode in which album folders are organized.
134217
// Implement the interface pflag.Value
135218

0 commit comments

Comments
 (0)