Vereins-Variablen für Immich-Album und Umbenennen
{vereina}/{vereinb} (= {home}/{away}, {heim}/{gast}), {homeshort}/{awayshort}, {competition}, {round},
{season} … aus dem Spieltag des Bildes oder aus dem IPTC-Ereignis („Liga: A - B“). Gilt für das
Immich-Album und das FTP-Umbenennungsmuster, z. B. „{vereina} - {vereinb} | {date}“.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012bGzgsxrmbBhDzeMV2L57D
This commit is contained in:
1 parent
3a2c8253ac
commit
fff701674a
5 files changed
+62
-3
No files matched your search
@@ -1156,7 +1156,8 @@ final class AppState: ObservableObject {
|
||||
func immichAlbum(for item: PhotoItem) -> String {
|
||||
func resolve(_ pattern: String) -> String {
|
||||
guard !pattern.isEmpty else { return "" }
|
||||
let ctx = VariableContext.make(fileURL: item.primary, exif: item.exif, iptc: item.iptc, dateFormat: settings.dateFormat)
|
||||
var ctx = VariableContext.make(fileURL: item.primary, exif: item.exif, iptc: item.iptc, dateFormat: settings.dateFormat)
|
||||
ctx.values.merge(matchVariables(for: item)) { iptc, _ in iptc } // IPTC values win (city, …)
|
||||
var s = VariableExpander.expand(pattern, context: ctx, codes: nil)
|
||||
// drop variables that had no value, tidy separators
|
||||
while let open = s.firstIndex(of: "{"), let close = s[open...].firstIndex(of: "}") { s.removeSubrange(open...close) }
|
||||
@@ -1166,6 +1167,11 @@ final class AppState: ObservableObject {
|
||||
return main.isEmpty ? resolve(settings.immich.albumFallback) : main
|
||||
}
|
||||
|
||||
/// {home}/{away} (= {vereina}/{vereinb}) … of a photo: from its Spieltag, else read from the IPTC event.
|
||||
func matchVariables(for item: PhotoItem) -> [String: String] {
|
||||
SpieltagGenerator.matchVariables(event: (self.item(item.id) ?? item).iptc.text["event"] ?? "", library: spieltag)
|
||||
}
|
||||
|
||||
/// Files to upload for an item, depending on the destination's variant.
|
||||
func uploadFiles(for item: PhotoItem, variant: UploadVariant) -> [URL] {
|
||||
switch variant {
|
||||
|
||||
@@ -134,8 +134,9 @@ final class UploadQueue: ObservableObject {
|
||||
let src = sourceItems.first { $0.primary == f || $0.companions.contains(f) }
|
||||
var remote = f.lastPathComponent
|
||||
if !pattern.isEmpty {
|
||||
let ctx = VariableContext.make(fileURL: f, exif: src?.exif ?? [:], iptc: src?.iptc ?? IPTCValues(),
|
||||
var ctx = VariableContext.make(fileURL: f, exif: src?.exif ?? [:], iptc: src?.iptc ?? IPTCValues(),
|
||||
dateFormat: state.settings.dateFormat)
|
||||
if let src { ctx.values.merge(state.matchVariables(for: src)) { iptc, _ in iptc } }
|
||||
remote = VariableExpander.expand(pattern, context: ctx)
|
||||
.replacingOccurrences(of: "/", with: "-") + "." + f.pathExtension.lowercased()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user