Trikot-Vorschlag nur in die Beschreibung; LR-Plugin automatisch aktualisieren
- Annehmen trägt den Spieler nur in die erste Zeile der Beschreibung ein, nicht mehr in „Persons shown“ (zuschaltbar in der Trikot-Erkennung) - Matchday-Spielerliste erkennt angenommene Spieler:innen auch aus der ersten Beschreibungszeile - veraltetes Lichtkasten-Bridge-Plugin in Lightroom wird beim Start ersetzt (Hinweis: LR neu starten) – ohne die neue Version fehlte die Zuordnung der Exporte, IPTC wurde nicht zurückgeschrieben und die Leerzeilen (Platzhalter für die Personen) oben in der Beschreibung fehlten 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
b9d7ea3146
commit
bfaea219c6
5 files changed
+45
-4
No files matched your search
@@ -233,6 +233,7 @@ final class AppState: ObservableObject {
|
||||
}
|
||||
seedDefaultsIfNeeded()
|
||||
startLightroomPolling()
|
||||
updateLightroomPluginIfNeeded()
|
||||
// PM "Automatically reload code replacement files when they change"
|
||||
codeReloadTimer = Timer.scheduledTimer(withTimeInterval: 5, repeats: true) { [weak self] _ in
|
||||
Task { @MainActor in
|
||||
@@ -1153,6 +1154,24 @@ final class AppState: ObservableObject {
|
||||
}
|
||||
}
|
||||
|
||||
/// A newer Lichtkasten brings a newer Lightroom plugin (e.g. source paths for the export) – an old one in
|
||||
/// Lightroom's Modules folder is replaced automatically, so the export mapping works without manual steps.
|
||||
private func updateLightroomPluginIfNeeded() {
|
||||
guard LightroomBridge.pluginInstalled,
|
||||
let bundled = Bundle.main.url(forResource: "LichtkastenBridge", withExtension: "lrplugin") else { return }
|
||||
let installed = LightroomBridge.lightroomModulesFolder.appendingPathComponent("LichtkastenBridge.lrplugin")
|
||||
let files = (try? FileManager.default.contentsOfDirectory(atPath: bundled.path)) ?? []
|
||||
let differs = files.contains { name in
|
||||
(try? Data(contentsOf: bundled.appendingPathComponent(name))) != (try? Data(contentsOf: installed.appendingPathComponent(name)))
|
||||
}
|
||||
guard differs else { return }
|
||||
do {
|
||||
try LightroomBridge.installPlugin(from: bundled)
|
||||
alert = AppAlert(title: "Lightroom-Plugin aktualisiert",
|
||||
message: "Die Lichtkasten Bridge in Lightroom Classic wurde auf die neue Version gebracht. Bitte Lightroom Classic einmal neu starten.")
|
||||
} catch { report(error) }
|
||||
}
|
||||
|
||||
private func startLightroomPolling() {
|
||||
lrPollTimer = Timer.scheduledTimer(withTimeInterval: 2, repeats: true) { [weak self] _ in
|
||||
Task { @MainActor in self?.pollLightroom() }
|
||||
@@ -1605,6 +1624,8 @@ final class AppState: ObservableObject {
|
||||
var v = values
|
||||
let reps = suggestions.compactMap(\.replacement)
|
||||
v.text["caption"] = JerseyLogic.insertIntoCaption(v.text["caption"] ?? "", names: reps, separator: settings.jersey.separator)
|
||||
// "Persons shown" only if switched on – by default the player goes into the caption only
|
||||
guard settings.jersey.writePersonsShown else { return v }
|
||||
var persons = v.lists["personInImage"] ?? []
|
||||
for s in suggestions {
|
||||
guard let rep = s.replacement, let code = s.code else { continue }
|
||||
@@ -1618,7 +1639,7 @@ final class AppState: ObservableObject {
|
||||
/// Accept directly (contact sheet / context menu): writes caption + persons and marks as done.
|
||||
func acceptSuggestions(_ s: [JerseySuggestion], for item: PhotoItem) {
|
||||
guard !s.isEmpty else { return }
|
||||
let fields = ["caption", "personInImage"].compactMap { IPTCField.byID[$0] }
|
||||
let fields = (settings.jersey.writePersonsShown ? ["caption", "personInImage"] : ["caption"]).compactMap { IPTCField.byID[$0] }
|
||||
let values = applying(s, to: item.iptc)
|
||||
Task {
|
||||
if await applyIPTCAndWait(values, fields: fields, to: [item]) {
|
||||
@@ -1678,6 +1699,21 @@ final class AppState: ObservableObject {
|
||||
let number = code.flatMap { c in Int(c.drop { !$0.isNumber }) }
|
||||
return PlayerInfo(name: name, number: number, team: code.flatMap { team(forCode: $0, in: teamsOfPhoto) }, confirmed: true)
|
||||
}
|
||||
// accepted players now only live in the first caption line → find a known player name there
|
||||
let firstLine = (item.iptc.text["caption"] ?? "").components(separatedBy: "\n").first ?? ""
|
||||
if !firstLine.trimmingCharacters(in: .whitespaces).isEmpty {
|
||||
for t in teamsOfPhoto {
|
||||
guard let set = t.codeSetID.flatMap({ id in codeLibrary.sets.first { $0.id == id } }) else { continue }
|
||||
for e in set.entries {
|
||||
guard let rep = e.columns.first else { continue }
|
||||
let name = JerseyLogic.personName(replacement: rep, columns: e.columns)
|
||||
if name.count > 3, firstLine.contains(name) {
|
||||
let number = Int(e.code.drop { !$0.isNumber })
|
||||
return PlayerInfo(name: name, number: number, team: t, confirmed: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if let s = openSuggestions(for: item.id).first, let rep = s.replacement {
|
||||
let name = JerseyLogic.personName(replacement: rep, columns: codes.table[(s.code ?? "").lowercased()] ?? [])
|
||||
let team = (teamsOfPhoto + settings.jersey.teams).first { $0.id == s.teamID }
|
||||
|
||||
@@ -68,7 +68,7 @@ struct LightroomSettings: Codable, Hashable {
|
||||
/// Jersey number recognition settings (teams of the current match).
|
||||
struct JerseySettings: Codable, Hashable {
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case teams, useShirt, useShorts, minConfidence, autoAfterIngest, separator
|
||||
case teams, useShirt, useShorts, minConfidence, autoAfterIngest, separator, writePersonsShown
|
||||
case matchday = "matchdayEnabled" // new key: the old default (on) is not carried over
|
||||
}
|
||||
|
||||
@@ -78,6 +78,8 @@ struct JerseySettings: Codable, Hashable {
|
||||
var minConfidence = 0.35
|
||||
var autoAfterIngest = false
|
||||
var separator = ", "
|
||||
/// Accepted players also go into "Persons shown" (off: only the first line of the caption)
|
||||
var writePersonsShown = false
|
||||
/// Matchday view (team header, player list, team-colored cards) – opt-in, needs two teams
|
||||
var matchday = false
|
||||
|
||||
@@ -91,6 +93,7 @@ struct JerseySettings: Codable, Hashable {
|
||||
minConfidence = (try? c.decode(Double.self, forKey: .minConfidence)) ?? d.minConfidence
|
||||
autoAfterIngest = (try? c.decode(Bool.self, forKey: .autoAfterIngest)) ?? d.autoAfterIngest
|
||||
separator = (try? c.decode(String.self, forKey: .separator)) ?? d.separator
|
||||
writePersonsShown = (try? c.decode(Bool.self, forKey: .writePersonsShown)) ?? d.writePersonsShown
|
||||
matchday = (try? c.decode(Bool.self, forKey: .matchday)) ?? d.matchday
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ struct IPTCInfoWindow: View {
|
||||
}
|
||||
}
|
||||
|
||||
/// Fills caption (first line) and "Persons shown" in the form – saved with ⌘B / OK as usual.
|
||||
/// Fills the first caption line (and "Persons shown" if switched on) in the form – saved with ⌘B / OK as usual.
|
||||
private func accept(_ s: [JerseySuggestion]) {
|
||||
guard let item else { return }
|
||||
let updated = state.applying(s, to: IPTCValues(texts: texts))
|
||||
|
||||
@@ -110,6 +110,8 @@ struct JerseySetupView: View {
|
||||
TextField("", text: jersey.separator).frame(width: 60).textFieldStyle(.roundedBorder)
|
||||
}
|
||||
Toggle("Nach dem Ingest automatisch erkennen", isOn: jersey.autoAfterIngest)
|
||||
Toggle("Angenommene Spieler:innen zusätzlich in „Persons shown“ eintragen", isOn: jersey.writePersonsShown)
|
||||
.help("Aus: nur in die erste Zeile der Beschreibung (Standard)")
|
||||
}
|
||||
.padding(6)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user