ripcd 0.0.1__py3-none-any.whl
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.
- ripcd/__init__.py +8 -0
- ripcd/__main__.py +6 -0
- ripcd/constants.py +10 -0
- ripcd/main.py +80 -0
- ripcd/py.typed +0 -0
- ripcd/rip.py +98 -0
- ripcd-0.0.1.dist-info/METADATA +96 -0
- ripcd-0.0.1.dist-info/RECORD +11 -0
- ripcd-0.0.1.dist-info/WHEEL +4 -0
- ripcd-0.0.1.dist-info/entry_points.txt +2 -0
- ripcd-0.0.1.dist-info/licenses/LICENSE.txt +18 -0
ripcd/__init__.py
ADDED
ripcd/__main__.py
ADDED
ripcd/constants.py
ADDED
ripcd/main.py
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"""CLI entry point for ripcd."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
import getpass
|
|
7
|
+
import subprocess as sp
|
|
8
|
+
|
|
9
|
+
from bascom import setup_logging
|
|
10
|
+
import click
|
|
11
|
+
import requests
|
|
12
|
+
|
|
13
|
+
from .constants import DEFAULT_DRIVE_SR0
|
|
14
|
+
from .rip import rip_cdda_to_flac
|
|
15
|
+
|
|
16
|
+
__all__ = ('main',)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@click.command(context_settings={'help_option_names': ('-h', '--help')})
|
|
20
|
+
@click.option(
|
|
21
|
+
'-D',
|
|
22
|
+
'--drive',
|
|
23
|
+
default='/dev/sr0',
|
|
24
|
+
help='Optical drive path.',
|
|
25
|
+
type=click.Path(exists=True, dir_okay=False, path_type=Path),
|
|
26
|
+
)
|
|
27
|
+
@click.option(
|
|
28
|
+
'-M',
|
|
29
|
+
'--accept-first-cddb-match',
|
|
30
|
+
is_flag=True,
|
|
31
|
+
help='Accept the first CDDB match in case of multiple matches.',
|
|
32
|
+
)
|
|
33
|
+
@click.option('--album-artist', help='Album artist override.')
|
|
34
|
+
@click.option('--album-dir', help='Album directory name. Defaults to artist-album-year format.')
|
|
35
|
+
@click.option('--cddb-host', help='CDDB host (default from keyring gnudb/<user>).')
|
|
36
|
+
@click.option('--never-skip',
|
|
37
|
+
help="Passed to cdparanoia's --never-skip=... option.",
|
|
38
|
+
type=int,
|
|
39
|
+
default=5)
|
|
40
|
+
@click.option('-d', '--debug', is_flag=True, help='Enable debug output.')
|
|
41
|
+
@click.option('-o',
|
|
42
|
+
'--output-dir',
|
|
43
|
+
help='Parent directory for album_dir. Defaults to current directory.')
|
|
44
|
+
@click.option('-u', '--username', default=None, help='Username for CDDB.')
|
|
45
|
+
def main(
|
|
46
|
+
drive: Path = DEFAULT_DRIVE_SR0,
|
|
47
|
+
album_artist: str | None = None,
|
|
48
|
+
album_dir: str | None = None,
|
|
49
|
+
cddb_host: str | None = None,
|
|
50
|
+
never_skip: int = 5,
|
|
51
|
+
output_dir: str | None = None,
|
|
52
|
+
username: str | None = None,
|
|
53
|
+
*,
|
|
54
|
+
accept_first_cddb_match: bool = True,
|
|
55
|
+
debug: bool = False,
|
|
56
|
+
) -> None:
|
|
57
|
+
"""
|
|
58
|
+
Rip an audio disc to FLAC files.
|
|
59
|
+
|
|
60
|
+
Requires cdparanoia and flac to be in PATH.
|
|
61
|
+
|
|
62
|
+
For Linux only.
|
|
63
|
+
""" # noqa: DOC501
|
|
64
|
+
setup_logging(debug=debug, loggers={'ripcd': {}})
|
|
65
|
+
if username is None: # pragma: no cover
|
|
66
|
+
username = getpass.getuser()
|
|
67
|
+
try:
|
|
68
|
+
rip_cdda_to_flac(
|
|
69
|
+
drive,
|
|
70
|
+
accept_first_cddb_match=accept_first_cddb_match,
|
|
71
|
+
album_artist=album_artist,
|
|
72
|
+
album_dir=album_dir,
|
|
73
|
+
cddb_host=cddb_host,
|
|
74
|
+
never_skip=never_skip,
|
|
75
|
+
output_dir=output_dir,
|
|
76
|
+
username=username,
|
|
77
|
+
)
|
|
78
|
+
except (sp.CalledProcessError, requests.RequestException, ValueError) as e:
|
|
79
|
+
click.echo(str(e), err=True)
|
|
80
|
+
raise click.Abort from e
|
ripcd/py.typed
ADDED
|
File without changes
|
ripcd/rip.py
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"""Rip audio CD to FLAC."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from typing import TYPE_CHECKING
|
|
7
|
+
import logging
|
|
8
|
+
import subprocess as sp
|
|
9
|
+
|
|
10
|
+
from deltona.media import cddb_query, get_cd_disc_id
|
|
11
|
+
|
|
12
|
+
if TYPE_CHECKING:
|
|
13
|
+
from collections.abc import Callable
|
|
14
|
+
|
|
15
|
+
from deltona.typing import StrPath
|
|
16
|
+
|
|
17
|
+
log = logging.getLogger(__name__)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def rip_cdda_to_flac(
|
|
21
|
+
drive: StrPath,
|
|
22
|
+
*,
|
|
23
|
+
accept_first_cddb_match: bool = True,
|
|
24
|
+
album_artist: str | None = None,
|
|
25
|
+
album_dir: StrPath | None = None,
|
|
26
|
+
cddb_host: str | None = None,
|
|
27
|
+
never_skip: int = 5,
|
|
28
|
+
output_dir: StrPath | None = None,
|
|
29
|
+
stderr_callback: Callable[[str], None] | None = None,
|
|
30
|
+
username: str | None = None,
|
|
31
|
+
) -> None:
|
|
32
|
+
"""
|
|
33
|
+
Rip an audio disc to FLAC files.
|
|
34
|
+
|
|
35
|
+
Requires ``cdparanoia`` and ``flac`` to be in ``PATH``.
|
|
36
|
+
|
|
37
|
+
Raises
|
|
38
|
+
------
|
|
39
|
+
CalledProcessError
|
|
40
|
+
"""
|
|
41
|
+
result = cddb_query(
|
|
42
|
+
get_cd_disc_id(drive),
|
|
43
|
+
app='ripcd rip_cdda',
|
|
44
|
+
accept_first_match=accept_first_cddb_match,
|
|
45
|
+
host=cddb_host,
|
|
46
|
+
username=username,
|
|
47
|
+
)
|
|
48
|
+
log.debug('Result: %s', result)
|
|
49
|
+
output_dir = Path(output_dir or '.')
|
|
50
|
+
album_dir = ((output_dir / album_dir) if album_dir else output_dir /
|
|
51
|
+
f'{album_artist or result.artist}-{result.album}-{result.year}')
|
|
52
|
+
album_dir.mkdir(parents=True, exist_ok=True)
|
|
53
|
+
for i, track in enumerate(result.tracks, 1):
|
|
54
|
+
wav = album_dir / f'{i:02d}-{result.artist}-{track}.wav'
|
|
55
|
+
flac = str(wav.with_suffix('.flac'))
|
|
56
|
+
cdparanoia_command = (
|
|
57
|
+
'cdparanoia',
|
|
58
|
+
f'--force-cdrom-device={drive}',
|
|
59
|
+
*(('--quiet', '--stderr-progress') if stderr_callback else ()),
|
|
60
|
+
f'--never-skip={never_skip:d}',
|
|
61
|
+
'--abort-on-skip',
|
|
62
|
+
str(i),
|
|
63
|
+
str(wav),
|
|
64
|
+
)
|
|
65
|
+
proc = sp.Popen(
|
|
66
|
+
cdparanoia_command,
|
|
67
|
+
stderr=sp.PIPE if stderr_callback else None,
|
|
68
|
+
stdout=sp.PIPE if stderr_callback else None,
|
|
69
|
+
text=True,
|
|
70
|
+
)
|
|
71
|
+
if stderr_callback:
|
|
72
|
+
assert proc.stderr is not None
|
|
73
|
+
while proc.stderr.readable():
|
|
74
|
+
if line := proc.stderr.readline().strip():
|
|
75
|
+
stderr_callback(line)
|
|
76
|
+
log.debug('Waiting for cdparanoia to finish (i = %d, track = "%s").', i, track)
|
|
77
|
+
if (code := proc.wait()) != 0:
|
|
78
|
+
raise sp.CalledProcessError(code, cdparanoia_command)
|
|
79
|
+
sp.run(
|
|
80
|
+
(
|
|
81
|
+
'flac',
|
|
82
|
+
'--delete-input-file',
|
|
83
|
+
'--force',
|
|
84
|
+
'--replay-gain',
|
|
85
|
+
'--silent',
|
|
86
|
+
'--verify',
|
|
87
|
+
f'--output-name={flac}',
|
|
88
|
+
f'--tag=ALBUM={result.album}',
|
|
89
|
+
f'--tag=ALBUMARTIST={album_artist or result.artist}',
|
|
90
|
+
f'--tag=ARTIST={result.artist}',
|
|
91
|
+
f'--tag=GENRE={result.genre}',
|
|
92
|
+
f'--tag=TITLE={track}',
|
|
93
|
+
f'--tag=TRACKNUMBER={i:02d}',
|
|
94
|
+
f'--tag=YEAR={result.year:04d}',
|
|
95
|
+
str(wav),
|
|
96
|
+
),
|
|
97
|
+
check=True,
|
|
98
|
+
)
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ripcd
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Rip audio CD to FLAC with CDDB metadata.
|
|
5
|
+
Project-URL: Issues, https://github.com/Tatsh/ripcd/issues
|
|
6
|
+
Project-URL: documentation, https://ripcd.readthedocs.org
|
|
7
|
+
Project-URL: homepage, https://tatsh.github.io/ripcd/
|
|
8
|
+
Project-URL: repository, https://github.com/Tatsh/ripcd
|
|
9
|
+
Author-email: Andrew Udvare <audvare@gmail.com>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE.txt
|
|
12
|
+
Keywords: cd,cddb,flac,rip
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Programming Language :: Python
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Classifier: Typing :: Typed
|
|
22
|
+
Requires-Python: <4.0,>=3.10
|
|
23
|
+
Requires-Dist: bascom>=0.1.2
|
|
24
|
+
Requires-Dist: click>=8.3.1
|
|
25
|
+
Requires-Dist: deltona[media]>=0.1.4
|
|
26
|
+
Requires-Dist: requests>=2.32.5
|
|
27
|
+
Requires-Dist: typing-extensions>=4.15.0
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# ripcd
|
|
31
|
+
|
|
32
|
+
[](https://www.python.org/)
|
|
33
|
+
[](https://pypi.org/project/ripcd/)
|
|
34
|
+
[](https://github.com/Tatsh/ripcd/tags)
|
|
35
|
+
[](https://github.com/Tatsh/ripcd/blob/master/LICENSE.txt)
|
|
36
|
+
[](https://github.com/Tatsh/ripcd/compare/v0.0.1...master)
|
|
37
|
+
[](https://github.com/Tatsh/ripcd/actions/workflows/codeql.yml)
|
|
38
|
+
[](https://github.com/Tatsh/ripcd/actions/workflows/qa.yml)
|
|
39
|
+
[](https://github.com/Tatsh/ripcd/actions/workflows/tests.yml)
|
|
40
|
+
[](https://coveralls.io/github/Tatsh/ripcd?branch=master)
|
|
41
|
+
[](https://github.com/dependabot)
|
|
42
|
+
[](https://ripcd.readthedocs.org/?badge=latest)
|
|
43
|
+
[](https://mypy-lang.org/)
|
|
44
|
+
[](https://pre-commit.com/)
|
|
45
|
+
[](https://docs.astral.sh/uv/)
|
|
46
|
+
[](https://www.pydocstyle.org/)
|
|
47
|
+
[](https://docs.pytest.org)
|
|
48
|
+
[](https://github.com/astral-sh/ruff)
|
|
49
|
+
[](https://pepy.tech/project/ripcd)
|
|
50
|
+
[](https://github.com/Tatsh/ripcd/stargazers)
|
|
51
|
+
[](https://prettier.io/)
|
|
52
|
+
|
|
53
|
+
[](https://bsky.app/profile/Tatsh.bsky.social)
|
|
54
|
+
[](https://buymeacoffee.com/Tatsh)
|
|
55
|
+
[](irc://irc.libera.chat/Tatsh)
|
|
56
|
+
[](https://hostux.social/@Tatsh)
|
|
57
|
+
[](https://www.patreon.com/Tatsh2)
|
|
58
|
+
|
|
59
|
+
Rip audio CD to FLAC with CDDB metadata. Linux only. Requires `cdparanoia` and `flac` in PATH.
|
|
60
|
+
|
|
61
|
+
## Installation
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
pip install ripcd
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Usage
|
|
68
|
+
|
|
69
|
+
```plain
|
|
70
|
+
Usage: ripcd [OPTIONS]
|
|
71
|
+
|
|
72
|
+
Rip an audio disc to FLAC files.
|
|
73
|
+
|
|
74
|
+
Requires cdparanoia and flac to be in PATH.
|
|
75
|
+
|
|
76
|
+
For Linux only.
|
|
77
|
+
|
|
78
|
+
Options:
|
|
79
|
+
-D, --drive FILE Optical drive path.
|
|
80
|
+
-M, --accept-first-cddb-match Accept the first CDDB match in case of
|
|
81
|
+
multiple matches.
|
|
82
|
+
--album-artist TEXT Album artist override.
|
|
83
|
+
--album-dir TEXT Album directory name. Defaults to artist-
|
|
84
|
+
album-year format.
|
|
85
|
+
--cddb-host TEXT CDDB host (default from keyring
|
|
86
|
+
gnudb/<user>).
|
|
87
|
+
--never-skip INTEGER Passed to cdparanoia's --never-skip=...
|
|
88
|
+
option.
|
|
89
|
+
-d, --debug Enable debug output.
|
|
90
|
+
-o, --output-dir TEXT Parent directory for album_dir. Defaults to
|
|
91
|
+
current directory.
|
|
92
|
+
-u, --username TEXT Username for CDDB.
|
|
93
|
+
-h, --help Show this message and exit.
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
CDDB host can be set via keyring under the `gnudb` key for your username, or via `--cddb-host`.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
ripcd/__init__.py,sha256=XitiagmqzZZ3pG6zd28a4a1vJ3FCO_nOpSzJftj1QPs,165
|
|
2
|
+
ripcd/__main__.py,sha256=oQ6s6zvZTBiEOgt-qep3bDY9ayxSanQr7KHzr6ENK0o,115
|
|
3
|
+
ripcd/constants.py,sha256=SlGfYxeZ_MY3yNsAGPbbUb7TBxkN-lgUV2j0Oha_KCI,185
|
|
4
|
+
ripcd/main.py,sha256=lnQyu8DbkToioXw5z8U7za0Er3qFqb30mIjYI0H4qZU,2443
|
|
5
|
+
ripcd/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
ripcd/rip.py,sha256=kmhhGwTl6vVBAJGZZ-Q63XKVE5GC19mm9VqOPHlJFHc,3103
|
|
7
|
+
ripcd-0.0.1.dist-info/METADATA,sha256=WFdOyzrxRwxuZNsuC4EbuECAD3PLeNEqX36s8iN7vA0,5663
|
|
8
|
+
ripcd-0.0.1.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
9
|
+
ripcd-0.0.1.dist-info/entry_points.txt,sha256=_mtXzfFWYiCVTQrbFXj-0bku10a4BTDrWkiTHG-kyFo,42
|
|
10
|
+
ripcd-0.0.1.dist-info/licenses/LICENSE.txt,sha256=OCToWP4jJyiXfFURKg37kL8nt4ORSw3W4sajhCTHqFE,1080
|
|
11
|
+
ripcd-0.0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ripcd authors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
6
|
+
associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
7
|
+
including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
8
|
+
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all copies or
|
|
12
|
+
substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
|
15
|
+
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
16
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
17
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
|
|
18
|
+
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|