Skip to content

flameastro/transcript-youtube-video

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📜 transcript-youtube-video

EUA English Version

Python code that saves the transcript

📑 Table of Contents


📜 What is it? 🤷🏻

transcript-youtube-video is a Python bot that automatically collects YouTube video transcripts and saves the content into a .txt file.

It uses the automated browser Playwright to open the video, access the transcript, and export it — all with just one command.


🧰 Requirements

Before starting, make sure the following tools are installed on your system:


🚀 How to Use

1. Check if Git is installed

git -v

If the output looks like "git version 2.x.x", you're good to go.


2. Clone the repository

git clone https://github.com/flameastro/transcript-youtube-video.git

3. Install dependencies

pip install playwright
playwright install

4. Run the bot

Inside the project folder, run:

python main.py

The program will ask for a YouTube video link:

⚠️ Note: In the example below, I'm using a link from Gustavo Guanabara's course just for testing.

Enter the YouTube video URL:
>>> https://www.youtube.com/watch?v=FdePtO5JSd0

It will also ask if you want to include timestamps in the transcript.txt file. (Timestamps indicate where in the video each piece of text appears. You can better understand this by comparing a file with timestamps and another file without timestamps)

Do you want to collect timestamps as well? [y/n]:
>>> y

After that, a Chromium browser window will open automatically. Just wait a few seconds while the bot collects the transcript.

If everything goes well ✅, the transcript will be saved in the transcript.txt file.


📂 Project Structure

transcript-youtube-video/
├─ assets/
│  ├─ code.png
│  ├─ transcript-v1.png
│  └─ transcript-v2.png
├─ examples/
│  ├─ transcript-v1.txt
│  └─ transcript-v2.txt
├─ LICENSE
├─ main.py
├─ README.md
└─ transcript.txt   # automatically generated after execution

📄 Output Examples

Example with timestamps

Transcript example with timestamps

Example without timestamps

Transcript example without timestamps

⚠️ Warning

  • Some videos do not have a transcript, especially when:

    • They are music videos
    • They have little or no audio
    • The creator disabled automatic captions

In these cases, the transcript.txt file may be empty.


Brasil Versão em Português

O código Python que salva as transcrições

📑 Sumário


📜 O que é? 🤷🏻

transcript-youtube-video é um bot em Python que coleta automaticamente a transcrição de vídeos do YouTube e salva o conteúdo em um arquivo .txt.

Ele utiliza o navegador automatizado Playwright para abrir o vídeo, localizar a transcrição e exportá-la — tudo isso com apenas um comando.


🧰 Pré-requisitos

Antes de começar, certifique-se de ter os seguintes itens instalados no seu sistema:


🚀 Como utilizar

1. Verifique se o Git está instalado

git -v

Se a saída for algo como "git version 2.x.x", você está pronto para continuar.


2. Clone o repositório

git clone https://github.com/flameastro/transcript-youtube-video.git

3. Instale as dependências

pip install playwright
playwright install

4. Execute o bot

Dentro da pasta do projeto, rode:

python main.py

O programa pedirá um link do vídeo do YouTube:

⚠️ Aviso: Neste exemplo, estou usando o link do curso do Gustavo Guanabara. Apenas para fins de testes.

Insira a URL do vídeo do YouTube:
>>> https://www.youtube.com/watch?v=FdePtO5JSd0

E também perguntará se você deseja adicionar tempo ou não no arquivo transcript.txt. O tempo sinaliza qual é a parte do vídeo que aquele determinado texto está. (Você pode entender isso melhor comparando um arquivo que possui tempo e outro arquivo que não possui tempo)

Deseja coletar o tempo também? [s/n]:
>>> s

Após inserir, uma nova janela do navegador Chromium será aberta automaticamente. Basta aguardar alguns segundos enquanto o bot coleta a transcrição.

Se tudo correr bem ✅, a transcrição será salva no arquivo transcript.txt.


📂 Estrutura do Projeto

transcript-youtube-video/
├─ assets/
│  ├─ code.png
│  ├─ transcript-v1.png
│  └─ transcript-v2.png
├─ examples/
│  ├─ transcript-v1.txt
│  └─ transcript-v2.txt
├─ LICENSE
├─ main.py
├─ README.md
└─ transcript.txt   # gerado automaticamente após a execução

📄 Exemplos de saída

Um exemplo de saída com tempo

Um exemplo de transcrição de saída com tempo

Um exemplo de saída sem tempo

Um exemplo de transcrição de saída sem tempo


⚠️ Aviso

  • Alguns vídeos não possuem transcrição, principalmente quando:

    • São músicas ou clipes
    • Possuem pouco ou nenhum áudio
    • O autor desativou as legendas automáticas

Nesses casos, o arquivo transcript.txt pode ficar vazio.


About

A bot that collects transcripts of YouTube videos.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages