Most weeks, the work on my daughter’s media player is not coding. It is adding things she asked for. This is a small post about two such additions, because each one hit a snag, and the snags are the useful part.

The Need: She Asks for a Song, and It Isn’t There Yet

My daughter is three. She decides what she wants to hear, and the answer changes every week. If the player doesn’t have it, I need to add it in a few minutes, or the moment is gone. So adding content has to be boring and fast.

The English tab works from folders only. There is no database for it. A folder on the NAS is a book, and the audio files inside are its tracks. Drop a folder in, and a new book card appears.

The Proof: Two Additions, Two Snags

Addition 1: an English book. I had ripped a CD, and the files came off with no names or artist information at all. I asked Claude to add it to the English tab “the usual way” and gave it the title, “Dry Bones”.

💬 Prompt that worked “Using the files in the ‘Unknown Album Artist - Unknown Album’ folder, add them to the English tab the existing way. The title is ‘Dry Bones’.”

That worked. Nine tracks appeared. The tab expects each track to have a type in its filename (story song, story reading, echo chant, melody), and the CD plays the same types twice, as two rounds. Since the ripped files had no names, Claude guessed the type of each track from its file size. I haven’t listened to all nine to confirm every guess, so I would call that “likely right, not checked”.

Snag 1. I wanted the new book to be last in the list, after the one I had added before. It was in the middle. The list was in alphabetical order. I told Claude: “put Dry Bones at the very end.”

Addition 2: a song in the Dad tab. I had an audio file (an m4a) and a picture for it. The picture was a portrait image, 1302 by 1754 pixels, and it had to be turned 90 degrees to the left to look right. I asked for exactly that. Claude checked the result by size: 1754 by 1302, now landscape. It replaced the file in the media folder under the same name, so the database needed no change.

Snag 2. Claude said it had confirmed the new size, but had not looked at the app screen. That is worth reading twice. A picture can have the right size and still be turned the wrong way, so look at it in the app. (If the old direction still shows, refresh the page, because the browser keeps the old image.)

The Story: Alphabetical Order Is Never What a Child Expects

A three-year-old thinks in terms of “the new one”. Alphabetical order puts the new book wherever the letter falls. It is correct for a library, and wrong for a child who wants to see what’s new at the end of the row.

The How: Sort by Folder Creation Time, and Restart the Server

The book list is built by the server each time it is asked. The change was in one place: sort the folders by when they were created, not by name.

// instead of alphabetical order
books.sort((a, b) => a.birthtimeMs - b.birthtimeMs);
// if the filesystem can't report a creation time, fall back to the name

There are two traps here.

  1. The server has to restart. The change needs the API container to be restarted before it takes effect. Without that, nothing looks different, and it feels like the change failed. On my NAS the command is a docker compose restart run over SSH.
  2. Creation time may not exist. Inside a Docker container, the file system sometimes can’t report when a folder was created. That is why I kept the fallback to the name. If the order is still alphabetical after the restart, look there.

For adding a book in general, my steps are: make a folder in the English media folder on the NAS (over SMB), copy the files in with the type names the app understands, and open the book list in the browser. For the Dad-tab song: copy the audio, set the picture as the cover in the song’s data file, and put the same change in both my local copy and the NAS copy, because the live app reads the NAS one.

Cost: $0.