Codebase

  • Scriptstruktur (bsp. Python)

import pandas as pd
from geniusdecoder.pipelines import run_full_pipeline_for_message  # dein großer Pipeline-Entry
from geniusdecoder.rules import run_all_once
from geniusdecoder.compute import compute_excel_equiv_vars  # deine BP/Z-Berechnung
from geniusdecoder.utils import clean_lyrics_basic

def process_song(row, genius_token, sp, rules_path: str) -> dict:
    """
    Nimmt eine Excel-Zeile (Titel, Interpret, Datum, Spieldauer, I-Key, …),
    holt Lyrics/Meta, berechnet BP/Z, läuft die Pipeline durch
    und gibt ein dict mit allen relevanten Feldern zurück.
    """
    title   = str(row.get("Titel") or "").strip()
    artist  = str(row.get("Interpret") or "").strip()
    addkey  = str(row.get("I-Key") or "").strip()
    date    = row.get("Datum")  # z.B. Excel-Date / String
    dur_raw = row.get("Spieldauer")

    if not title or not artist:
        return {}

    # 1) Meta holen (Genius / Excel)
    song_obj = genius_songsearch(title, artist)  # deine Funktion
    meta     = get_genius_release_meta_by_id(song_obj.id, genius_token) if song_obj else \
               get_genius_release_meta(title, artist, genius_token)

    # Datum & Dauer aufbereiten
    y, m, d = coalesce_date(meta, row)  # Deine coalesce_date/parse_excel_date Logik
    dur_ms  = parse_duration_to_ms(dur_raw) or spotify_duration_any(sp, title, artist, row.get("SpotifyURL"))

    # 2) Steuerwerte (BP/Z) berechnen
    calc = compute_excel_equiv_vars(title, y, m, d, dur_ms, hour_mode="minutes")
    intruder  = [calc[f"BP{i}"] for i in range(1, 7)]
    extractor = [calc[f"Z{i}"]  for i in range(1, 7)]

    # 3) Lyrics holen & vorbereiten
    lyrics = song_obj.lyrics if song_obj and getattr(song_obj, "lyrics", "") else ""
    text_lines = clean_lyrics_basic(lyrics)
    if not text_lines:
        return {}

    # 4) Voll-Pipeline laufen lassen (dein Monster-Setup)
    # ggf. Parameter wie alpha1, alpha2, board_header etc. aus CONFIG/addkey/intruder/extractor bauen
    l2_plain = run_full_pipeline_for_message(
        lyrics_text=lyrics,
        title=title,
        date_iso=f"{y:04d}-{m:02d}-{d:02d}" if y and m and d else "",
        time_str=None,  # falls du Dauer in Sekunden/MM:SS brauchst, hier formatieren
        alpha1="ABCDEFHILNOPRSTVGJKMQUXYZ",
        alpha2="0e9lV_nCxXZSIPXfkVVBMO_fg",
        use_bazeries=True,
        baz_mode="decrypt",
        use_rail=True,
        use_full_text=False,
        extra_text=None,
    )

    # 5) Rules anwenden (z.B. MAIN/CAPS)
    msg_main = run_all_once(l2_plain, ruleset="MAIN")
    msg_caps = run_all_once(l2_plain, ruleset="CAPS")

    # 6) Alles in ein Ergebnis-Dict packen
    result = {
        "title": title,
        "artist": artist,
        "date_iso": f"{y:04d}-{m:02d}-{d:02d}" if y and m and d else "",
        "duration_ms": dur_ms,
        "bp": intruder,
        "z": extractor,
        "raw_lyrics": lyrics,
        "message_main": msg_main,
        "message_caps": msg_caps,
        # hier kannst du weitere Layer/Ebenen aufnehmen:
        # "layer1": ...,
        # "layer2": ...,
        # "picked100": ...,
        # etc.
    }
    return result