subs_down_n_sync
CLI Python para baixar e sincronizar legendas para arquivos de vídeo. Idioma padrão: pt-BR, configurável via flag --lang (qualquer tag BCP 47).
A sincronização usa embeddings semânticos multilíngues (sentence-transformers, modelo paraphrase-multilingual-MiniLM-L12-v2) combinados com DTW: baixa uma legenda de referência no idioma original (padrão: EN, configurável via --ref-lang) e alinha os cues da legenda alvo aos timestamps da referência por similaridade semântica. Legendas com match exato (hash ou release group) são usadas sem sincronização.
Instalação
Recomendado: pipx
pipx instala ferramentas CLI em ambientes isolados e adiciona automaticamente ao PATH:
pipx install subs-down-n-sync
Alternativa: pip
pip install subs-down-n-sync
Se aparecer o aviso WARNING: The script subs-down-n-sync is installed in '...' which is not on PATH, adicione o diretório ao PATH:
# Linux/macOS — adicione ao ~/.bashrc ou ~/.zshrc
export PATH="$HOME/.local/bin:$PATH"
# Windows (PowerShell) — adicione ao seu $PROFILE
$env:PATH += ";$env:APPDATA\Python\Scripts"
Após editar o arquivo de perfil, reinicie o terminal ou rode source ~/.bashrc (Linux/macOS).
Instale também o ffmpeg:
sudo apt install ffmpeg # Debian/Ubuntu
brew install ffmpeg # macOS
winget install Gyan.FFmpeg # Windows
Configure as credenciais do OpenSubtitles:
export OPENSUBTITLES_USERNAME="seu_usuario"
export OPENSUBTITLES_PASSWORD="sua_senha"
OPENSUBTITLES_USERNAME e OPENSUBTITLES_PASSWORD são opcionais se as credenciais
já estiverem salvas em ~/.config/subs-down-n-sync/credentials.enc (criptografado com AES-128).
No primeiro uso sem env vars, o CLI solicita interativamente e salva o arquivo.
Env vars têm prioridade sobre o arquivo salvo.
Para desenvolvimento, veja Setup.
Setup
Linux/macOS:
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
Windows (PowerShell):
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -e ".[dev]"
Windows (cmd.exe):
python -m venv .venv
.venv\Scripts\activate.bat
pip install -e ".[dev]"
Instale também o ffmpeg no sistema:
sudo apt install ffmpeg # Debian/Ubuntu
brew install ffmpeg # macOS
winget install Gyan.FFmpeg # Windows (winget)
choco install ffmpeg # Windows (Chocolatey)
scoop install ffmpeg # Windows (Scoop)
Confirme que ffmpeg está no PATH rodando ffmpeg -version em novo terminal.
Configuração (uma única vez)
Linux/macOS:
export OPENSUBTITLES_USERNAME="seu_usuario"
export OPENSUBTITLES_PASSWORD="sua_senha"
Windows (PowerShell, sessão atual):
$env:OPENSUBTITLES_USERNAME = "seu_usuario"
$env:OPENSUBTITLES_PASSWORD = "sua_senha"
Windows (persistente, próximas sessões):
setx OPENSUBTITLES_USERNAME "seu_usuario"
setx OPENSUBTITLES_PASSWORD "sua_senha"
OPENSUBTITLES_USERNAME e OPENSUBTITLES_PASSWORD são opcionais se as credenciais
já estiverem salvas em ~/.config/subs-down-n-sync/credentials.enc (criptografado com AES-128).
No primeiro uso sem env vars, o CLI solicita interativamente e salva o arquivo.
Env vars têm prioridade sobre o arquivo salvo.
Uso
# Default: pt-BR
subs-down-n-sync /caminho/para/filme.mkv
# Outro idioma (BCP 47: 'en', 'pt-BR', 'en-US', 'es', 'ja', ...)
subs-down-n-sync /caminho/para/filme.mkv --lang en
subs-down-n-sync /caminho/para/filme.mkv -l es
# Processar diretório inteiro (busca vídeos recursivamente)
subs-down-n-sync /caminho/para/pasta/
subs-down-n-sync /caminho/para/pasta/ --lang en
subs-down-n-sync /caminho/para/pasta/ --overwrite # sobrescreve legendas existentes (baixa da API)
subs-down-n-sync /caminho/para/pasta/ --resync # sincroniza legenda existente sem API
subs-down-n-sync /caminho/para/pasta/ --parallel # processa até 2 vídeos simultâneos
# Audio sync com modelo Whisper maior (mais preciso, mais lento)
subs-down-n-sync /caminho/para/filme.mkv --whisper-model base
# Idioma original diferente de EN (ex.: conteúdo espanhol)
subs-down-n-sync /caminho/para/filme.mkv --ref-lang es
# Ou via módulo Python
python -m subs_down_n_sync /caminho/para/filme.mkv
Ao passar um diretório, vídeos que já têm legenda (<video>.<lang>.srt) são pulados por padrão. Use --overwrite / -o para baixar novamente da API. Use --resync / -r para sincronizar a legenda existente sem bater na API (útil quando a legenda já está correta mas fora de sincronia). Use --parallel / -p para processar até 2 vídeos em paralelo.
Saída: /caminho/para/filme.<lang>.srt (ex.: filme.pt-BR.srt, filme.en.srt). Isso permite manter legendas do mesmo vídeo em idiomas diferentes sem sobrescrever.
Desenvolvimento
pip install -e ".[dev]"
pytest
Os testes unitários rodam com gate de cobertura de 90% (configurado em pyproject.toml). O CI falha se a cobertura cair abaixo disso.
Para rodar sem o gate (útil ao explorar com -k ou --collect-only):
pytest --no-cov
Lint e formatação
O projeto usa Ruff para formatação e lint.
ruff format . # aplica formatação
ruff format --check . # verifica sem escrever (usado no CI)
ruff check . # roda lint
ruff check --fix . # aplica fixes automáticos
O CI falha se ruff format --check ou ruff check encontrarem problemas.
Testes de integração
O projeto tem duas camadas de testes:
- Testes unitários (padrão,
pytest) — rápidos, mockamsubliminalesentence_transformers. Não precisam de rede nem de binários externos além do Python. - Testes de integração (
pytest -m integration) — exercitam o pipeline real de alinhamento semântico (download do modelosentence-transformers+ DTW) sobre legendas reais. Requer acesso à internet no primeiro run para baixar o modelo (~120 MB), cacheado pelo Hugging Face em~/.cache/huggingface/.
Como rodar cada camada:
pytest # só unit (rápido)
pytest -m integration # só integração (baixa modelo de embeddings, roda DTW real)
pytest -m "" # tudo (unit + integração)
Metadata
Release files for subs-down-n-sync 1.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| subs_down_n_sync-1.5.0.tar.gz | 47.2 kB | With provenance | Details for subs_down_n_sync-1.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| subs_down_n_sync-1.5.0-py3-none-any.whl | Python 3 | none | any | Details for subs_down_n_sync-1.5.0-py3-none-any.whl |
Total release size: 78.6 kB
Release files / subs_down_n_sync-1.5.0.tar.gz
| Download URL | subs_down_n_sync-1.5.0.tar.gz |
|---|---|
| Size | 47.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
850cffedecf885e0cc1451f28f9eec71288e3d71361d02c93a6c947082e827b0
|
|
BLAKE2b-256 checksum How to use checksums |
7c20d3283cfeed1bf4fdd7974672340f78a27a8ade824236527ade31614e62e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 1, 2026.
Transparency logRelease files / subs_down_n_sync-1.5.0-py3-none-any.whl
| Download URL | subs_down_n_sync-1.5.0-py3-none-any.whl |
|---|---|
| Size | 31.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b293d2ea39832dd7f90494682a334620b1e43c9f0efda0384772054e05d2c920
|
|
BLAKE2b-256 checksum How to use checksums |
18ca0496f45e2930a37ecccad4435bb759f8c488ca8db74dc5277fc4db2e9bdf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 1, 2026.
Transparency logSecurity for subs-down-n-sync 1.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for subs_down_n_sync-1.5.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 1, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.