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
@@ -295,6 +295,41 @@ public enum SpieltagGenerator {
|
||||
return all.filter { seen.insert($0.lowercased()).inserted }
|
||||
}
|
||||
|
||||
/// Teams from an IPTC event text without a Spieltag: "Bundesliga: Hamburger SV - Borussia Mönchengladbach"
|
||||
/// → ("Hamburger SV", "Borussia Mönchengladbach"). Also "vs.", "–" and "gegen".
|
||||
public static func teams(fromEvent event: String) -> (home: String, away: String)? {
|
||||
var s = event.trimmingCharacters(in: .whitespaces)
|
||||
if let colon = s.range(of: ": ") { s = String(s[colon.upperBound...]) }
|
||||
for sep in [" vs. ", " vs ", " - ", " – ", " gegen "] {
|
||||
let parts = s.components(separatedBy: sep)
|
||||
if parts.count == 2 {
|
||||
let h = parts[0].trimmingCharacters(in: .whitespaces)
|
||||
var a = parts[1].trimmingCharacters(in: .whitespaces)
|
||||
// "… vs. Gladbach, 06.11.2026" (headline style) → cut the date
|
||||
if let comma = a.range(of: ", ") { a = String(a[..<comma.lowerBound]) }
|
||||
if !h.isEmpty, !a.isEmpty { return (h, a) }
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
/// Variables of the match a photo belongs to – for album names and rename patterns:
|
||||
/// {home} {away} {homeshort} {awayshort} {homeabbr} {awayabbr} {competition} {round} {matchdate} {season} …
|
||||
/// plus German aliases {heim} {gast} {vereina} {vereinb}.
|
||||
public static func matchVariables(event: String, library: SpieltagLibrary) -> [String: String] {
|
||||
var v: [String: String] = [:]
|
||||
if let m = library.match(forEvent: event), let h = library.team(m.homeID), let a = library.team(m.awayID) {
|
||||
v = context(match: m, home: h, away: a, competition: library.competition(m.competitionID), patterns: library.patterns)
|
||||
} else if let t = teams(fromEvent: event) {
|
||||
v = ["home": t.home, "away": t.away, "homeshort": t.home, "awayshort": t.away]
|
||||
}
|
||||
if let h = v["home"], let a = v["away"] {
|
||||
v["heim"] = h; v["gast"] = a; v["vereina"] = h; v["vereinb"] = a
|
||||
v["teama"] = h; v["teamb"] = a
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
/// Folder name for the ingest (no path separators).
|
||||
public static func folderName(patterns: SpieltagPatterns, ctx: [String: String]) -> String {
|
||||
fill(patterns.folder, ctx).replacingOccurrences(of: "/", with: "-").replacingOccurrences(of: ":", with: "-")
|
||||
|
||||
Reference in new issue
Block a user