">
VICTOR SAAD
All buildsTodos os projetos
Python · yt-dlp · Claude · Obsidian · git

YouTube → second brain bot

Bot YouTube → segundo cérebro

I watch a lot of long technical videos and retain almost none of it. Now I paste the link and get a clean, linked note on my phone a couple of minutes later.

Eu assisto a muitos vídeos técnicos longos e não guardo quase nada. Agora colo o link e, poucos minutos depois, tenho no celular uma nota limpa e cheia de links.

discord.pyyt-dlpClaude CLIObsidianasynciogitflock
On the left, a Discord channel where a YouTube link was posted and the bot replied that the note was saved and pushed; on the right, the resulting Obsidian note with title, source, channel and key takeaways with linked names.
Left: the link goes in. Right: the note that comes out, with people and tools turned into links. Recreated from a real note.
À esquerda, o link entra. À direita, a nota que sai, com pessoas e ferramentas viradas em links. Recriada a partir de uma nota real.

The problem

O problema

The gap between “this is useful” and “I can find this again in six months” is where most of what I watch disappears. Saving the link doesn't close it; the link isn't the knowledge.

É no espaço entre “isso é útil” e “consigo achar isso de novo daqui a seis meses” que some quase tudo o que eu assisto. Salvar o link não resolve: o link não é o conhecimento.

How it works

Como funciona

  1. Paste. A link in one Discord channel; the bot reacts with an hourglass.
  2. Transcribe. yt-dlp pulls the captions and the video's title and channel.
  3. Clean. Claude turns raw auto-captions into readable prose with section headings.
  4. Enrich. A second pass extracts the takeaways, the people and the concepts; each becomes a wiki link, and new people get a stub note of their own.
  5. File and sync. The note lands in the vault, is committed and pushed to GitHub, and reaches my Mac and phone through the second brain's sync. The bot replies with a check mark.
  1. Colar. Um link num canal do Discord; o bot reage com uma ampulheta.
  2. Transcrever. O yt-dlp puxa as legendas, o título e o canal do vídeo.
  3. Limpar. O Claude transforma as legendas automáticas cruas em texto legível, com títulos de seção.
  4. Enriquecer. Uma segunda passada extrai os principais pontos, as pessoas e os conceitos; cada um vira um wiki link, e pessoas novas ganham uma nota inicial só delas.
  5. Arquivar e sincronizar. A nota cai no vault, ganha commit e push para o GitHub e chega ao Mac e ao celular pela sincronização do segundo cérebro. O bot responde com um check.

A second channel works the other way round: ask a question and the bot answers from the whole vault.

Um segundo canal faz o caminho inverso: você pergunta e o bot responde com base no vault inteiro.

Two bugs worth the price of admission

Dois bugs que valeram o ingresso

The lockfile. It died silently for two days. The kernel runs fs.protected_regular=2, which refuses writes to a file owned by another user inside a sticky, world-writable directory, root included. The lockfile was in /tmp. Locks live in /run now. The same setting had quietly broken the vault sync too; I found that one only because I went looking after this.

O lockfile. O bot morreu em silêncio por dois dias. O kernel roda com fs.protected_regular=2, que recusa escrita num arquivo de outro usuário dentro de um diretório sticky e gravável por todos, até para o root. O lockfile estava em /tmp. Hoje os locks ficam em /run. A mesma configuração também tinha quebrado, sem alarde, a sincronização do vault; só descobri porque fui procurar depois disso.

Logging the wrong stream. The CLI it shells out to reports an expired session on stdout, not stderr. I was logging stderr. The result was a log full of successful-looking silence while nothing worked. Log both.

Logando a saída errada. A CLI que o bot chama avisa sessão expirada no stdout, não no stderr. Eu logava o stderr. Resultado: um log cheio de um silêncio com cara de sucesso enquanto nada funcionava. Logue os dois.

Small things that mattered

Detalhes que fizeram diferença

  • Blocking work wrapped in asyncio.to_thread so the Discord heartbeat keeps beating.
  • Graceful degradation: if the cleaning step fails, the raw transcript is still saved; nothing pasted is lost.
  • One lock shared with the five-minute vault sync, so the two never run git at the same time.
  • Keepalive: a check restarts the bot if it isn't running.
  • Trabalho bloqueante dentro de asyncio.to_thread, para o heartbeat do Discord continuar batendo.
  • Degradação suave: se a limpeza falhar, a transcrição crua é salva mesmo assim; nada do que foi colado se perde.
  • Um lock só, dividido com a sincronização do vault a cada cinco minutos, para os dois nunca rodarem git ao mesmo tempo.
  • Keepalive: uma checagem reinicia o bot se ele não estiver rodando.

Want to talk about this? I'm happy to walk through how it was built.Quer conversar sobre isso? Mostro com prazer como foi construído.