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 ADDED
@@ -0,0 +1,8 @@
1
+ """Rip an audio disc to FLAC files."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from .rip import rip_cdda_to_flac
6
+
7
+ __all__ = ('rip_cdda_to_flac',)
8
+ __version__ = '0.0.1'
ripcd/__main__.py ADDED
@@ -0,0 +1,6 @@
1
+ """Entry point for ``python -m`` invocation."""
2
+ from __future__ import annotations
3
+
4
+ from .main import main
5
+
6
+ main()
ripcd/constants.py ADDED
@@ -0,0 +1,10 @@
1
+ """Constants."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pathlib import Path
6
+
7
+ __all__ = ('DEFAULT_DRIVE_SR0',)
8
+
9
+ DEFAULT_DRIVE_SR0 = Path('/dev/sr0')
10
+ """Default drive to read from."""
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
+ [![Python versions](https://img.shields.io/pypi/pyversions/ripcd.svg?color=blue&logo=python&logoColor=white)](https://www.python.org/)
33
+ [![PyPI - Version](https://img.shields.io/pypi/v/ripcd)](https://pypi.org/project/ripcd/)
34
+ [![GitHub tag (with filter)](https://img.shields.io/github/v/tag/Tatsh/ripcd)](https://github.com/Tatsh/ripcd/tags)
35
+ [![License](https://img.shields.io/github/license/Tatsh/ripcd)](https://github.com/Tatsh/ripcd/blob/master/LICENSE.txt)
36
+ [![GitHub commits since latest release (by SemVer including pre-releases)](https://img.shields.io/github/commits-since/Tatsh/ripcd/v0.0.1/master)](https://github.com/Tatsh/ripcd/compare/v0.0.1...master)
37
+ [![CodeQL](https://github.com/Tatsh/ripcd/actions/workflows/codeql.yml/badge.svg)](https://github.com/Tatsh/ripcd/actions/workflows/codeql.yml)
38
+ [![QA](https://github.com/Tatsh/ripcd/actions/workflows/qa.yml/badge.svg)](https://github.com/Tatsh/ripcd/actions/workflows/qa.yml)
39
+ [![Tests](https://github.com/Tatsh/ripcd/actions/workflows/tests.yml/badge.svg)](https://github.com/Tatsh/ripcd/actions/workflows/tests.yml)
40
+ [![Coverage Status](https://coveralls.io/repos/github/Tatsh/ripcd/badge.svg?branch=master)](https://coveralls.io/github/Tatsh/ripcd?branch=master)
41
+ [![Dependabot](https://img.shields.io/badge/Dependabot-enabled-blue?logo=dependabot)](https://github.com/dependabot)
42
+ [![Documentation Status](https://readthedocs.org/projects/ripcd/badge/?version=latest)](https://ripcd.readthedocs.org/?badge=latest)
43
+ [![mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/)
44
+ [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://pre-commit.com/)
45
+ [![uv](https://img.shields.io/badge/uv-261230?logo=astral)](https://docs.astral.sh/uv/)
46
+ [![pydocstyle](https://img.shields.io/badge/pydocstyle-enabled-AD4CD3?logo=pydocstyle)](https://www.pydocstyle.org/)
47
+ [![pytest](https://img.shields.io/badge/pytest-enabled-CFB97D?logo=pytest)](https://docs.pytest.org)
48
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
49
+ [![Downloads](https://static.pepy.tech/badge/ripcd/month)](https://pepy.tech/project/ripcd)
50
+ [![Stargazers](https://img.shields.io/github/stars/Tatsh/ripcd?logo=github&style=flat)](https://github.com/Tatsh/ripcd/stargazers)
51
+ [![Prettier](https://img.shields.io/badge/Prettier-enabled-black?logo=prettier)](https://prettier.io/)
52
+
53
+ [![@Tatsh](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fpublic.api.bsky.app%2Fxrpc%2Fapp.bsky.actor.getProfile%2F%3Factor=did%3Aplc%3Auq42idtvuccnmtl57nsucz72&query=%24.followersCount&label=Follow+%40Tatsh&logo=bluesky&style=social)](https://bsky.app/profile/Tatsh.bsky.social)
54
+ [![Buy Me A Coffee](https://img.shields.io/badge/Buy%20Me%20a%20Coffee-Tatsh-black?logo=buymeacoffee)](https://buymeacoffee.com/Tatsh)
55
+ [![Libera.Chat](https://img.shields.io/badge/Libera.Chat-Tatsh-black?logo=liberadotchat)](irc://irc.libera.chat/Tatsh)
56
+ [![Mastodon Follow](https://img.shields.io/mastodon/follow/109370961877277568?domain=hostux.social&style=social)](https://hostux.social/@Tatsh)
57
+ [![Patreon](https://img.shields.io/badge/Patreon-Tatsh2-F96854?logo=patreon)](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,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.29.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ ripcd = ripcd.main:main
@@ -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.