I have this Octane material with a ImageTexture shader.
I can programmatically set the source file on the shader.
I want to be able to Keyframe this source file.
Here's what I got so far:
def changeTexture(shader, item, chosen, curTime) :
    doc = shader.GetDocument()
    doc.AddUndo(c4d.UNDOTYPE_CHANGE, shader)
    filepath = f'{item}_{chosen}.png'
    # Assign the new value
    print(f'Applying texture: {filepath}')
    print (shader[c4d.IMAGETEXTURE_FILE])
    shader[c4d.IMAGETEXTURE_FILE] = filepath
    shader.Message(c4d.MSG_UPDATE)
    print(shader[c4d.IMAGETEXTURE_FILE])
    track = shader.FindCTrack(c4d.IMAGETEXTURE_FILE)
    if not track:
        track = c4d.CTrack(shader, c4d.IMAGETEXTURE_FILE)
        shader.InsertTrackSorted(track)
    print(track)
    curve = track.GetCurve()
    result = curve.FindKey(curTime)
    if result is None:
        result = curve.AddKey(curTime)
    print(result)
    track.FillKey(doc, shader, result['key'])
    c4d.EventAdd()
This runs without bugs. The files do get changed but they're not keyframed. The first time I run this, the file keyframe indicator does show up orange. But not the subsequent times.