yt-audio-cli 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- yt_audio_cli-0.1.0/.gitignore +216 -0
- yt_audio_cli-0.1.0/LICENSE +21 -0
- yt_audio_cli-0.1.0/PKG-INFO +178 -0
- yt_audio_cli-0.1.0/README.md +167 -0
- yt_audio_cli-0.1.0/pyproject.toml +91 -0
- yt_audio_cli-0.1.0/src/yt_audio_cli/__init__.py +20 -0
- yt_audio_cli-0.1.0/src/yt_audio_cli/__main__.py +6 -0
- yt_audio_cli-0.1.0/src/yt_audio_cli/cli.py +493 -0
- yt_audio_cli-0.1.0/src/yt_audio_cli/convert/__init__.py +8 -0
- yt_audio_cli-0.1.0/src/yt_audio_cli/convert/transcoder.py +200 -0
- yt_audio_cli-0.1.0/src/yt_audio_cli/core/__init__.py +18 -0
- yt_audio_cli-0.1.0/src/yt_audio_cli/core/errors.py +83 -0
- yt_audio_cli-0.1.0/src/yt_audio_cli/core/filename.py +91 -0
- yt_audio_cli-0.1.0/src/yt_audio_cli/download/__init__.py +21 -0
- yt_audio_cli-0.1.0/src/yt_audio_cli/download/downloader.py +530 -0
- yt_audio_cli-0.1.0/src/yt_audio_cli/ui/__init__.py +29 -0
- yt_audio_cli-0.1.0/src/yt_audio_cli/ui/progress.py +200 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
# Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
# poetry.lock
|
|
109
|
+
# poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
# pdm.lock
|
|
116
|
+
# pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
# pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# Redis
|
|
135
|
+
*.rdb
|
|
136
|
+
*.aof
|
|
137
|
+
*.pid
|
|
138
|
+
|
|
139
|
+
# RabbitMQ
|
|
140
|
+
mnesia/
|
|
141
|
+
rabbitmq/
|
|
142
|
+
rabbitmq-data/
|
|
143
|
+
|
|
144
|
+
# ActiveMQ
|
|
145
|
+
activemq-data/
|
|
146
|
+
|
|
147
|
+
# SageMath parsed files
|
|
148
|
+
*.sage.py
|
|
149
|
+
|
|
150
|
+
# Environments
|
|
151
|
+
.env
|
|
152
|
+
.envrc
|
|
153
|
+
.venv
|
|
154
|
+
env/
|
|
155
|
+
venv/
|
|
156
|
+
ENV/
|
|
157
|
+
env.bak/
|
|
158
|
+
venv.bak/
|
|
159
|
+
|
|
160
|
+
# Spyder project settings
|
|
161
|
+
.spyderproject
|
|
162
|
+
.spyproject
|
|
163
|
+
|
|
164
|
+
# Rope project settings
|
|
165
|
+
.ropeproject
|
|
166
|
+
|
|
167
|
+
# mkdocs documentation
|
|
168
|
+
/site
|
|
169
|
+
|
|
170
|
+
# mypy
|
|
171
|
+
.mypy_cache/
|
|
172
|
+
.dmypy.json
|
|
173
|
+
dmypy.json
|
|
174
|
+
|
|
175
|
+
# Pyre type checker
|
|
176
|
+
.pyre/
|
|
177
|
+
|
|
178
|
+
# pytype static type analyzer
|
|
179
|
+
.pytype/
|
|
180
|
+
|
|
181
|
+
# Cython debug symbols
|
|
182
|
+
cython_debug/
|
|
183
|
+
|
|
184
|
+
# PyCharm
|
|
185
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
186
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
188
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
189
|
+
# .idea/
|
|
190
|
+
|
|
191
|
+
# Abstra
|
|
192
|
+
# Abstra is an AI-powered process automation framework.
|
|
193
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
194
|
+
# Learn more at https://abstra.io/docs
|
|
195
|
+
.abstra/
|
|
196
|
+
|
|
197
|
+
# Visual Studio Code
|
|
198
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
199
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
200
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
201
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
202
|
+
# .vscode/
|
|
203
|
+
|
|
204
|
+
# Ruff stuff:
|
|
205
|
+
.ruff_cache/
|
|
206
|
+
|
|
207
|
+
# PyPI configuration file
|
|
208
|
+
.pypirc
|
|
209
|
+
|
|
210
|
+
# Marimo
|
|
211
|
+
marimo/_static/
|
|
212
|
+
marimo/_lsp/
|
|
213
|
+
__marimo__/
|
|
214
|
+
|
|
215
|
+
# Streamlit
|
|
216
|
+
.streamlit/secrets.toml
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 pyyupsk
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: yt-audio-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A simple command-line tool for downloading audio from YouTube and other sites
|
|
5
|
+
License-File: LICENSE
|
|
6
|
+
Requires-Python: >=3.12
|
|
7
|
+
Requires-Dist: rich>=14.2.0
|
|
8
|
+
Requires-Dist: typer>=0.21.0
|
|
9
|
+
Requires-Dist: yt-dlp>=2025.12.8
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
|
|
12
|
+
# yt-audio-cli
|
|
13
|
+
|
|
14
|
+
[](https://github.com/pyyupsk/yt-audio-cli/actions/workflows/ci.yml)
|
|
15
|
+
[](https://codecov.io/gh/pyyupsk/yt-audio-cli)
|
|
16
|
+
[](https://pypi.org/project/yt-audio-cli/)
|
|
17
|
+
[](https://pypi.org/project/yt-audio-cli/)
|
|
18
|
+
[](LICENSE)
|
|
19
|
+
|
|
20
|
+
A simple command-line tool for downloading audio from YouTube and other sites.
|
|
21
|
+
|
|
22
|
+
## What This Is
|
|
23
|
+
|
|
24
|
+
yt-audio-cli is an opinionated wrapper around [yt-dlp](https://github.com/yt-dlp/yt-dlp) and [FFmpeg](https://ffmpeg.org/), designed specifically for audio downloads. It provides sensible defaults and a streamlined interface for common audio extraction tasks.
|
|
25
|
+
|
|
26
|
+
- **yt-dlp** handles all video/audio downloading and site support (1000+ sites)
|
|
27
|
+
- **FFmpeg** handles audio conversion and processing
|
|
28
|
+
- **yt-audio-cli** ties them together with audio-focused defaults and a simplified CLI
|
|
29
|
+
|
|
30
|
+
If you need advanced features like video downloads, custom format selection, or fine-grained control, use yt-dlp directly.
|
|
31
|
+
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# Install
|
|
36
|
+
pip install yt-audio-cli
|
|
37
|
+
|
|
38
|
+
# Download audio
|
|
39
|
+
yt-audio-cli https://youtube.com/watch?v=VIDEO_ID
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Requirements
|
|
43
|
+
|
|
44
|
+
**FFmpeg** must be installed on your system for audio conversion:
|
|
45
|
+
|
|
46
|
+
- **Windows**: `winget install FFmpeg` or download from [ffmpeg.org](https://ffmpeg.org/download.html)
|
|
47
|
+
- **macOS**: `brew install ffmpeg`
|
|
48
|
+
- **Linux**: `sudo apt install ffmpeg` (Debian/Ubuntu) or `sudo dnf install ffmpeg` (Fedora)
|
|
49
|
+
|
|
50
|
+
yt-dlp is installed automatically as a Python dependency.
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install yt-audio-cli
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Or with [uv](https://docs.astral.sh/uv/):
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
uv tool install yt-audio-cli
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Usage
|
|
65
|
+
|
|
66
|
+
### Download Audio
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# Single video (saves as MP3 by default)
|
|
70
|
+
yt-audio-cli https://youtube.com/watch?v=VIDEO_ID
|
|
71
|
+
|
|
72
|
+
# Multiple videos
|
|
73
|
+
yt-audio-cli URL1 URL2 URL3
|
|
74
|
+
|
|
75
|
+
# Entire playlist
|
|
76
|
+
yt-audio-cli https://youtube.com/playlist?list=PLAYLIST_ID
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Choose Format
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
yt-audio-cli -f opus URL # Opus (smallest size)
|
|
83
|
+
yt-audio-cli -f aac URL # AAC
|
|
84
|
+
yt-audio-cli -f mp3 URL # MP3 (default)
|
|
85
|
+
yt-audio-cli -f wav URL # WAV (lossless)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Choose Quality
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
yt-audio-cli -q best URL # Highest quality (default)
|
|
92
|
+
yt-audio-cli -q good URL # Balanced
|
|
93
|
+
yt-audio-cli -q small URL # Smallest file size
|
|
94
|
+
|
|
95
|
+
# Or set exact bitrate (32-320 kbps)
|
|
96
|
+
yt-audio-cli -b 256 URL
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Save Location
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
# Save to specific folder
|
|
103
|
+
yt-audio-cli -o ~/Music URL
|
|
104
|
+
|
|
105
|
+
# Default: current directory
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Skip Metadata
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# Don't embed title/artist in the file
|
|
112
|
+
yt-audio-cli --no-metadata URL
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Options
|
|
116
|
+
|
|
117
|
+
| Option | Short | Description | Default |
|
|
118
|
+
| --------------- | ----- | ---------------------------------- | ----------- |
|
|
119
|
+
| `--format` | `-f` | Audio format (mp3, aac, opus, wav) | mp3 |
|
|
120
|
+
| `--output` | `-o` | Output directory | Current dir |
|
|
121
|
+
| `--quality` | `-q` | Quality preset (best, good, small) | best |
|
|
122
|
+
| `--bitrate` | `-b` | Exact bitrate in kbps (32-320) | - |
|
|
123
|
+
| `--no-metadata` | | Skip embedding metadata | - |
|
|
124
|
+
| `--force` | `-F` | Re-download even if file exists | - |
|
|
125
|
+
| `--version` | `-v` | Show version | - |
|
|
126
|
+
| `--help` | `-h` | Show help | - |
|
|
127
|
+
|
|
128
|
+
> **Note:** By default, files that already exist in the output directory are skipped. Use `--force` to re-download them.
|
|
129
|
+
|
|
130
|
+
## Troubleshooting
|
|
131
|
+
|
|
132
|
+
**"FFmpeg not found"**
|
|
133
|
+
Install FFmpeg using the instructions in [Requirements](#requirements).
|
|
134
|
+
|
|
135
|
+
**"Video unavailable"**
|
|
136
|
+
The video may be private, age-restricted, or region-locked. This is a limitation of the source site, not yt-dlp or this tool.
|
|
137
|
+
|
|
138
|
+
**"Signature solving failed" / JS challenge warnings**
|
|
139
|
+
YouTube uses JavaScript challenges to protect some video formats. You may see warnings like:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
yt-dlp: [youtube] Signature solving failed: Some formats may be missing.
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Downloads usually still work (yt-dlp falls back to alternative formats), but to resolve these warnings:
|
|
146
|
+
|
|
147
|
+
- **Install Deno** (recommended): `curl -fsSL https://deno.land/install.sh | sh`
|
|
148
|
+
- **Or download the solver**: `yt-dlp --remote-components ejs:github`
|
|
149
|
+
|
|
150
|
+
See [yt-dlp EJS wiki](https://github.com/yt-dlp/yt-dlp/wiki/EJS) for more details.
|
|
151
|
+
|
|
152
|
+
**Download fails**
|
|
153
|
+
Check your internet connection and verify the URL is correct. If the issue persists, ensure yt-dlp is up to date: `pip install -U yt-dlp`
|
|
154
|
+
|
|
155
|
+
## Metadata
|
|
156
|
+
|
|
157
|
+
```python
|
|
158
|
+
__metadata__ = {
|
|
159
|
+
"name": "yt-audio-cli",
|
|
160
|
+
"version": "0.1.0",
|
|
161
|
+
"author": "pyyupsk",
|
|
162
|
+
"license": "MIT",
|
|
163
|
+
"python": ">=3.12",
|
|
164
|
+
"repository": "github.com/pyyupsk/yt-audio-cli",
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Disclaimer
|
|
169
|
+
|
|
170
|
+
> [!IMPORTANT]
|
|
171
|
+
> This tool is intended for downloading content you have the right to access. Respect copyright laws and the terms of service of the platforms you use.
|
|
172
|
+
|
|
173
|
+
> [!CAUTION]
|
|
174
|
+
> The authors are not responsible for any misuse of this software.
|
|
175
|
+
|
|
176
|
+
## License
|
|
177
|
+
|
|
178
|
+
This project is licensed under the [MIT License](LICENSE).
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# yt-audio-cli
|
|
2
|
+
|
|
3
|
+
[](https://github.com/pyyupsk/yt-audio-cli/actions/workflows/ci.yml)
|
|
4
|
+
[](https://codecov.io/gh/pyyupsk/yt-audio-cli)
|
|
5
|
+
[](https://pypi.org/project/yt-audio-cli/)
|
|
6
|
+
[](https://pypi.org/project/yt-audio-cli/)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
|
|
9
|
+
A simple command-line tool for downloading audio from YouTube and other sites.
|
|
10
|
+
|
|
11
|
+
## What This Is
|
|
12
|
+
|
|
13
|
+
yt-audio-cli is an opinionated wrapper around [yt-dlp](https://github.com/yt-dlp/yt-dlp) and [FFmpeg](https://ffmpeg.org/), designed specifically for audio downloads. It provides sensible defaults and a streamlined interface for common audio extraction tasks.
|
|
14
|
+
|
|
15
|
+
- **yt-dlp** handles all video/audio downloading and site support (1000+ sites)
|
|
16
|
+
- **FFmpeg** handles audio conversion and processing
|
|
17
|
+
- **yt-audio-cli** ties them together with audio-focused defaults and a simplified CLI
|
|
18
|
+
|
|
19
|
+
If you need advanced features like video downloads, custom format selection, or fine-grained control, use yt-dlp directly.
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Install
|
|
25
|
+
pip install yt-audio-cli
|
|
26
|
+
|
|
27
|
+
# Download audio
|
|
28
|
+
yt-audio-cli https://youtube.com/watch?v=VIDEO_ID
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Requirements
|
|
32
|
+
|
|
33
|
+
**FFmpeg** must be installed on your system for audio conversion:
|
|
34
|
+
|
|
35
|
+
- **Windows**: `winget install FFmpeg` or download from [ffmpeg.org](https://ffmpeg.org/download.html)
|
|
36
|
+
- **macOS**: `brew install ffmpeg`
|
|
37
|
+
- **Linux**: `sudo apt install ffmpeg` (Debian/Ubuntu) or `sudo dnf install ffmpeg` (Fedora)
|
|
38
|
+
|
|
39
|
+
yt-dlp is installed automatically as a Python dependency.
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pip install yt-audio-cli
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Or with [uv](https://docs.astral.sh/uv/):
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
uv tool install yt-audio-cli
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Usage
|
|
54
|
+
|
|
55
|
+
### Download Audio
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# Single video (saves as MP3 by default)
|
|
59
|
+
yt-audio-cli https://youtube.com/watch?v=VIDEO_ID
|
|
60
|
+
|
|
61
|
+
# Multiple videos
|
|
62
|
+
yt-audio-cli URL1 URL2 URL3
|
|
63
|
+
|
|
64
|
+
# Entire playlist
|
|
65
|
+
yt-audio-cli https://youtube.com/playlist?list=PLAYLIST_ID
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Choose Format
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
yt-audio-cli -f opus URL # Opus (smallest size)
|
|
72
|
+
yt-audio-cli -f aac URL # AAC
|
|
73
|
+
yt-audio-cli -f mp3 URL # MP3 (default)
|
|
74
|
+
yt-audio-cli -f wav URL # WAV (lossless)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Choose Quality
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
yt-audio-cli -q best URL # Highest quality (default)
|
|
81
|
+
yt-audio-cli -q good URL # Balanced
|
|
82
|
+
yt-audio-cli -q small URL # Smallest file size
|
|
83
|
+
|
|
84
|
+
# Or set exact bitrate (32-320 kbps)
|
|
85
|
+
yt-audio-cli -b 256 URL
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Save Location
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
# Save to specific folder
|
|
92
|
+
yt-audio-cli -o ~/Music URL
|
|
93
|
+
|
|
94
|
+
# Default: current directory
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Skip Metadata
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
# Don't embed title/artist in the file
|
|
101
|
+
yt-audio-cli --no-metadata URL
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Options
|
|
105
|
+
|
|
106
|
+
| Option | Short | Description | Default |
|
|
107
|
+
| --------------- | ----- | ---------------------------------- | ----------- |
|
|
108
|
+
| `--format` | `-f` | Audio format (mp3, aac, opus, wav) | mp3 |
|
|
109
|
+
| `--output` | `-o` | Output directory | Current dir |
|
|
110
|
+
| `--quality` | `-q` | Quality preset (best, good, small) | best |
|
|
111
|
+
| `--bitrate` | `-b` | Exact bitrate in kbps (32-320) | - |
|
|
112
|
+
| `--no-metadata` | | Skip embedding metadata | - |
|
|
113
|
+
| `--force` | `-F` | Re-download even if file exists | - |
|
|
114
|
+
| `--version` | `-v` | Show version | - |
|
|
115
|
+
| `--help` | `-h` | Show help | - |
|
|
116
|
+
|
|
117
|
+
> **Note:** By default, files that already exist in the output directory are skipped. Use `--force` to re-download them.
|
|
118
|
+
|
|
119
|
+
## Troubleshooting
|
|
120
|
+
|
|
121
|
+
**"FFmpeg not found"**
|
|
122
|
+
Install FFmpeg using the instructions in [Requirements](#requirements).
|
|
123
|
+
|
|
124
|
+
**"Video unavailable"**
|
|
125
|
+
The video may be private, age-restricted, or region-locked. This is a limitation of the source site, not yt-dlp or this tool.
|
|
126
|
+
|
|
127
|
+
**"Signature solving failed" / JS challenge warnings**
|
|
128
|
+
YouTube uses JavaScript challenges to protect some video formats. You may see warnings like:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
yt-dlp: [youtube] Signature solving failed: Some formats may be missing.
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Downloads usually still work (yt-dlp falls back to alternative formats), but to resolve these warnings:
|
|
135
|
+
|
|
136
|
+
- **Install Deno** (recommended): `curl -fsSL https://deno.land/install.sh | sh`
|
|
137
|
+
- **Or download the solver**: `yt-dlp --remote-components ejs:github`
|
|
138
|
+
|
|
139
|
+
See [yt-dlp EJS wiki](https://github.com/yt-dlp/yt-dlp/wiki/EJS) for more details.
|
|
140
|
+
|
|
141
|
+
**Download fails**
|
|
142
|
+
Check your internet connection and verify the URL is correct. If the issue persists, ensure yt-dlp is up to date: `pip install -U yt-dlp`
|
|
143
|
+
|
|
144
|
+
## Metadata
|
|
145
|
+
|
|
146
|
+
```python
|
|
147
|
+
__metadata__ = {
|
|
148
|
+
"name": "yt-audio-cli",
|
|
149
|
+
"version": "0.1.0",
|
|
150
|
+
"author": "pyyupsk",
|
|
151
|
+
"license": "MIT",
|
|
152
|
+
"python": ">=3.12",
|
|
153
|
+
"repository": "github.com/pyyupsk/yt-audio-cli",
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Disclaimer
|
|
158
|
+
|
|
159
|
+
> [!IMPORTANT]
|
|
160
|
+
> This tool is intended for downloading content you have the right to access. Respect copyright laws and the terms of service of the platforms you use.
|
|
161
|
+
|
|
162
|
+
> [!CAUTION]
|
|
163
|
+
> The authors are not responsible for any misuse of this software.
|
|
164
|
+
|
|
165
|
+
## License
|
|
166
|
+
|
|
167
|
+
This project is licensed under the [MIT License](LICENSE).
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "yt-audio-cli"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "A simple command-line tool for downloading audio from YouTube and other sites"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.12"
|
|
7
|
+
dependencies = ["rich>=14.2.0", "typer>=0.21.0", "yt-dlp>=2025.12.8"]
|
|
8
|
+
|
|
9
|
+
[project.scripts]
|
|
10
|
+
yt-audio-cli = "yt_audio_cli.cli:app"
|
|
11
|
+
|
|
12
|
+
[build-system]
|
|
13
|
+
requires = ["hatchling"]
|
|
14
|
+
build-backend = "hatchling.build"
|
|
15
|
+
|
|
16
|
+
[tool.hatch.build.targets.wheel]
|
|
17
|
+
packages = ["src/yt_audio_cli"]
|
|
18
|
+
|
|
19
|
+
[tool.hatch.build.targets.sdist]
|
|
20
|
+
include = ["src/", "LICENSE", "README.md", "pyproject.toml"]
|
|
21
|
+
|
|
22
|
+
[dependency-groups]
|
|
23
|
+
dev = [
|
|
24
|
+
"bandit>=1.9.2",
|
|
25
|
+
"pre-commit>=4.5.1",
|
|
26
|
+
"pyright>=1.1.407",
|
|
27
|
+
"pytest>=9.0.2",
|
|
28
|
+
"pytest-cov>=7.0.0",
|
|
29
|
+
"ruff>=0.14.10",
|
|
30
|
+
"ty>=0.0.8",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[tool.ruff]
|
|
34
|
+
target-version = "py312"
|
|
35
|
+
line-length = 88
|
|
36
|
+
src = ["src", "tests"]
|
|
37
|
+
|
|
38
|
+
[tool.ruff.lint]
|
|
39
|
+
select = [
|
|
40
|
+
"E", # pycodestyle errors
|
|
41
|
+
"W", # pycodestyle warnings
|
|
42
|
+
"F", # Pyflakes
|
|
43
|
+
"I", # isort
|
|
44
|
+
"B", # flake8-bugbear
|
|
45
|
+
"C4", # flake8-comprehensions
|
|
46
|
+
"UP", # pyupgrade
|
|
47
|
+
"ARG", # flake8-unused-arguments
|
|
48
|
+
"SIM", # flake8-simplify
|
|
49
|
+
"PTH", # flake8-use-pathlib
|
|
50
|
+
"RUF", # Ruff-specific rules
|
|
51
|
+
]
|
|
52
|
+
ignore = [
|
|
53
|
+
"E501", # line too long (handled by formatter)
|
|
54
|
+
]
|
|
55
|
+
|
|
56
|
+
[tool.ruff.lint.per-file-ignores]
|
|
57
|
+
"tests/*" = [
|
|
58
|
+
"ARG005",
|
|
59
|
+
"SIM117",
|
|
60
|
+
] # Unused lambda args in tests, nested with statements
|
|
61
|
+
|
|
62
|
+
[tool.ruff.lint.isort]
|
|
63
|
+
known-first-party = ["yt_audio_cli"]
|
|
64
|
+
|
|
65
|
+
[tool.ruff.format]
|
|
66
|
+
quote-style = "double"
|
|
67
|
+
indent-style = "space"
|
|
68
|
+
|
|
69
|
+
[tool.pyright]
|
|
70
|
+
pythonVersion = "3.12"
|
|
71
|
+
typeCheckingMode = "standard"
|
|
72
|
+
include = ["src"]
|
|
73
|
+
exclude = ["tests"]
|
|
74
|
+
|
|
75
|
+
[tool.pytest.ini_options]
|
|
76
|
+
testpaths = ["tests"]
|
|
77
|
+
addopts = "-v --tb=short"
|
|
78
|
+
|
|
79
|
+
[tool.coverage.run]
|
|
80
|
+
source = ["src/yt_audio_cli"]
|
|
81
|
+
branch = true
|
|
82
|
+
|
|
83
|
+
[tool.coverage.report]
|
|
84
|
+
exclude_lines = [
|
|
85
|
+
"pragma: no cover",
|
|
86
|
+
"if TYPE_CHECKING:",
|
|
87
|
+
"raise NotImplementedError",
|
|
88
|
+
]
|
|
89
|
+
|
|
90
|
+
[tool.bandit]
|
|
91
|
+
exclude_dirs = ["tests"]
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""A simple command-line tool for downloading audio from YouTube and other sites."""
|
|
2
|
+
|
|
3
|
+
from yt_audio_cli.core import ConversionError, DownloadError, FFmpegNotFoundError
|
|
4
|
+
|
|
5
|
+
__version__ = "0.1.0"
|
|
6
|
+
__metadata__ = {
|
|
7
|
+
"name": "yt-audio-cli",
|
|
8
|
+
"version": __version__,
|
|
9
|
+
"author": "pyyupsk",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"python": ">=3.12",
|
|
12
|
+
"repository": "github.com/pyyupsk/yt-audio-cli",
|
|
13
|
+
}
|
|
14
|
+
__all__ = [
|
|
15
|
+
"ConversionError",
|
|
16
|
+
"DownloadError",
|
|
17
|
+
"FFmpegNotFoundError",
|
|
18
|
+
"__metadata__",
|
|
19
|
+
"__version__",
|
|
20
|
+
]
|