pax_global_header 0000666 0000000 0000000 00000000064 15224143223 0014510 g ustar 00root root 0000000 0000000 52 comment=61cbaeb26805edc452f06c7edc5ed9b7826415e5
python-discid-1.4.2/ 0000775 0000000 0000000 00000000000 15224143223 0014272 5 ustar 00root root 0000000 0000000 python-discid-1.4.2/.git-blame-ignore-revs 0000664 0000000 0000000 00000000051 15224143223 0020366 0 ustar 00root root 0000000 0000000 81f388fe4ab7fe591d68cc3f14753247eaa4992d
python-discid-1.4.2/.github/ 0000775 0000000 0000000 00000000000 15224143223 0015632 5 ustar 00root root 0000000 0000000 python-discid-1.4.2/.github/workflows/ 0000775 0000000 0000000 00000000000 15224143223 0017667 5 ustar 00root root 0000000 0000000 python-discid-1.4.2/.github/workflows/build.yaml 0000664 0000000 0000000 00000003042 15224143223 0021651 0 ustar 00root root 0000000 0000000 name: Run tests
on: [push, pull_request]
permissions: {}
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
steps:
- uses: actions/checkout@v7
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install libdiscid0
pip install build pytest
- name: Test
run: pytest --verbose
- name: Build
run: python -m build
- name: Upload artifacts
uses: actions/upload-artifact@v7
with:
name: dist-${{ matrix.python-version }}
path: dist/
pypi-publish:
name: upload release to PyPI
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
needs: test
# Specifying a GitHub environment is optional, but strongly encouraged
environment:
name: pypi
url: https://pypi.org/p/discid
permissions:
# IMPORTANT: this permission is mandatory for Trusted Publishing
id-token: write
steps:
- uses: actions/checkout@v7
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.10'
cache: 'pip'
- name: Install dependencies
run: pip install build
- name: Build
run: python -m build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
python-discid-1.4.2/.github/workflows/lint.yaml 0000664 0000000 0000000 00000001236 15224143223 0021523 0 ustar 00root root 0000000 0000000 name: Linting
on:
push:
paths: &path-list
- '.github/workflows/lint.yaml'
- '**/*.py'
pull_request:
paths: *path-list
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Ruff lint
uses: astral-sh/ruff-action@v4.0.0
with:
args: "check --output-format=github"
- name: Ruff format check
uses: astral-sh/ruff-action@v4.0.0
with:
args: "format --diff"
typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Install ty
run: pip install ty
- name: Type check
run: ty check --verbose
python-discid-1.4.2/.gitignore 0000664 0000000 0000000 00000000070 15224143223 0016257 0 ustar 00root root 0000000 0000000 *.pyc
discid.egg-info/
dist/
build/
MANIFEST
doc/_build
python-discid-1.4.2/.pre-commit-config.yaml 0000664 0000000 0000000 00000001654 15224143223 0020561 0 ustar 00root root 0000000 0000000 default_install_hook_types: [pre-commit, pre-push]
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.18
hooks:
- id: ruff-check
args: [--fix]
- id: ruff-format
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.11.23
hooks:
- id: pip-compile
name: pip-compile doc/requirements.txt
args: [pyproject.toml, -o, doc/requirements.txt, --group, docs, --upgrade, --generate-hashes, --universal, --python-version=3.10]
files: 'pyproject.toml'
stages: [pre-commit]
pass_filenames: false
- repo: https://github.com/astral-sh/ty-pre-commit
rev: v0.0.52
hooks:
- id: ty
- repo: local
hooks:
- id: pytest
name: Run pytest
entry: uv run --frozen pytest --exitfirst
language: python
types: [python]
stages: [pre-push]
pass_filenames: false
always_run: true
python-discid-1.4.2/.readthedocs.yaml 0000664 0000000 0000000 00000001113 15224143223 0017515 0 ustar 00root root 0000000 0000000 # Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
# Required
version: 2
# Set the OS, Python version, and other tools you might need
build:
os: ubuntu-24.04
tools:
python: "3.13"
# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: doc/conf.py
# Optionally, but recommended,
# declare the Python requirements required to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- requirements: doc/requirements.txt
python-discid-1.4.2/CHANGES.rst 0000664 0000000 0000000 00000011566 15224143223 0016105 0 ustar 00root root 0000000 0000000 Changelog
=========
Changes in 1.4.2 (2026-07-10):
------------------------------
* Provide Python wheel on PyPI.
* Removed remaining Python 2 specific code from ``util.py``.
Changes in 1.4.1 (2026-06-24):
------------------------------
* Mark package as typed by adding a ``py.typed`` marker file.
Changes in 1.4.0 (2026-03-30):
------------------------------
* Added type hints to the public API for better IDE support and type checking.
* Added :attr:`Disc.pregap` property.
* Fixed: mutable default arguments in function signatures.
* Accept any ``Sequence[int]`` for ``offsets`` in :func:`put`.
* Removed Python 2 specific code and comments.
* Improved code consistency with ruff formatting and linting.
* Minimum supported Python version is now 3.10 (previously 3.9).
* Enhanced documentation with type hints using sphinx-autodoc-typehints.
* Fixed typos and broken links in documentation.
Changes in 1.3.0 (2025-07-26):
------------------------------
* Modernized, PEP 518 compatible, build system using ``pyproject.toml``.
* Minimum supported Python version is now 3.9.
* :issue:`51` tests requiring a physical disc are not run by default anymore.
Set the environment variable ``PYTHON_DISCID_TEST_DEVICE`` to enable them
or run ``make disccheck``.
* Fixed :func:`put` to work with first track number greater than 1.
* Add :attr:`Disc.cddb_query_string` property.
Changes in 1.2.0 (2019-02-23):
------------------------------
* improve install with pip
* add Makefile
Changes in 1.1.1 (2017-01-29):
------------------------------
* workaround :issue:`43` for py2app problems
* :issue:`41` improve windows example
Changes in 1.1.0 (2013-10-09):
------------------------------
* feature :issue:`36` add :attr:`Disc.toc_string`
* :issue:`38` remove :class:`DiscId` (deprecated since 0.5.0)
Changes in 1.0.3 (2013-10-06):
------------------------------
* fix: :issue:`37` test_emptyness: Assertion disc->success failed
Changes in 1.0.2 (2013-06-27):
------------------------------
* revert code to version 1.0.0 (see :issue:`35`)
* fix: :issue:`35` deprecation warning for DEFAULT_DEVICE shows always
* renamed a api documentation page, a redirect was created
Changes in 1.0.1 (2013-06-26):
------------------------------
* fix: :issue:`34` bring back :data:`DEFAULT_DEVICE` as deprecated
Changes in 1.0.0 (2013-06-25):
------------------------------
* :issue:`30` :data:`DEFAULT_DEVICE` is now :func:`get_default_device()`
* :issue:`32` :attr:`Disc.submission_url` doesn't point to a redirect now
* fix: seconds are now rounded the same as on MB server (0.5->up)
Changes in 0.5.0 (2013-04-27):
------------------------------
* feature: :issue:`10` add :attr:`Disc.mcn` and :attr:`Track.isrc`
* feature: add :data:`LIBDISCID_VERSION_STRING`
* feature: :issue:`28` add :attr:`Disc.seconds`, :attr:`Track.seconds`
and aliases :attr:`Disc.length` and :attr:`Track.sectors`
* :issue:`22` move :func:`read` and :func:`put` to module level
* :issue:`25` provide a package `discid` rather than a module
* :issue:`29` changed parameters for :func:`put` to include extra `sectors`
and add :exc:`TOCError`
* rename :class:`DiscId` to :class:`Disc`
* fix: :issue:`27` move track attributes to :class:`Track`
* fix: :issue:`24` only have "real" tracks in the list(s) (0 not special)
* fix: :issue:`19` only read the requested features from disc (sparse)
* fix: :issue:`26` remove :attr:`DiscId.webservice_url` (deprecated)
* fix: detect the version of libdiscid 0.3.0 also in lib64 installations
Changes in 0.4.0 (2013-04-09):
------------------------------
* feature: added :data:`FEATURES_IMPLEMENTED`, :attr:`DiscId.track_lengths`,
:attr:`DiscId.webservice_url` and :attr:`DiscId.freedb_id`
* feature :issue:`18`: disc access test suite
* fix :issue:`21`: uninformative error on Windows
Changes in 0.3.0 (2013-03-11):
------------------------------
* feature :issue:`20`: add :data:`FEATURES` list
* feature: :func:`DiscId.put`, :attr:`DiscId.track_offsets`,
:attr:`DiscId.sectors`, :attr:`DiscId.first_track_num`,
:attr:`DiscId.last_track_num`
* fix :issue:`17`: test fails on Mac OS X for default_device
* fix :issue:`16`: prefer libdiscid in current directory
* fix :issue:`15`: import can now raise :exc:`OSError`
* fix :issue:`14`: find libdiscid in current folder (Linux/Unix)
Changes in 0.2.1 (2013-01-30):
------------------------------
* fix :issue:`9`: test fails on Python 3.2 because of unicode literals
Changes in 0.2.0 (2013-01-30):
------------------------------
* API change from :func:`DiscId.get_id` to :attr:`DiscId.id`
* added :data:`DEFAULT_DEVICE` as a module constant
* added :attr:`DiscId.submission_url`
* added an actual documentation and links to linux packages
* add tests and continuous integration configuration
* add changelog
Changes in 0.1.0 (2013-01-12):
------------------------------
* initial version with :func:`DiscId.read` and :func:`DiscId.get_id`
python-discid-1.4.2/COPYING 0000664 0000000 0000000 00000104513 15224143223 0015331 0 ustar 00root root 0000000 0000000 GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Copyright (C)
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
.
python-discid-1.4.2/COPYING.LESSER 0000664 0000000 0000000 00000016743 15224143223 0016334 0 ustar 00root root 0000000 0000000 GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
python-discid-1.4.2/MANIFEST.in 0000664 0000000 0000000 00000000316 15224143223 0016030 0 ustar 00root root 0000000 0000000 include README.rst CHANGES.rst COPYING COPYING.LESSER
include test_discid.py examples.py
recursive-include doc *.rst
include doc/conf.py doc/Makefile
recursive-include doc/_static *.css
include MANIFEST.in
python-discid-1.4.2/Makefile 0000664 0000000 0000000 00000000763 15224143223 0015740 0 ustar 00root root 0000000 0000000 version := 1.4.2
build:
python -m build .
upload: build
twine3 upload -s dist/discid-$(version).tar.gz
check:
pytest --verbose
disccheck:
PYTHON_DISCID_TEST_DEVICE=1 pytest --verbose
doc:
cd doc && make dirhtml
version:
sed -i -e 's/\(__version__\s=\s"\)[0-9.]\+[0-9a-z.-]*/\1$(version)/' \
discid/__init__.py
sed -i -e 's/\(version = "\)[0-9.]\+[0-9a-z.-]*/\1$(version)/' \
pyproject.toml
clean:
rm -f *.pyc discid/*.pyc
rm -rf __pycache__ discid/__pycache__
.PHONY: doc build
python-discid-1.4.2/README.rst 0000664 0000000 0000000 00000003041 15224143223 0015757 0 ustar 00root root 0000000 0000000 Libdiscid Python bindings
-------------------------
Python-discid implements Python bindings for MusicBrainz Libdiscid. This
module supports Python 3 >= 3.10.
Libdiscid >= 0.2.2 is needed.
Libdiscid's main purpose is the calculation of an identifier of audio
discs (disc ID) to use for the `MusicBrainz database `_.
That identifier is calculated from the TOC of the disc, similar to the
freeDB CDDB identifier. Libdiscid can calculate MusicBrainz disc IDs and
freeDB disc IDs.
Additionally the MCN of the disc and ISRCs from the tracks can be extracted.
This module is a close binding that offloads all relevant data
storage and calculation to Libdiscid. On the other hand it gives a
pythonic API and uses objects and exceptions.
The official API documentation can be found at `readthedocs.org`_
For more information on Libdiscid see `libdiscid`_.
For more information about the calculation of these disc IDs see `Disc
ID Calculation`_.
Usage
~~~~~
.. code:: python
# this will load Libdiscid
import discid
disc = discid.read() # use default device
print(f"id: {disc.id}")
See also the examples.py.
License
~~~~~~~
This module is released under the GNU Lesser General Public License
Version 3. See COPYING.LESSER for details.
Bugs
~~~~
You can submit tickets at `GitHub`_.
.. _readthedocs.org: https://python-discid.readthedocs.org/
.. _libdiscid: http://musicbrainz.org/doc/libdiscid
.. _Disc ID Calculation: http://musicbrainz.org/doc/Disc_ID_Calculation
.. _GitHub: https://github.com/metabrainz/python-discid
python-discid-1.4.2/discid/ 0000775 0000000 0000000 00000000000 15224143223 0015531 5 ustar 00root root 0000000 0000000 python-discid-1.4.2/discid/__init__.py 0000664 0000000 0000000 00000004535 15224143223 0017651 0 ustar 00root root 0000000 0000000 # Copyright (C) 2013 Johannes Dewender
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see .
#
# Please submit bug reports to GitHub:
# https://github.com/metabrainz/python-discid/issues
"""Python binding of Libdiscid
Libdiscid is a library to calculate MusicBrainz Disc IDs.
This module provides a Python-like API for that functionality.
The user is expected to create a :class:`Disc` object
using :func:`read` or :func:`put` and extract the generated information.
Importing this module will open libdiscid at the same time
and will raise :exc:`OSError` when libdiscid is not found.
"""
import discid.disc
import discid.libdiscid
from discid.disc import Disc, DiscError, TOCError, put, read
from discid.libdiscid import get_default_device
from discid.track import Track
__version__ = "1.4.2"
__all__ = [
"FEATURES",
"FEATURES_IMPLEMENTED",
"LIBDISCID_VERSION_STRING",
"Disc",
"DiscError",
"TOCError",
"Track",
"get_default_device",
"put",
"read",
]
# these constants are defined here so sphinx can catch the "docstrings"
LIBDISCID_VERSION_STRING = discid.libdiscid.LIBDISCID_VERSION_STRING
"""The version string of the loaded libdiscid in the form ``"libdiscid x.y.z"``.
For versions older than 0.4.0 the string is ``"libdiscid < 0.4.0"``.
"""
FEATURES = discid.libdiscid.FEATURES
"""The features libdiscid supports for the platform as a list of strings.
Some functions can raise :exc:`NotImplementedError` when a feature
is not available.
Some features might not be implemented in this Python module,
see :data:`FEATURES_IMPLEMENTED`.
"""
FEATURES_IMPLEMENTED = discid.disc.FEATURES_IMPLEMENTED
"""The features implemented in this Python module as a list of strings.
Some might not be available for your platform, see :data:`FEATURES`.
"""
python-discid-1.4.2/discid/disc.py 0000664 0000000 0000000 00000035054 15224143223 0017034 0 ustar 00root root 0000000 0000000 # Copyright (C) 2013 Johannes Dewender
# Copyright (C) 2017 Frederik “Freso” S. Olesen
# Copyright (C) 2025, 2026 Philipp Wolfer
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see .
#
# Please submit bug reports to GitHub:
# https://github.com/metabrainz/python-discid/issues
"""Disc class"""
import re
from collections.abc import Iterable, Sequence
from ctypes import c_char_p, c_int, c_uint, c_void_p
from types import TracebackType
from discid.libdiscid import _LIB, FEATURES
from discid.track import Track
from discid.util import _decode, _encode, _sectors_to_seconds
# our implementation of libdiscid's enum discid_feature
_FEATURE_MAPPING = {"read": 1 << 0, "mcn": 1 << 1, "isrc": 1 << 2}
FEATURES_IMPLEMENTED = list(_FEATURE_MAPPING.keys())
def read(
device: str | bytes | None = None, features: Iterable[str] | None = None
) -> "Disc":
"""Reads the TOC from the device given as string
and returns a :class:`Disc` object.
The device string can be either of :obj:`str ` or :obj:`bytes`.
However, it should in no case contain non-ASCII characters.
If no device is given, a default, also given by :func:`get_default_device`
is used.
You can optionally add a subset of the features in
:data:`FEATURES` or the whole list to read more than just the TOC.
In contrast to libdiscid, :func:`read` won't read any
of the additional features by default.
:param device: the device name to use or :obj:`None` for using the default device
:param features: list of features to enable ("read" will always be assumed)
:raises DiscError: raised when reading the device fails
:raises NotImplementedError: raised when libdiscid does not support reading discs
on the current platform
"""
disc = Disc()
disc.read(device, features)
return disc
def put(
first: int, last: int, disc_sectors: int, track_offsets: Sequence[int]
) -> "Disc":
"""Creates a TOC based on the information given
and returns a :class:`Disc` object.
Depending on how you get the total sector count,
you might have to subtract 11400 (2:32 min.) for discs with data tracks.
:param first: number of the first audio track
:param last: number of the last audio track
:param disc_sectors: the end of the last audio track, normally the total
sector count of the disc
:param track_offsets: list of all audio track offsets
:raises TOCError: raised when illegal parameters are provided
.. seealso:: :musicbrainz:`Disc ID Calculation`
"""
disc = Disc()
disc.put(first, last, disc_sectors, track_offsets)
return disc
class DiscError(IOError):
""":func:`read` will raise this exception when an error occurred."""
pass
class TOCError(Exception):
""":func:`put` will raise this exception when illegal parameters
are provided.
"""
pass
class Disc:
"""The class of the object returned by :func:`read` or :func:`put`."""
_LIB.discid_new.argtypes = ()
_LIB.discid_new.restype = c_void_p
def __init__(self):
"""The initialization will reserve some memory
for internal data structures.
"""
self._handle: c_void_p | None = c_void_p(_LIB.discid_new())
self._success: bool = False
self._requested_features: list[str] = []
assert self._handle.value is not None
def __str__(self):
assert self._success
return self.id
_LIB.discid_get_error_msg.argtypes = (c_void_p,)
_LIB.discid_get_error_msg.restype = c_char_p
def _get_error_msg(self):
"""Get the error message for the last error with the object."""
error = _LIB.discid_get_error_msg(self._handle)
return _decode(error)
_LIB.discid_read.argtypes = (c_void_p, c_char_p)
_LIB.discid_read.restype = c_int
try:
_LIB.discid_read_sparse.argtypes = (c_void_p, c_char_p, c_uint)
_LIB.discid_read_sparse.restype = c_int
except AttributeError:
pass
def read(
self, device: str | bytes | None = None, features: Iterable[str] | None = None
) -> bool:
"""Reads the TOC from the device given as string
The user is supposed to use :func:`discid.read`.
"""
if "read" not in FEATURES:
raise NotImplementedError("discid_read not implemented on platform")
if features is None:
features = []
# only use features implemented on this platform and in this module
self._requested_features = list(
set(features) & set(FEATURES) & set(FEATURES_IMPLEMENTED)
)
# create the bitmask for libdiscid
c_features = 0
for feature in features:
c_features += _FEATURE_MAPPING.get(feature, 0)
# device = None will use the default device (internally)
if device is not None:
device = _encode(device)
try:
result = _LIB.discid_read_sparse(self._handle, device, c_features) == 1
except AttributeError:
result = _LIB.discid_read(self._handle, device) == 1
self._success = result
if not self._success:
raise DiscError(self._get_error_msg())
return self._success
_LIB.discid_put.argtypes = (c_void_p, c_int, c_int, c_void_p)
_LIB.discid_put.restype = c_int
def put(
self, first: int, last: int, disc_sectors: int, track_offsets: Sequence[int]
) -> bool:
"""Creates a TOC based on the input given.
The user is supposed to use :func:`discid.put`.
"""
# check for common usage errors
if len(track_offsets) != last - first + 1:
raise TOCError("Invalid number of track offsets")
elif any(disc_sectors < off for off in track_offsets):
raise TOCError("Disc sector count too low")
# only the "read" (= TOC) feature is supported by put
self._requested_features = ["read"]
offsets = [disc_sectors, *track_offsets]
# libdiscid always expects an array of 100 integers, no matter the track count.
c_offsets = (c_int * 100)()
c_offsets[0] = offsets[0]
try:
for i, offset in enumerate(offsets[1:]):
c_offsets[i + first] = offset
except IndexError:
raise TOCError("Too many tracks") from None
result = _LIB.discid_put(self._handle, first, last, c_offsets) == 1
self._success = result
if not self._success:
raise TOCError(self._get_error_msg())
return self._success
_LIB.discid_get_id.argtypes = (c_void_p,)
_LIB.discid_get_id.restype = c_char_p
def _get_id(self):
"""Gets the current MusicBrainz disc ID"""
assert self._success
result = _LIB.discid_get_id(self._handle)
return _decode(result)
_LIB.discid_get_freedb_id.argtypes = (c_void_p,)
_LIB.discid_get_freedb_id.restype = c_char_p
def _get_freedb_id(self):
"""Gets the current FreeDB disc ID"""
assert self._success
result = _LIB.discid_get_freedb_id(self._handle)
return _decode(result)
_LIB.discid_get_submission_url.argtypes = (c_void_p,)
_LIB.discid_get_submission_url.restype = c_char_p
def _get_submission_url(self):
"""Give an URL to submit the current TOC
as a new Disc ID to MusicBrainz.
"""
assert self._success
result = _LIB.discid_get_submission_url(self._handle)
return _decode(result)
try:
_LIB.discid_get_toc_string.argtypes = (c_void_p,)
_LIB.discid_get_toc_string.restype = c_char_p
except AttributeError:
pass
def _get_toc_string(self):
"""The TOC suitable as value of the ``toc`` parameter
when accessing the MusicBrainz Web Service.
"""
assert self._success
try:
result = _LIB.discid_get_toc_string(self._handle)
except AttributeError:
return None
else:
return _decode(result)
_LIB.discid_get_first_track_num.argtypes = (c_void_p,)
_LIB.discid_get_first_track_num.restype = c_int
def _get_first_track_num(self):
"""Gets the first track number"""
assert self._success
return _LIB.discid_get_first_track_num(self._handle)
_LIB.discid_get_last_track_num.argtypes = (c_void_p,)
_LIB.discid_get_last_track_num.restype = c_int
def _get_last_track_num(self):
"""Gets the last track number"""
assert self._success
return _LIB.discid_get_last_track_num(self._handle)
_LIB.discid_get_sectors.argtypes = (c_void_p,)
_LIB.discid_get_sectors.restype = c_int
def _get_sectors(self):
"""Gets the total number of sectors on the disc"""
assert self._success
return _LIB.discid_get_sectors(self._handle)
try:
_LIB.discid_get_mcn.argtypes = (c_void_p,)
_LIB.discid_get_mcn.restype = c_char_p
except AttributeError:
pass
def _get_mcn(self):
"""Gets the current Media Catalogue Number (MCN/UPC/EAN)"""
assert self._success
if "mcn" in self._requested_features:
try:
result = _LIB.discid_get_mcn(self._handle)
except AttributeError:
return None
else:
return _decode(result)
else:
return None
@property
def id(self) -> str:
"""This is the MusicBrainz :musicbrainz:`Disc ID`,
a :obj:`str ` object.
"""
return self._get_id()
@property
def freedb_id(self) -> str:
"""This is the :musicbrainz:`FreeDB` Disc ID (without category),
a :obj:`str ` object.
"""
return self._get_freedb_id()
@property
def submission_url(self) -> str | None:
"""Disc ID / TOC submission URL for MusicBrainz
With this URL you can submit the current TOC
as a new MusicBrainz :musicbrainz:`Disc ID`.
This is a :obj:`str ` object.
"""
url = self._get_submission_url()
if url is None:
return None
else:
# update submission url, which saves a couple of redirects
url = url.replace("//mm.", "//")
url = url.replace("/bare/cdlookup.html", "/cdtoc/attach")
return url
@property
def toc_string(self) -> str | None:
"""The TOC suitable as value of the ``toc`` parameter
when accessing the MusicBrainz Web Service.
This is a :obj:`str ` object
and enables fuzzy searching when the actual Disc ID is not found.
Note that this is the unencoded value, which still contains spaces.
.. seealso:: `MusicBrainz Web Service `_
"""
toc_string = self._get_toc_string()
if toc_string is None and self.submission_url:
# probably an old version of libdiscid (< 0.6.0)
# gather toc string from submission_url
match = re.search("toc=([0-9+]+)", self.submission_url)
if match is None:
raise ValueError("can't get toc string from submission url")
else:
return match.group(1).replace("+", " ")
else:
return toc_string
@property
def first_track_num(self) -> int:
"""Number of the first track"""
return self._get_first_track_num()
@property
def last_track_num(self) -> int:
"""Number of the last **audio** track"""
return self._get_last_track_num()
@property
def pregap(self) -> int:
"""Pregap of the first track in sectors.
This corresponds to the offset of the first track. A pregap of 150
sectors is typical for a CD and does not indicate any intentional gap
before the first track.
"""
track = Track(self, self._get_first_track_num())
return track.offset
@property
def sectors(self) -> int:
"""Total length in sectors"""
return self._get_sectors()
length = sectors
"""This is an alias for :attr:`sectors`"""
@property
def seconds(self) -> int:
"""Total length in seconds"""
return _sectors_to_seconds(self.sectors)
@property
def mcn(self) -> str | None:
"""This is the Media Catalogue Number (MCN/UPC/EAN)
It is set after the ``"mcn"`` feature was requested on a read
and supported by the platform or :obj:`None`.
If set, this is a :obj:`str ` object.
"""
return self._get_mcn()
@property
def tracks(self) -> list[Track]:
"""A list of :class:`Track` objects for this Disc."""
assert self._success
return [
Track(self, number)
for number in range(self.first_track_num, self.last_track_num + 1)
]
@property
def cddb_query_string(self) -> str:
"""A CDDB query string suitable for querying CDDB servers.
This is a :obj:`str ` object
and enables generating queries to CDDB servers.
.. seealso:: `CDDB Server Protocol `_
"""
offset_str = " ".join([str(track.offset) for track in self.tracks])
cddb_query_string = (
f"{self.freedb_id} {self.last_track_num} {offset_str} {self.seconds}"
)
return cddb_query_string
_LIB.discid_free.argtypes = (c_void_p,)
_LIB.discid_free.restype = None
def _free(self):
"""This will free the internal allocated memory for the object."""
_LIB.discid_free(self._handle)
self._handle = None
def __enter__(self):
"""deprecated :keyword:`with` usage"""
return self
def __exit__(
self,
exc_type: type[BaseException] | None,
exc_value: BaseException | None,
traceback: TracebackType | None,
) -> bool | None:
"""deprecated :keyword:`with` usage"""
pass
def __del__(self):
self._free()
# vim:set shiftwidth=4 smarttab expandtab:
python-discid-1.4.2/discid/libdiscid.py 0000664 0000000 0000000 00000013226 15224143223 0020035 0 ustar 00root root 0000000 0000000 # Copyright (C) 2013, 2014 Johannes Dewender
# Copyright (C) 2025, 2026 Philipp Wolfer
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see .
#
# Please submit bug reports to GitHub:
# https://github.com/metabrainz/python-discid/issues
"""libdiscid dynamic loading code and constants
The code that works with Disc objects is in disc.py
"""
import ctypes
import os
import sys
from ctypes import CDLL, c_char_p, c_void_p
from ctypes.util import find_library
from discid.util import _decode
_LIB_BASE_NAME = "discid"
_LIB_MAJOR_VERSION = 0
def _find_library(name: str, version: int = 0) -> str:
"""Find a library by base-name and major version"""
windows_names = [
f"{name}.dll",
f"lib{name}.dll",
f"lib{name}-{version}.dll",
]
lib_file = None
# This seems to be necessary in a bundle/dmg
if sys.platform == "darwin":
lib_name = f"../Frameworks/lib{name}.{version}.dylib"
if os.path.isfile(lib_name):
lib_file = lib_name
# force prefer current folder
# for linux/UNIX-like and Windows
if sys.platform in ["darwin", "cygwin"]:
# these will already work fine with find_library
pass
elif sys.platform == "win32":
for lib_name in windows_names:
if os.path.isfile(lib_name):
lib_file = lib_name
break
else:
# that would be linux/UNIX-like
# these need to prepend ./
lib_name = f"./lib{name}.so.{version}"
if os.path.isfile(lib_name):
lib_file = lib_name
# doesn't work on Windows
# Darwin gives a full path when found system-wide
# Linux and Cygwin give base filename when found
# Darwin and Cygwin will find and prefer in current folder
if lib_file is None:
lib_file = find_library(name)
# Windows needs complete filenames
# and gives a full path when found system-wide
# also searches in current folder, but system-wide preferred
if lib_file is None and sys.platform == "win32":
for lib_name in windows_names:
if lib_file is None:
lib_file = find_library(lib_name)
if lib_file is None:
# this won't help anymore,
# but gives a nice platform dependent file in the error message
if sys.platform == "win32":
lib_file = f"{name}.dll"
elif sys.platform == "darwin":
lib_file = f"lib{name}.{version}.dylib"
elif sys.platform == "cygwin":
lib_file = f"cyg{name}-{version}.dll"
else:
lib_file = f"lib{name}.so.{version}"
return lib_file
def _open_library(lib_name: str) -> CDLL:
"""Open a library by name or location"""
try:
return ctypes.cdll.LoadLibrary(lib_name)
except OSError as exc:
if lib_name not in str(exc):
# replace uninformative Error on Windows
raise OSError(f"could not find libdiscid: {lib_name}") from exc
else:
raise
_LIB_NAME = _find_library(_LIB_BASE_NAME, _LIB_MAJOR_VERSION)
_LIB = _open_library(_LIB_NAME)
try:
_LIB.discid_get_version_string.argtypes = ()
_LIB.discid_get_version_string.restype = c_char_p
except AttributeError:
pass
def _get_version_string():
"""Get the version string of libdiscid"""
try:
version_string = _LIB.discid_get_version_string()
except AttributeError:
return "libdiscid < 0.4.0"
else:
return _decode(version_string)
_LIB.discid_get_default_device.argtypes = ()
_LIB.discid_get_default_device.restype = c_char_p
def get_default_device() -> str:
"""The default device to use for :func:`read` on this platform
given as a :obj:`str ` object.
"""
device = _LIB.discid_get_default_device()
return _decode(device)
try:
_LIB.discid_get_feature_list.argtypes = (c_void_p,)
_LIB.discid_get_feature_list.restype = None
except AttributeError:
_features_available = False
else:
_features_available = True
def _get_features():
"""Get the supported features for the platform."""
features: list[str] = []
if _features_available:
c_features = (c_char_p * 32)()
_LIB.discid_get_feature_list(c_features)
features.extend(_decode(feature) for feature in c_features if feature)
else:
# libdiscid <= 0.4.0
features = ["read"] # no generic platform yet
try:
# test for ISRC/MCN API (introduced 0.3.0)
_LIB.discid_get_mcn # noqa: B018 (useless-expression)
except AttributeError:
pass
else:
# ISRC/MCN API found -> libdiscid = 0.3.x
if (
sys.platform.startswith("linux")
and not os.path.isfile("/usr/lib/libdiscid.so.0.3.0")
and not os.path.isfile("/usr/lib64/libdiscid.so.0.3.0")
):
features += ["mcn", "isrc"]
elif sys.platform in ["darwin", "win32"]:
features += ["mcn", "isrc"]
return features
LIBDISCID_VERSION_STRING = _get_version_string()
FEATURES = _get_features()
# vim:set shiftwidth=4 smarttab expandtab:
python-discid-1.4.2/discid/py.typed 0000664 0000000 0000000 00000000000 15224143223 0017216 0 ustar 00root root 0000000 0000000 python-discid-1.4.2/discid/track.py 0000664 0000000 0000000 00000006623 15224143223 0017216 0 ustar 00root root 0000000 0000000 # Copyright (C) 2013 Johannes Dewender
# Copyright (C) 2025, 2026 Philipp Wolfer
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see .
#
# Please submit bug reports to GitHub:
# https://github.com/metabrainz/python-discid/issues
"""Track class"""
from ctypes import c_char_p, c_int, c_void_p
from typing import TYPE_CHECKING
from discid.libdiscid import _LIB
from discid.util import _decode, _sectors_to_seconds
if TYPE_CHECKING:
from .disc import Disc
class Track:
"""Track objects are part of the :class:`Disc` class.
:param disc: the :class:`Disc` object
:param number: the track number
"""
def __init__(self, disc: "Disc", number: int):
self._disc: Disc = disc
self._number: int = number
assert self._disc._handle and self._disc._handle.value is not None
def __str__(self):
assert self._disc._success
return str(self.number)
_LIB.discid_get_track_offset.argtypes = (c_void_p, c_int)
_LIB.discid_get_track_offset.restype = c_int
def _get_track_offset(self):
assert self._disc._success
return _LIB.discid_get_track_offset(self._disc._handle, self.number)
_LIB.discid_get_track_length.argtypes = (c_void_p, c_int)
_LIB.discid_get_track_length.restype = c_int
def _get_track_length(self):
assert self._disc._success
return _LIB.discid_get_track_length(self._disc._handle, self.number)
try:
_LIB.discid_get_track_isrc.argtypes = (c_void_p, c_int)
_LIB.discid_get_track_isrc.restype = c_char_p
except AttributeError:
pass
def _get_track_isrc(self):
assert self._disc._success
if "isrc" in self._disc._requested_features:
try:
result = _LIB.discid_get_track_isrc(self._disc._handle, self.number)
except AttributeError:
return None
else:
return _decode(result)
else:
return None
@property
def number(self) -> int:
"""The track number"""
return self._number
@property
def offset(self) -> int:
"""The track offset"""
return self._get_track_offset()
@property
def sectors(self) -> int:
"""The track length in sectors"""
return self._get_track_length()
length = sectors
"""This is an alias for :attr:`sectors`"""
@property
def seconds(self) -> int:
"""Track length in seconds"""
return _sectors_to_seconds(self.sectors)
@property
def isrc(self) -> str | None:
"""The International Standard Recording Code
This will be :obj:`None` when the ``"isrc"`` feature was not requested
or not supported, otherwise this is a :obj:`str ` object.
"""
return self._get_track_isrc()
# vim:set shiftwidth=4 smarttab expandtab:
python-discid-1.4.2/discid/util.py 0000664 0000000 0000000 00000003362 15224143223 0017064 0 ustar 00root root 0000000 0000000 # Copyright (C) 2013 Johannes Dewender
# Copyright (C) 2026 Philipp Wolfer
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see .
#
# Please submit bug reports to GitHub:
# https://github.com/metabrainz/python-discid/issues
"""utility functions"""
import math
SECTORS_PER_SECOND = 75
def _encode(string: str | bytes) -> bytes:
"""Encode (unicode) string to byte string"""
if isinstance(string, str):
return string.encode()
elif isinstance(string, bytes):
return string
raise TypeError("Unexpected type, expected string or bytes")
def _decode(byte_string: bytes | str) -> str:
"""Decode byte string to (unicode) string"""
if isinstance(byte_string, bytes):
return byte_string.decode()
elif isinstance(byte_string, str):
return byte_string
raise TypeError("Unexpected type, expected string or bytes")
def _sectors_to_seconds(sectors: float) -> int:
"""Round sectors to seconds like done on MusicBrainz Server
The result is forced to :obj:int to make formatted output easier.
"""
return math.floor((sectors / float(SECTORS_PER_SECOND)) + 0.5)
# vim:set shiftwidth=4 smarttab expandtab:
python-discid-1.4.2/doc/ 0000775 0000000 0000000 00000000000 15224143223 0015037 5 ustar 00root root 0000000 0000000 python-discid-1.4.2/doc/CHANGES.rst 0000777 0000000 0000000 00000000000 15224143223 0020651 2../CHANGES.rst ustar 00root root 0000000 0000000 python-discid-1.4.2/doc/Makefile 0000664 0000000 0000000 00000004141 15224143223 0016477 0 ustar 00root root 0000000 0000000 # Makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
ifeq ($(shell which sphinx-build 2> /dev/null 1>&2; echo $$?),0)
SPHINXBUILD = sphinx-build
else
SPHINXBUILD = sphinx-build2
endif
ifndef BUILDDIR
BUILDDIR = _build
endif
# Internal variables.
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(SPHINXOPTS) .
.PHONY: help clean html dirhtml singlehtml text man changes linkcheck
help:
@echo "Please use \`make ' where is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " linkcheck to check all external links for integrity"
clean:
-rm -rf $(BUILDDIR)/*
html:
@echo $(SPHINXBUILD)
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."
man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."
linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
coverage:
$(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage
cat $(BUILDDIR)/coverage/python.txt
python-discid-1.4.2/doc/_static/ 0000775 0000000 0000000 00000000000 15224143223 0016465 5 ustar 00root root 0000000 0000000 python-discid-1.4.2/doc/_static/custom.css 0000664 0000000 0000000 00000000062 15224143223 0020507 0 ustar 00root root 0000000 0000000 dl.py.property {
display: block !important;
}
python-discid-1.4.2/doc/api.rst 0000664 0000000 0000000 00000003145 15224143223 0016345 0 ustar 00root root 0000000 0000000 discid API
==========
.. automodule:: discid
:synopsis: Python binding of Libdiscid
Constants
---------
At the module level there are these constants available:
.. autodata:: LIBDISCID_VERSION_STRING
:annotation:
.. autodata:: FEATURES
:annotation:
See the :musicbrainz:`libdiscid feature matrix `
for a list of supported features per platform.
.. autodata:: FEATURES_IMPLEMENTED
Functions
---------
These functions are used to create a :class:`Disc` object.
.. autofunction:: read
.. autofunction:: put
You can get the device that is used as a default with
.. autofunction:: get_default_device
Disc object
-----------
.. autoclass:: Disc
:undoc-members:
.. autoproperty:: id
.. autoproperty:: freedb_id
.. autoproperty:: first_track_num
.. autoproperty:: last_track_num
.. autoproperty:: pregap
.. versionadded:: 1.4
.. autoproperty:: sectors
.. autoproperty:: length
.. autoproperty:: seconds
.. autoproperty:: mcn
.. autoproperty:: tracks
.. autoproperty:: submission_url
.. autoproperty:: toc_string
.. versionadded:: 1.1
.. autoproperty:: cddb_query_string
.. versionadded:: 1.3
Track object
------------
.. autoclass:: Track
:undoc-members:
.. autoproperty:: number
.. autoproperty:: offset
.. autoproperty:: sectors
.. autoproperty:: length
.. autoproperty:: seconds
.. autoproperty:: isrc
Exceptions
----------
The discid module includes a custom exception to handle specific problems:
.. autoexception:: DiscError
:show-inheritance:
.. autoexception:: TOCError
:show-inheritance:
python-discid-1.4.2/doc/conf.py 0000664 0000000 0000000 00000010052 15224143223 0016334 0 ustar 00root root 0000000 0000000 import ctypes
import os
import sys
sys.path.insert(0, os.path.abspath(".")) # for extensions
sys.path.insert(0, os.path.abspath("..")) # for the code
# -- Mock libdiscid loading ----------------------------------------------------
class Mock:
def __call__(self, *args):
return Mock()
def __getattr__(self, name):
return Mock()
def discid_get_version_string(self):
return ""
ctypes.cdll.LoadLibrary = Mock() # type: ignore
# to gather version information
import discid # noqa: E402
# -- General configuration -----------------------------------------------------
needs_sphinx = "1.0"
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.coverage",
"sphinx.ext.extlinks",
"sphinx.ext.intersphinx",
"sphinx_autodoc_typehints",
]
source_suffix = ".rst"
master_doc = "index"
exclude_patterns = ["_build", ".venv"]
# General information about the project.
project = "python-discid"
copyright = "2013 Johannes Dewender, 2026 Philipp Wolfer"
# The short X.Y version / base version
version = ".".join(discid.__version__.split("-")[0].split(".")[0:2])
# The full version, including alpha/beta/rc tags.
release = discid.__version__
# see below for "current" = base version with "-dev" appended if necessary
download_base = "https://github.com/metabrainz/python-discid/archive"
if release.endswith("dev"):
current = f"{version}-dev"
download_url = f"{download_base}/main.%s"
else:
current = version
download_url = f"{download_base}/v{release}.%s"
extlinks = {
"source_download": (download_url, "%s"),
"issue": ("https://github.com/metabrainz/python-discid/issues/%s", "#%s"),
"musicbrainz": ("https://musicbrainz.org/doc/%s", "%s"),
}
# there seems to be no way to prefer latest python documentation
intersphinx_mapping = {
"python": ("http://python.readthedocs.org/en/latest/", None),
"musicbrainzngs": (
"https://python-musicbrainzngs.readthedocs.org/en/latest/",
None,
),
}
rst_prolog = """
.. currentmodule:: discid
"""
rst_epilog = f"""
.. |current| replace:: {current}
"""
# -- Options for HTML output ---------------------------------------------------
html_theme = "sphinx_rtd_theme"
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
html_theme_options = {
"collapse_navigation": True,
"navigation_depth": 2,
"version_selector": True,
}
html_title = f"{project} {current} documentation"
html_domain_indices = False
# Add custom CSS for better property display
html_static_path = ["_static"]
html_css_files = ["custom.css"]
# -- Options for LaTeX output --------------------------------------------------
latex_elements: dict[str, str] = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
(
"index",
"python-discid.tex",
"python-discid Documentation",
"Johannes Dewender",
"manual",
),
]
latex_domain_indices = False
# -- Options for manual page output --------------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
("index", "python-discid", "python-discid Documentation", ["Johannes Dewender"], 1)
]
# -- Options for Texinfo output ------------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(
"index",
"python-discid",
"python-discid Documentation",
"Johannes Dewender",
"python-discid",
"One line description of project.",
"Miscellaneous",
),
]
texinfo_domain_indices = False
python-discid-1.4.2/doc/discid.rst 0000664 0000000 0000000 00000000136 15224143223 0017030 0 ustar 00root root 0000000 0000000 :orphan:
discid
------
.. This is included so old /discid links don't break
see :doc:`api`
python-discid-1.4.2/doc/index.rst 0000664 0000000 0000000 00000003246 15224143223 0016705 0 ustar 00root root 0000000 0000000 python-discid |current|
=======================
**python-discid** is a Python binding
of :musicbrainz:`libdiscid` by MusicBrainz.
The main purpose is the calculation of an identifier for audio discs
(:musicbrainz:`Disc ID`) to use for the MusicBrainz_ database.
Additionally the disc MCN and track :musicbrainz:`ISRCs `
can be extracted.
This module is released under the
`GNU Lesser General Public License Version 3
`_ or later (LGPL3+) and
the code repository and the bug tracker are at GitHub_.
If you are interested in a binding for the MusicBrainz Web Service,
you might be interested in `python-musicbrainzngs`_.
Contents
--------
.. toctree::
:maxdepth: 2
install
usage
api
CHANGES
Related Tools
-------------
There are other bindings of libdiscid available.
Please check :musicbrainz:`libdiscid`.
In particular there is another Python binding named `python-libdiscid`_.
The main difference is, that `python-libdiscid` is released
under the Expat license and uses Cython.
This means that it needs to be compiled against libdiscid.
`Python-discid` doesn't need compilation, as it uses :mod:`ctypes`.
If you want to use the disc ID created by `python-discid` to query
MusicBrainz for metadata, then you should use `python-musicbrainzngs`_.
See :ref:`fetching_metadata` for using `discid` and `musicbrainzngs` together.
Indices and tables
------------------
* :ref:`genindex`
* :ref:`search`
.. _GitHub: https://github.com/metabrainz/python-discid
.. _MusicBrainz: https://musicbrainz.org
.. _python-musicbrainzngs: https://python-musicbrainzngs.readthedocs.org/
.. _python-libdiscid: https://python-libdiscid.readthedocs.io/
python-discid-1.4.2/doc/install.rst 0000664 0000000 0000000 00000005614 15224143223 0017245 0 ustar 00root root 0000000 0000000 Download and Installation
=========================
Dependencies
------------
**python-discid** works with Python 3 >= 3.10.
The module :mod:`discid` cannot be imported
without `libdiscid`_ >= 0.2.2 installed.
If you want to use it as optional dependency,
import the module only when needed or catch the :exc:`OSError`
when libdiscid is not found.
Package Repositories (Linux)
----------------------------
If you are using Linux,
you might find **python-discid** in a repository used by your package manager.
These packages are known:
* Arch Linux:
`python-discid `_
* Fedora:
`python3-discid `_
* openSUSE:
`python-discid `_
* Ubuntu:
PPA (`musicbrainz-stable `_
and `musicbrainz-daily `_)
Your package manager will also handle the *libdiscid* dependency automatically.
PyPI
----
The next-best option is to load the Package from
`pypi `_
with `pip `_::
pip install discid
You still have to install `libdiscid`_.
Source Code
-----------
The code is available from `GitHub`_
as :source_download:`zip` and :source_download:`tar.gz`.
You can always get the latest code with :command:`git`::
git clone https://github.com/metabrainz/python-discid.git
Installation
************
You can use **python-discid** already when you put the folder :file:`discid`
in the same location you run your script from
or somewhere in your :envvar:`PYTHONPATH`.
System-wide installation from local source can be done with pip::
python -m pip install .
Running tests
*************
You can test your setup (including `libdiscid`_) with `pytest`_::
pytest
Some additional tests can be run that require the presence of a CD drive with an
inserted audio CD. The exact audio CD does not matter, any valid audio CD should work.
To run those tests set the environment variable ``PYTHON_DISCID_TEST_DEVICE`` to a
non-empty value and run pytest::
PYTHON_DISCID_TEST_DEVICE=1 pytest
.. _GitHub: https://github.com/metabrainz/python-discid
.. _pytest: https://pytest.org/
Libdiscid
---------
If you don't have a package manager
that takes care of the *libdiscid* dependency,
you have to download it manually.
You can find several builds and the source
at https://musicbrainz.org/doc/libdiscid.
If no build for your platform is available,
you have to build from source and install with::
cmake .
make
make install
If the last step doesn't work for you,
you might have to place the files :file:`discid.DLL`, :file:`libdiscid.*.dylib`
or :file:`libdiscid.so.*`
(depending on your platform)
in the same directory as you start your script from
or somewhere in your :envvar:`PATH`.
python-discid-1.4.2/doc/requirements.txt 0000664 0000000 0000000 00000064064 15224143223 0020335 0 ustar 00root root 0000000 0000000 # This file was autogenerated by uv via the following command:
# uv pip compile pyproject.toml -o doc/requirements.txt --group docs --generate-hashes --universal --python-version=3.10
alabaster==1.0.0 \
--hash=sha256:c00dca57bca26fa62a6d7d0a9fcce65f3e026e9bfe33e9c538fd3fbb2144fd9e \
--hash=sha256:fc6786402dc3fcb2de3cabd5fe455a2db534b371124f1f21de8731783dec828b
# via sphinx
babel==2.18.0 \
--hash=sha256:b80b99a14bd085fcacfa15c9165f651fbb3406e66cc603abf11c5750937c992d \
--hash=sha256:e2b422b277c2b9a9630c1d7903c2a00d0830c409c59ac8cae9081c92f1aeba35
# via sphinx
certifi==2026.6.17 \
--hash=sha256:024c88eeec92ca068db80f02b8b07c9cef7b9fe261d1d535abfd5abd6f6af432 \
--hash=sha256:2227dcbaafe0d2f59279d1762ddddc37783ed4354594f194ffc31d20f41fc3db
# via requests
charset-normalizer==3.4.9 \
--hash=sha256:0327fcd59a935777d83410750c50600ee9571af2846f71ce40f25b13da1ef380 \
--hash=sha256:03d07803992c6c7bbc976327f34b18b6160327fc81cb82c9d504720ac0be3b62 \
--hash=sha256:04ce310cb89c15df659582aee80a0603788732a5e017d5bd5c81158106ce249c \
--hash=sha256:0d861473f743244d349b50f850d10eb87aeb22bbdcc8e64f79273c94af5a8226 \
--hash=sha256:0e94703ec9684807f20cfb5eed95c70f67f2a8f21ad620146d7b5a13677b93e5 \
--hash=sha256:0fa1aec2d32bcc03c8fa0f6f1712caad1adc38509f31142112e5c9daf5b9c833 \
--hash=sha256:16b65ea0f2465b6fb52aa22de5eca612aa964ddfec00a912e26f4656cbef890b \
--hash=sha256:16d10d789dd9bcca1173c95af82c58433122564b7bc39385124be735a35cbe99 \
--hash=sha256:19ac87f93086ce37b86e098888555c4b4bc48102279bae3350098c0ed664b501 \
--hash=sha256:1d22856ffbe153a602df38e4a5464f0b748a54002e0d69ac6d2ad0a197cc99ec \
--hash=sha256:21e764fd1e70b6a3e205a0e46f3051701f98a8cb3fad66eeb80e48bb502f8698 \
--hash=sha256:231ddcbb35e2ff8973e1365db41fe0572662893b99a05deb183b68ad4c0c8bd4 \
--hash=sha256:253a4a220747e8b5faf57ec320c4f5efb0cef05f647420bf267143ec15dba10a \
--hash=sha256:280081916dc341820640489a66e4696049401ef1cf6dd672f672e70ad915aca3 \
--hash=sha256:2a441ea71902098ffe78c5abe6c494f44160b4af614ed16c3d9a3b1d17fd8ee2 \
--hash=sha256:304b13570067b2547562e308af560b3963857b1fa90bd6afd978130130fe2d6a \
--hash=sha256:32286a2c8d167e897177b673176c1e3e00d4057caf5d2b64eef9a3666b03018e \
--hash=sha256:33bdcc2a32c0a0e861f60841a512c8acc658c87c2ac59d89e3a46dacf7d866e4 \
--hash=sha256:375b83ed0aecfce76c16d198fbc21f3b11b337d68662bea0a995046682a11419 \
--hash=sha256:3c09a49d6cde137258beb3d551994a2927fd35ad5cf96aed573f61bbd67c5f84 \
--hash=sha256:3d92613ec25e43b05f042302531ec0f00b8445190e43325880cbd6ab7c2581da \
--hash=sha256:40a126142a56b2dfc0aacbad1de8310cbf60da7656db0e6b16eebd48e3e93519 \
--hash=sha256:416c229f77e5ea25b3dfd4b582f8d73d7e43c22320302b9ab128a2d3a0b38efe \
--hash=sha256:432786d3561e69aeeae6c7e8648964ce0ad05736120135601f87ac26b9c83381 \
--hash=sha256:43b9e366a31fdd1c87d0eb08f579b4a82b723ea54338f040d6b4e518a026ea29 \
--hash=sha256:440eede837960000d74978f0eba527be106b5b9aee0daf779d395276ed0b0614 \
--hash=sha256:45b0cc4e3556cd875e09102988d1ab8356c998b596c9fced84547c8138b487a0 \
--hash=sha256:476743fe6dfe14a2da12e3ac79125dc84a3b2cf8094369a47a1529b0cd8549fe \
--hash=sha256:4773092f8019072343a7447203308b176e10199920eb02d6195e81bbb3274c29 \
--hash=sha256:4b3dac63058cc36820b0dd072f89898604e2d39686fe05321729d00d8ac185a0 \
--hash=sha256:4d1c96a7a18b9690a4d46df09e3e3382406ae3213727cd1019ebade1c4a81917 \
--hash=sha256:51307f5c71007673a2bf8232ad973483d281e74cb99c8c5a990af1eefa6277d9 \
--hash=sha256:51447e9aa2684679af07ca5021c3db526e0284347ebf4ffcec1154c3350cfe32 \
--hash=sha256:58150c9f9b9a552505912d182ccdf26f6396fb6094816ceebcbb20eecabaed94 \
--hash=sha256:5b10cd92fc5c498b35a8635df6d5a100207f88b63a4dc1de7ef9a548e1e2cd63 \
--hash=sha256:5e226f6218febc71f6c1fc2fafb91c226f75bdc1d8fb12d66823716e891608fd \
--hash=sha256:609b3ba8fcc0fb5ab7af00719d0fb6ad0cb518e48e7712d12fd68f1327951198 \
--hash=sha256:60f44ade2cf573dad7a277e6f8ca9a51a21dda572b13bd7d8539bb3cd5dbedde \
--hash=sha256:611057cc5d5c0afc743ba8be6bd828c17e0aaa8643f9d0a9b9bb7dea80eb8012 \
--hash=sha256:6366a16e1a25018694d6a5d784d09b046edc9eac40ea2b54065c3052672516a1 \
--hash=sha256:65a7ff3f705e57d392f7261b6d0550fe137c3019477431f1c355e0db0a7d3e15 \
--hash=sha256:673611bbd43f0810bec0b0f028ddeaaa501190339cac411f347ac76917c3ae7b \
--hash=sha256:67830fc78e67501f47bb950471b2dcb9b35b140084429318e862895a8e89c993 \
--hash=sha256:68ce9f4d6b26d5ccbf7fd4459bf75f74a0a146677ebba80597df60cbdb20e6f4 \
--hash=sha256:68e5f26a1ad57ded6d1cfb85331d1c1a195314756471d97758c48498bb4dcdf5 \
--hash=sha256:69b157c5d3292bcd443faca052f3096f637f1e074b98212a933c074ae23dc3b8 \
--hash=sha256:75286256590a6320cf106a0d28970d3560aad9ee09aa7b34fb40524792436d35 \
--hash=sha256:78841cccf1af7b40f6f716338d50c0902dbe88d9f800b3c973b7a9a0a693a642 \
--hash=sha256:78fa18e436a1a0e58dbd7e02fc4473f3f32cceb12df9dfca542d075961c307d2 \
--hash=sha256:79580094b00d1789d1f93ea55bc43cb2f611910c72235b7657f3482ddcc1b22d \
--hash=sha256:7b86a2b16095d250c6f58b3d9b2eee6f4147754344f3dab0922f7c9bf7d226c9 \
--hash=sha256:83aed2c10721ddd90f68140685391b50811a880af20654c59af6b6c66c40513c \
--hash=sha256:84fd18bcc17526fc2b3c1af7d2b9217d32c9c04448c16ec693b9b4f1985c3d33 \
--hash=sha256:871ff67ea1aad4dfd91736464934d56b32dac49f9fbe16cddba36198a7b3a0db \
--hash=sha256:898f0e9068ca27d37f8e83a5b962821df851532e6c4a7d615c1c033f9da6eedf \
--hash=sha256:8a79d9f4d8001473a30c163556b3c3bfebec837495a412dde78b51672f6134f9 \
--hash=sha256:8c041122946b7ba21bb32c45b1aa57b1be35527690aeb3c5c234521085632eee \
--hash=sha256:90c44bc373b7687f6948b693cceaea1348ae0975d7474746559494468e3c1d84 \
--hash=sha256:9104ed0bd76a429d46f9ec0dbc9b08ad1d2dcdf2b00a5a0daa1c145329b35b44 \
--hash=sha256:920079c3f7456fa213e0829ed2073aaa727fd39d889ead5b4f35d0de5460d04f \
--hash=sha256:93d59d504b230e83c7a843251681959a0b6a9cd76f6e146ce1b8a80eb8739af9 \
--hash=sha256:9b2aff1c7b3884512b9512c3eaadd9bab39fb45042ffaaa1dd08ff2b9f8109d9 \
--hash=sha256:9b8e0f3107e2200b76f6054de99016eac3ee6762713587b36baaa7e4bd2ae177 \
--hash=sha256:9bb41182d93ea91f60b4bc8fbf4c820c69ef8a12ab2d917f3f1834f1acad07e8 \
--hash=sha256:9cdef90ae47919cae358d8ab15797a800ed41da7aba5d72419fb510729e2ed4b \
--hash=sha256:a1786910334ed46ab1dd73222f2cd1e05c2c3bb39f6dddb4f8b36fc382058a39 \
--hash=sha256:a4cfde78a9f2880208d16a93b795726a3017d5977e08d1e162a7a31322479c41 \
--hash=sha256:a4fbdde9dd4a9ce5fd52c2b3a347bb50cc89483ef783f1cb00d408c13f7a96c0 \
--hash=sha256:aa99adc8f081b475a12843953db36831eaf83ec33eb46a90629ca6a5de45a616 \
--hash=sha256:ac351b3b8014eead140e77e9717e2992c6bbe30b63bc3422422eb84865412e3d \
--hash=sha256:ad41ba96094304aa090f5a30cb6e4fb3b3f1c264c523394b4c39bbacc4dc92ba \
--hash=sha256:b5314963fce9b0b12743891de876e724997864ee22aa496f903f426c7e2fa5b2 \
--hash=sha256:bcf74c1df76758a395bf0af608c04c82257523f55c9868b334f06270d0f2112b \
--hash=sha256:bd47ba7fc3ca94896759ea0109775132d3e7ab921fbf54038e1bab2e46c313c9 \
--hash=sha256:c0323c9daef75ef2e5083624b4585018a0c9d5e3b40f607eed81a311270b934b \
--hash=sha256:c1225416b463483160e4af85d5fc3a9690ccb53fd4b1865a6437825f5ede3209 \
--hash=sha256:c1c948747b03be832dceed96ca815cef7360de9aa19d37c730f8e3f6101aca48 \
--hash=sha256:c25fe15c70c59eb7c5ce8c06a1f3fa1da0ecc5ea1e7a5922c40fd2fa9b0d5046 \
--hash=sha256:cc1b0fff8ead343dae06305f954eb8468ba0ec1a97881f42489d198e4ce3c632 \
--hash=sha256:cd6280cf040f233bd7d3407b743b4b4c74f70e8e1c4199cb112a62c941c0772a \
--hash=sha256:cd6c3d4b783c556fa00bf540854e42f135e2f256abd29669fcd0da0f2dec79c2 \
--hash=sha256:d4d6fcde76f94f5cb9e43e9e9a61f16dacefd228cbbf6f1a09bd9b219a92f1a1 \
--hash=sha256:ddf4af30b417d9fe16481e9b81c27ab2a7cde1ff7ba3e85653b02db7d145dc7b \
--hash=sha256:df115d4d83168fdf2cae48ef1ff6d1cb4c466364e30861b37121de0f3bf1b990 \
--hash=sha256:df7276909358e5635ae203673ab7e509ddd224225a8d6b0790bf13eb2bde1cc5 \
--hash=sha256:e4fd89cc178bced6ad29cb3e6dd4aa63fa5017c3524dbd0b25998fb64a87cc8b \
--hash=sha256:e9701d0049d92c16703a42771b98d560b95248949f23f8cf7b4eddd201814fb9 \
--hash=sha256:ee2f2a527e3c1a6e6411eb4209642e138b544a2d72fe5d0d76daf77b24063534 \
--hash=sha256:f7fb7d750cfa0a070d2c24e831fd3481019a60dd317ea2b39acbcebc08b6ed81 \
--hash=sha256:f840ed6d8ecba8255df8c42b87fadeda98ddfc6eeec05e2dc66e26d46dd6f58a \
--hash=sha256:f86c6358749bd4fda175388691e3ba8c46e24c5347d0afd20f9b7edfc9faf07d \
--hash=sha256:fa36ec09ef71d158186bc79e359ff5fdd6e7996fe8ab638f00d6b93139ba4fcf \
--hash=sha256:fe2c7201c642b7c308f1675355ad7ff7b66acfe3541625efe5a3ad38f29d6115
# via requests
colorama==0.4.6 ; sys_platform == 'win32' \
--hash=sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44 \
--hash=sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6
# via sphinx
docutils==0.21.2 ; python_full_version < '3.11' \
--hash=sha256:3a6b18732edf182daa3cd12775bbb338cf5691468f91eeeb109deff6ebfa986f \
--hash=sha256:dafca5b9e384f0e419294eb4d2ff9fa826435bf15f15b7bd45723e8ad76811b2
# via
# sphinx
# sphinx-rtd-theme
docutils==0.22.4 ; python_full_version >= '3.11' \
--hash=sha256:4db53b1fde9abecbb74d91230d32ab626d94f6badfc575d6db9194a49df29968 \
--hash=sha256:d0013f540772d1420576855455d050a2180186c91c15779301ac2ccb3eeb68de
# via
# sphinx
# sphinx-rtd-theme
idna==3.18 \
--hash=sha256:7f952cbe720b688055e3f87de14f5c3e5fdaa8bc3928985c4077ca689de849a2 \
--hash=sha256:ffb385a7e039654cef1ab9ef32c6fafe283c0c0467bba1d9029738ce4a14a848
# via requests
imagesize==2.0.0 \
--hash=sha256:5667c5bbb57ab3f1fa4bc366f4fbc971db3d5ed011fd2715fd8001f782718d96 \
--hash=sha256:8e8358c4a05c304f1fccf7ff96f036e7243a189e9e42e90851993c558cfe9ee3
# via sphinx
jinja2==3.1.6 \
--hash=sha256:0137fb05990d35f1275a587e9aee6d56da821fc83491a0fb838183be43f66d6d \
--hash=sha256:85ece4451f492d0c13c5dd7c13a64681a86afae63a5f347908daf103ce6d2f67
# via sphinx
markupsafe==3.0.3 \
--hash=sha256:0303439a41979d9e74d18ff5e2dd8c43ed6c6001fd40e5bf2e43f7bd9bbc523f \
--hash=sha256:068f375c472b3e7acbe2d5318dea141359e6900156b5b2ba06a30b169086b91a \
--hash=sha256:0bf2a864d67e76e5c9a34dc26ec616a66b9888e25e7b9460e1c76d3293bd9dbf \
--hash=sha256:0db14f5dafddbb6d9208827849fad01f1a2609380add406671a26386cdf15a19 \
--hash=sha256:0eb9ff8191e8498cca014656ae6b8d61f39da5f95b488805da4bb029cccbfbaf \
--hash=sha256:0f4b68347f8c5eab4a13419215bdfd7f8c9b19f2b25520968adfad23eb0ce60c \
--hash=sha256:1085e7fbddd3be5f89cc898938f42c0b3c711fdcb37d75221de2666af647c175 \
--hash=sha256:116bb52f642a37c115f517494ea5feb03889e04df47eeff5b130b1808ce7c219 \
--hash=sha256:12c63dfb4a98206f045aa9563db46507995f7ef6d83b2f68eda65c307c6829eb \
--hash=sha256:133a43e73a802c5562be9bbcd03d090aa5a1fe899db609c29e8c8d815c5f6de6 \
--hash=sha256:1353ef0c1b138e1907ae78e2f6c63ff67501122006b0f9abad68fda5f4ffc6ab \
--hash=sha256:15d939a21d546304880945ca1ecb8a039db6b4dc49b2c5a400387cdae6a62e26 \
--hash=sha256:177b5253b2834fe3678cb4a5f0059808258584c559193998be2601324fdeafb1 \
--hash=sha256:1872df69a4de6aead3491198eaf13810b565bdbeec3ae2dc8780f14458ec73ce \
--hash=sha256:1b4b79e8ebf6b55351f0d91fe80f893b4743f104bff22e90697db1590e47a218 \
--hash=sha256:1b52b4fb9df4eb9ae465f8d0c228a00624de2334f216f178a995ccdcf82c4634 \
--hash=sha256:1ba88449deb3de88bd40044603fafffb7bc2b055d626a330323a9ed736661695 \
--hash=sha256:1cc7ea17a6824959616c525620e387f6dd30fec8cb44f649e31712db02123dad \
--hash=sha256:218551f6df4868a8d527e3062d0fb968682fe92054e89978594c28e642c43a73 \
--hash=sha256:26a5784ded40c9e318cfc2bdb30fe164bdb8665ded9cd64d500a34fb42067b1c \
--hash=sha256:2713baf880df847f2bece4230d4d094280f4e67b1e813eec43b4c0e144a34ffe \
--hash=sha256:2a15a08b17dd94c53a1da0438822d70ebcd13f8c3a95abe3a9ef9f11a94830aa \
--hash=sha256:2f981d352f04553a7171b8e44369f2af4055f888dfb147d55e42d29e29e74559 \
--hash=sha256:32001d6a8fc98c8cb5c947787c5d08b0a50663d139f1305bac5885d98d9b40fa \
--hash=sha256:3524b778fe5cfb3452a09d31e7b5adefeea8c5be1d43c4f810ba09f2ceb29d37 \
--hash=sha256:3537e01efc9d4dccdf77221fb1cb3b8e1a38d5428920e0657ce299b20324d758 \
--hash=sha256:35add3b638a5d900e807944a078b51922212fb3dedb01633a8defc4b01a3c85f \
--hash=sha256:38664109c14ffc9e7437e86b4dceb442b0096dfe3541d7864d9cbe1da4cf36c8 \
--hash=sha256:3a7e8ae81ae39e62a41ec302f972ba6ae23a5c5396c8e60113e9066ef893da0d \
--hash=sha256:3b562dd9e9ea93f13d53989d23a7e775fdfd1066c33494ff43f5418bc8c58a5c \
--hash=sha256:457a69a9577064c05a97c41f4e65148652db078a3a509039e64d3467b9e7ef97 \
--hash=sha256:4bd4cd07944443f5a265608cc6aab442e4f74dff8088b0dfc8238647b8f6ae9a \
--hash=sha256:4e885a3d1efa2eadc93c894a21770e4bc67899e3543680313b09f139e149ab19 \
--hash=sha256:4faffd047e07c38848ce017e8725090413cd80cbc23d86e55c587bf979e579c9 \
--hash=sha256:509fa21c6deb7a7a273d629cf5ec029bc209d1a51178615ddf718f5918992ab9 \
--hash=sha256:5678211cb9333a6468fb8d8be0305520aa073f50d17f089b5b4b477ea6e67fdc \
--hash=sha256:591ae9f2a647529ca990bc681daebdd52c8791ff06c2bfa05b65163e28102ef2 \
--hash=sha256:5a7d5dc5140555cf21a6fefbdbf8723f06fcd2f63ef108f2854de715e4422cb4 \
--hash=sha256:69c0b73548bc525c8cb9a251cddf1931d1db4d2258e9599c28c07ef3580ef354 \
--hash=sha256:6b5420a1d9450023228968e7e6a9ce57f65d148ab56d2313fcd589eee96a7a50 \
--hash=sha256:722695808f4b6457b320fdc131280796bdceb04ab50fe1795cd540799ebe1698 \
--hash=sha256:729586769a26dbceff69f7a7dbbf59ab6572b99d94576a5592625d5b411576b9 \
--hash=sha256:77f0643abe7495da77fb436f50f8dab76dbc6e5fd25d39589a0f1fe6548bfa2b \
--hash=sha256:795e7751525cae078558e679d646ae45574b47ed6e7771863fcc079a6171a0fc \
--hash=sha256:7be7b61bb172e1ed687f1754f8e7484f1c8019780f6f6b0786e76bb01c2ae115 \
--hash=sha256:7c3fb7d25180895632e5d3148dbdc29ea38ccb7fd210aa27acbd1201a1902c6e \
--hash=sha256:7e68f88e5b8799aa49c85cd116c932a1ac15caaa3f5db09087854d218359e485 \
--hash=sha256:83891d0e9fb81a825d9a6d61e3f07550ca70a076484292a70fde82c4b807286f \
--hash=sha256:8485f406a96febb5140bfeca44a73e3ce5116b2501ac54fe953e488fb1d03b12 \
--hash=sha256:8709b08f4a89aa7586de0aadc8da56180242ee0ada3999749b183aa23df95025 \
--hash=sha256:8f71bc33915be5186016f675cd83a1e08523649b0e33efdb898db577ef5bb009 \
--hash=sha256:915c04ba3851909ce68ccc2b8e2cd691618c4dc4c4232fb7982bca3f41fd8c3d \
--hash=sha256:949b8d66bc381ee8b007cd945914c721d9aba8e27f71959d750a46f7c282b20b \
--hash=sha256:94c6f0bb423f739146aec64595853541634bde58b2135f27f61c1ffd1cd4d16a \
--hash=sha256:9a1abfdc021a164803f4d485104931fb8f8c1efd55bc6b748d2f5774e78b62c5 \
--hash=sha256:9b79b7a16f7fedff2495d684f2b59b0457c3b493778c9eed31111be64d58279f \
--hash=sha256:a320721ab5a1aba0a233739394eb907f8c8da5c98c9181d1161e77a0c8e36f2d \
--hash=sha256:a4afe79fb3de0b7097d81da19090f4df4f8d3a2b3adaa8764138aac2e44f3af1 \
--hash=sha256:ad2cf8aa28b8c020ab2fc8287b0f823d0a7d8630784c31e9ee5edea20f406287 \
--hash=sha256:b8512a91625c9b3da6f127803b166b629725e68af71f8184ae7e7d54686a56d6 \
--hash=sha256:bc51efed119bc9cfdf792cdeaa4d67e8f6fcccab66ed4bfdd6bde3e59bfcbb2f \
--hash=sha256:bdc919ead48f234740ad807933cdf545180bfbe9342c2bb451556db2ed958581 \
--hash=sha256:bdd37121970bfd8be76c5fb069c7751683bdf373db1ed6c010162b2a130248ed \
--hash=sha256:be8813b57049a7dc738189df53d69395eba14fb99345e0a5994914a3864c8a4b \
--hash=sha256:c0c0b3ade1c0b13b936d7970b1d37a57acde9199dc2aecc4c336773e1d86049c \
--hash=sha256:c47a551199eb8eb2121d4f0f15ae0f923d31350ab9280078d1e5f12b249e0026 \
--hash=sha256:c4ffb7ebf07cfe8931028e3e4c85f0357459a3f9f9490886198848f4fa002ec8 \
--hash=sha256:ccfcd093f13f0f0b7fdd0f198b90053bf7b2f02a3927a30e63f3ccc9df56b676 \
--hash=sha256:d2ee202e79d8ed691ceebae8e0486bd9a2cd4794cec4824e1c99b6f5009502f6 \
--hash=sha256:d53197da72cc091b024dd97249dfc7794d6a56530370992a5e1a08983ad9230e \
--hash=sha256:d6dd0be5b5b189d31db7cda48b91d7e0a9795f31430b7f271219ab30f1d3ac9d \
--hash=sha256:d88b440e37a16e651bda4c7c2b930eb586fd15ca7406cb39e211fcff3bf3017d \
--hash=sha256:de8a88e63464af587c950061a5e6a67d3632e36df62b986892331d4620a35c01 \
--hash=sha256:df2449253ef108a379b8b5d6b43f4b1a8e81a061d6537becd5582fba5f9196d7 \
--hash=sha256:e1c1493fb6e50ab01d20a22826e57520f1284df32f2d8601fdd90b6304601419 \
--hash=sha256:e1cf1972137e83c5d4c136c43ced9ac51d0e124706ee1c8aa8532c1287fa8795 \
--hash=sha256:e2103a929dfa2fcaf9bb4e7c091983a49c9ac3b19c9061b6d5427dd7d14d81a1 \
--hash=sha256:e56b7d45a839a697b5eb268c82a71bd8c7f6c94d6fd50c3d577fa39a9f1409f5 \
--hash=sha256:e8afc3f2ccfa24215f8cb28dcf43f0113ac3c37c2f0f0806d8c70e4228c5cf4d \
--hash=sha256:e8fc20152abba6b83724d7ff268c249fa196d8259ff481f3b1476383f8f24e42 \
--hash=sha256:eaa9599de571d72e2daf60164784109f19978b327a3910d3e9de8c97b5b70cfe \
--hash=sha256:ec15a59cf5af7be74194f7ab02d0f59a62bdcf1a537677ce67a2537c9b87fcda \
--hash=sha256:f190daf01f13c72eac4efd5c430a8de82489d9cff23c364c3ea822545032993e \
--hash=sha256:f34c41761022dd093b4b6896d4810782ffbabe30f2d443ff5f083e0cbbb8c737 \
--hash=sha256:f3e98bb3798ead92273dc0e5fd0f31ade220f59a266ffd8a4f6065e0a3ce0523 \
--hash=sha256:f42d0984e947b8adf7dd6dde396e720934d12c506ce84eea8476409563607591 \
--hash=sha256:f71a396b3bf33ecaa1626c255855702aca4d3d9fea5e051b41ac59a9c1c41edc \
--hash=sha256:f9e130248f4462aaa8e2552d547f36ddadbeaa573879158d721bbd33dfe4743a \
--hash=sha256:fed51ac40f757d41b7c48425901843666a6677e3e8eb0abcff09e4ba6e664f50
# via jinja2
packaging==26.2 \
--hash=sha256:5fc45236b9446107ff2415ce77c807cee2862cb6fac22b8a73826d0693b0980e \
--hash=sha256:ff452ff5a3e828ce110190feff1178bb1f2ea2281fa2075aadb987c2fb221661
# via sphinx
pygments==2.20.0 \
--hash=sha256:6757cd03768053ff99f3039c1a36d6c0aa0b263438fcab17520b30a303a82b5f \
--hash=sha256:81a9e26dd42fd28a23a2d169d86d7ac03b46e2f8b59ed4698fb4785f946d0176
# via sphinx
requests==2.34.2 \
--hash=sha256:2a0d60c172f83ac6ab31e4554906c0f3b3588d37b5cb939b1c061f4907e278e0 \
--hash=sha256:f288924cae4e29463698d6d60bc6a4da69c89185ad1e0bcc4104f584e960b9ed
# via sphinx
roman-numerals==4.1.0 ; python_full_version >= '3.11' \
--hash=sha256:1af8b147eb1405d5839e78aeb93131690495fe9da5c91856cb33ad55a7f1e5b2 \
--hash=sha256:647ba99caddc2cc1e55a51e4360689115551bf4476d90e8162cf8c345fe233c7
# via sphinx
snowballstemmer==3.1.1 \
--hash=sha256:7e207fa178741da09cdee59d3ecec3827ad5f92b1fc5c9ff3755b639f71f5752 \
--hash=sha256:e07bbc54a0d798fe6010a12398422e62a8bfbba95c394fd0956ef58cb4d3e260
# via sphinx
sphinx==8.1.3 ; python_full_version < '3.11' \
--hash=sha256:09719015511837b76bf6e03e42eb7595ac8c2e41eeb9c29c5b755c6b677992a2 \
--hash=sha256:43c1911eecb0d3e161ad78611bc905d1ad0e523e4ddc202a58a821773dc4c927
# via
# discid (pyproject.toml:docs)
# sphinx-autodoc-typehints
# sphinx-rtd-theme
# sphinxcontrib-jquery
sphinx==9.0.4 ; python_full_version == '3.11.*' \
--hash=sha256:594ef59d042972abbc581d8baa577404abe4e6c3b04ef61bd7fc2acbd51f3fa3 \
--hash=sha256:5bebc595a5e943ea248b99c13814c1c5e10b3ece718976824ffa7959ff95fffb
# via
# discid (pyproject.toml:docs)
# sphinx-autodoc-typehints
# sphinx-rtd-theme
# sphinxcontrib-jquery
sphinx==9.1.0 ; python_full_version >= '3.12' \
--hash=sha256:7741722357dd75f8190766926071fed3bdc211c74dd2d7d4df5404da95930ddb \
--hash=sha256:c84fdd4e782504495fe4f2c0b3413d6c2bf388589bb352d439b2a3bb99991978
# via
# discid (pyproject.toml:docs)
# sphinx-autodoc-typehints
# sphinx-rtd-theme
# sphinxcontrib-jquery
sphinx-autodoc-typehints==3.0.1 ; python_full_version < '3.11' \
--hash=sha256:4b64b676a14b5b79cefb6628a6dc8070e320d4963e8ff640a2f3e9390ae9045a \
--hash=sha256:b9b40dd15dee54f6f810c924f863f9cf1c54f9f3265c495140ea01be7f44fa55
# via discid (pyproject.toml:docs)
sphinx-autodoc-typehints==3.6.1 ; python_full_version == '3.11.*' \
--hash=sha256:dd818ba31d4c97f219a8c0fcacef280424f84a3589cedcb73003ad99c7da41ca \
--hash=sha256:fa0b686ae1b85965116c88260e5e4b82faec3687c2e94d6a10f9b36c3743e2fe
# via discid (pyproject.toml:docs)
sphinx-autodoc-typehints==3.12.1 ; python_full_version >= '3.12' \
--hash=sha256:4bbf6f6b907586d3b2a3ae2b23e0f86be939f19a7449e917d304df57ff9674d1 \
--hash=sha256:932472c9cc160e6a0dc34eca13d3d6a9823ed6e6dc505d7c12f6963c983cf8f6
# via discid (pyproject.toml:docs)
sphinx-rtd-theme==3.1.0 \
--hash=sha256:1785824ae8e6632060490f67cf3a72d404a85d2d9fc26bce3619944de5682b89 \
--hash=sha256:b44276f2c276e909239a4f6c955aa667aaafeb78597923b1c60babc76db78e4c
# via discid (pyproject.toml:docs)
sphinxcontrib-applehelp==2.0.0 \
--hash=sha256:2f29ef331735ce958efa4734873f084941970894c6090408b079c61b2e1c06d1 \
--hash=sha256:4cd3f0ec4ac5dd9c17ec65e9ab272c9b867ea77425228e68ecf08d6b28ddbdb5
# via sphinx
sphinxcontrib-devhelp==2.0.0 \
--hash=sha256:411f5d96d445d1d73bb5d52133377b4248ec79db5c793ce7dbe59e074b4dd1ad \
--hash=sha256:aefb8b83854e4b0998877524d1029fd3e6879210422ee3780459e28a1f03a8a2
# via sphinx
sphinxcontrib-htmlhelp==2.1.0 \
--hash=sha256:166759820b47002d22914d64a075ce08f4c46818e17cfc9470a9786b759b19f8 \
--hash=sha256:c9e2916ace8aad64cc13a0d233ee22317f2b9025b9cf3295249fa985cc7082e9
# via sphinx
sphinxcontrib-jquery==4.1 \
--hash=sha256:1620739f04e36a2c779f1a131a2dfd49b2fd07351bf1968ced074365933abc7a \
--hash=sha256:f936030d7d0147dd026a4f2b5a57343d233f1fc7b363f68b3d4f1cb0993878ae
# via sphinx-rtd-theme
sphinxcontrib-jsmath==1.0.1 \
--hash=sha256:2ec2eaebfb78f3f2078e73666b1415417a116cc848b72e5172e596c871103178 \
--hash=sha256:a9925e4a4587247ed2191a22df5f6970656cb8ca2bd6284309578f2153e0c4b8
# via sphinx
sphinxcontrib-qthelp==2.0.0 \
--hash=sha256:4fe7d0ac8fc171045be623aba3e2a8f613f8682731f9153bb2e40ece16b9bbab \
--hash=sha256:b18a828cdba941ccd6ee8445dbe72ffa3ef8cbe7505d8cd1fa0d42d3f2d5f3eb
# via sphinx
sphinxcontrib-serializinghtml==2.0.0 \
--hash=sha256:6e2cb0eef194e10c27ec0023bfeb25badbbb5868244cf5bc5bdc04e4464bf331 \
--hash=sha256:e9d912827f872c029017a53f0ef2180b327c3f7fd23c87229f7a8e8b70031d4d
# via sphinx
tomli==2.4.1 ; python_full_version < '3.11' \
--hash=sha256:01f520d4f53ef97964a240a035ec2a869fe1a37dde002b57ebc4417a27ccd853 \
--hash=sha256:0d85819802132122da43cb86656f8d1f8c6587d54ae7dcaf30e90533028b49fe \
--hash=sha256:136443dbd7e1dee43c68ac2694fde36b2849865fa258d39bf822c10e8068eac5 \
--hash=sha256:1d8591993e228b0c930c4bb0db464bdad97b3289fb981255d6c9a41aedc84b2d \
--hash=sha256:2190f2e9dd7508d2a90ded5ed369255980a1bcdd58e52f7fe24b8162bf9fedbd \
--hash=sha256:2c1c351919aca02858f740c6d33adea0c5deea37f9ecca1cc1ef9e884a619d26 \
--hash=sha256:36d2bd2ad5fb9eaddba5226aa02c8ec3fa4f192631e347b3ed28186d43be6b54 \
--hash=sha256:3d48a93ee1c9b79c04bb38772ee1b64dcf18ff43085896ea460ca8dec96f35f6 \
--hash=sha256:47149d5bd38761ac8be13a84864bf0b7b70bc051806bc3669ab1cbc56216b23c \
--hash=sha256:4ab97e64ccda8756376892c53a72bd1f964e519c77236368527f758fbc36a53a \
--hash=sha256:4b605484e43cdc43f0954ddae319fb75f04cc10dd80d830540060ee7cd0243cd \
--hash=sha256:504aa796fe0569bb43171066009ead363de03675276d2d121ac1a4572397870f \
--hash=sha256:51529d40e3ca50046d7606fa99ce3956a617f9b36380da3b7f0dd3dd28e68cb5 \
--hash=sha256:52c8ef851d9a240f11a88c003eacb03c31fc1c9c4ec64a99a0f922b93874fda9 \
--hash=sha256:559db847dc486944896521f68d8190be1c9e719fced785720d2216fe7022b662 \
--hash=sha256:5a881ab208c0baf688221f8cecc5401bd291d67e38a1ac884d6736cbcd8247e9 \
--hash=sha256:5cb41aa38891e073ee49d55fbc7839cfdb2bc0e600add13874d048c94aadddd1 \
--hash=sha256:5e262d41726bc187e69af7825504c933b6794dc3fbd5945e41a79bb14c31f585 \
--hash=sha256:5ee18d9ebdb417e384b58fe414e8d6af9f4e7a0ae761519fb50f721de398dd4e \
--hash=sha256:7008df2e7655c495dd12d2a4ad038ff878d4ca4b81fccaf82b714e07eae4402c \
--hash=sha256:734e20b57ba95624ecf1841e72b53f6e186355e216e5412de414e3c51e5e3c41 \
--hash=sha256:7c7e1a961a0b2f2472c1ac5b69affa0ae1132c39adcb67aba98568702b9cc23f \
--hash=sha256:7f86fd587c4ed9dd76f318225e7d9b29cfc5a9d43de44e5754db8d1128487085 \
--hash=sha256:7f94b27a62cfad8496c8d2513e1a222dd446f095fca8987fceef261225538a15 \
--hash=sha256:88dceee75c2c63af144e456745e10101eb67361050196b0b6af5d717254dddf7 \
--hash=sha256:8a650c2dbafa08d42e51ba0b62740dae4ecb9338eefa093aa5c78ceb546fcd5c \
--hash=sha256:8d65a2fbf9d2f8352685bc1364177ee3923d6baf5e7f43ea4959d7d8bc326a36 \
--hash=sha256:96481a5786729fd470164b47cdb3e0e58062a496f455ee41b4403be77cb5a076 \
--hash=sha256:a120733b01c45e9a0c34aeef92bf0cf1d56cfe81ed9d47d562f9ed591a9828ac \
--hash=sha256:b1d22e6e9387bf4739fbe23bfa80e93f6b0373a7f1b96c6227c32bef95a4d7a8 \
--hash=sha256:b8c198f8c1805dc42708689ed6864951fd2494f924149d3e4bce7710f8eb5232 \
--hash=sha256:c2541745709bad0264b7d4705ad453b76ccd191e64aa6f0fc66b69a293a45ece \
--hash=sha256:c742f741d58a28940ce01d58f0ab2ea3ced8b12402f162f4d534dfe18ba1cd6a \
--hash=sha256:c7f2c7f2b9ca6bdeef8f0fa897f8e05085923eb091721675170254cbc5b02897 \
--hash=sha256:d312ef37c91508b0ab2cee7da26ec0b3ed2f03ce12bd87a588d771ae15dcf82d \
--hash=sha256:d4d8fe59808a54658fcc0160ecfb1b30f9089906c50b23bcb4c69eddc19ec2b4 \
--hash=sha256:da25dc3563bff5965356133435b757a795a17b17d01dbc0f42fb32447ddfd917 \
--hash=sha256:eab21f45c7f66c13f2a9e0e1535309cee140182a9cdae1e041d02e47291e8396 \
--hash=sha256:eb0dc4e38e6a1fd579e5d50369aa2e10acfc9cace504579b2faabb478e76941a \
--hash=sha256:ec9bfaf3ad2df51ace80688143a6a4ebc09a248f6ff781a9945e51937008fcbc \
--hash=sha256:ede3e6487c5ef5d28634ba3f31f989030ad6af71edfb0055cbbd14189ff240ba \
--hash=sha256:f3c6818a1a86dd6dca7ddcaaf76947d5ba31aecc28cb1b67009a5877c9a64f3f \
--hash=sha256:f758f1b9299d059cc3f6546ae2af89670cb1c4d48ea29c3cacc4fe7de3058257 \
--hash=sha256:f8f0fc26ec2cc2b965b7a3b87cd19c5c6b8c5e5f436b984e85f486d652285c30 \
--hash=sha256:fd0409a3653af6c147209d267a0e4243f0ae46b011aa978b1080359fddc9b6cf \
--hash=sha256:ff18e6a727ee0ab0388507b89d1bc6a22b138d1e2fa56d1ad494586d61d2eae9 \
--hash=sha256:ff2983983d34813c1aeb0fa89091e76c3a22889ee83ab27c5eeb45100560c049
# via sphinx
urllib3==2.7.0 \
--hash=sha256:231e0ec3b63ceb14667c67be60f2f2c40a518cb38b03af60abc813da26505f4c \
--hash=sha256:9fb4c81ebbb1ce9531cce37674bbc6f1360472bc18ca9a553ede278ef7276897
# via requests
python-discid-1.4.2/doc/usage.rst 0000664 0000000 0000000 00000006321 15224143223 0016677 0 ustar 00root root 0000000 0000000 Usage
=====
Basic
-----
The basic use case is::
# this will load libdiscid
import discid
print(f"device: {discid.get_default_device()}")
disc = discid.read() # reads from default device
print(f"id: {disc.id}")
print(f"submission url:\n{disc.submission_url}")
You can also set the device explicitly::
device = discid.get_default_device()
disc = discid.read(device)
id = disc.id
You can use other devices of course: see :func:`read`.
When anything goes wrong reading from the device, :exc:`DiscError` is raised.
Advanced
--------
:mod:`discid` can do more than just provide the MusicBrainz Disc ID.
You can get details about the tracks an fetch additional features
like the ISRCs and the MCN, which is basically the EAN/UPC of the disc::
disc = discid.read(features=["mcn", "isrc"])
print(f"mcn: {disc.mcn}")
for track in disc.tracks:
print(f"{track.number:>2}: {track.isrc:13}")
Without Disc Access
-------------------
When you just want to generate disc IDs and you have the necessary data
laying around, you can use :func:`put`.
You will need the numbers of the first track (should be 1),
the number of the last audio track (cut off trailing data tracks),
the total number of sectors for these tracks
and the offset for every one of the tracks up to the last audio track.
An example for the TOC
`TqvKjMu7dMliSfmVEBtrL7sBSno- `_::
first = 1
last = 15
sectors = 258725
offsets = [150, 17510, ..., 235590]
disc = discid.put(first, last, sectors, offsets)
print(f"id: {disc.id}")
last_track = disc.tracks[disc.last_track_num - 1]
print(f"last track length: {last_track.seconds} seconds")
.. note:: The example disc has track 16 as a multimedia/data track.
The sector count for the disc is the ending sector for track 15!
Depending on how you get this number, you might need to substract
11400 (2:32 minutes) from your sector count.
Make sure the last track length is correct!
.. seealso:: :musicbrainz:`Disc ID Calculation` for details
on which numbers to choose.
.. _fetching_metadata:
Fetching Metadata
-----------------
You can use `python-musicbrainzngs`_ to fetch metadata for your disc.
The relevant function is :func:`musicbrainzngs.get_releases_by_discid`::
import discid
import musicbrainzngs
musicbrainzngs.set_useragent("python-discid-example", "0.1", "your@mail")
disc = discid.read()
try:
result = musicbrainzngs.get_releases_by_discid(disc.id,
includes=["artists"])
except musicbrainzngs.ResponseError:
print("disc not found or bad response")
else:
if result.get("disc"):
first_release = result["disc"]["release-list"][0]
print(f"artist:\t{first_release['artist-credit-phrase']}")
print(f"title:\t{first_release['title']}")
elif result.get("cdstub"):
cdstub = result["cdstub"]
print(f"artist:\t{cdstub['artist']}")
print(f"title:\t{cdstub['title']}")
You can fetch much more data.
See :mod:`musicbrainzngs` for details.
.. note:: Please submit your disc ID with :attr:`Disc.submission_url`
when it isn't found at the MusicBrainz server.
.. _python-musicbrainzngs: https://python-musicbrainzngs.readthedocs.org/
python-discid-1.4.2/examples.py 0000775 0000000 0000000 00000002317 15224143223 0016470 0 ustar 00root root 0000000 0000000 #!/usr/bin/env python
# Copyright (C) 2013 Johannes Dewender
# This example is free. You can redistribute and/or modify it at will.
# this will load Libdiscid
import discid
def simple_example():
disc = discid.read() # use default device
print(f"id: {disc.id}")
print(f"used {discid.get_default_device()} as device")
print(f"submit with:\n{disc.submission_url}")
def _length_str(seconds, sectors):
hours = seconds // 3600
seconds = seconds % 3600
if hours:
return f"{hours}:{seconds // 60:>02}:{seconds % 60:>02} ({sectors:>6})"
else:
return f" {seconds // 60:>2}:{seconds % 60:>02} ({sectors:>6})"
def complex_example():
device_name = discid.get_default_device()
disc = discid.read(device_name, ["mcn", "isrc"])
print(f"device:\t{device_name}")
print(f"id:\t{disc.id}")
print(f"MCN:\t{disc.mcn}")
print(f"length:\t{_length_str(disc.seconds, disc.sectors)}")
for track in disc.tracks:
length = _length_str(track.seconds, track.sectors)
print(f"{track.number:>2}: {track.offset:>6} {length}\tISRC: {track.isrc}")
if __name__ == "__main__":
# simple_example()
complex_example()
# vim:set shiftwidth=4 smarttab expandtab:
python-discid-1.4.2/pyproject.toml 0000664 0000000 0000000 00000002712 15224143223 0017210 0 ustar 00root root 0000000 0000000 [build-system]
requires = ["setuptools>=77.0.3"]
build-backend = "setuptools.build_meta"
[project]
name = "discid"
version = "1.4.2"
description = "Python binding of Libdiscid"
authors = [
{name = "Johannes Dewender", email = "brainz@JonnyJD.net"},
{name = "Philipp Wolfer", email = "ph.wolfer@gmail.com"},
]
requires-python = ">=3.10"
readme = "README.rst"
license = "LGPL-3.0-or-later"
license-files = ["COPYING.LESSER"]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Topic :: Multimedia :: Sound/Audio :: CD Audio :: CD Ripping",
"Topic :: Software Development :: Libraries :: Python Modules",
"Typing :: Typed",
]
[project.urls]
Documentation = "https://python-discid.readthedocs.org/"
Repository = "https://github.com/metabrainz/python-discid"
Issues = "https://github.com/metabrainz/python-discid/issues"
Changelog = "https://github.com/metabrainz/python-discid/blob/master/CHANGES.rst"
Funding = "https://metabrainz.org/donate"
[dependency-groups]
test = ["pytest"]
docs = [
"Sphinx>=8.1.3",
"sphinx-autodoc-typehints>=3.0.1",
"sphinx-rtd-theme>=3.0.2",
]
dev = [
"pre-commit>=4.5.1",
"ruff>=0.14.13",
]
[tool.setuptools.package-data]
discid = ["py.typed"]
[tool.ruff]
src=["discid"]
[tool.ruff.lint]
select = ["E", "F", "B", "I", "UP", "RUF", "PYI", "PERF"]
python-discid-1.4.2/test_discid.py 0000775 0000000 0000000 00000027010 15224143223 0017145 0 ustar 00root root 0000000 0000000 #!/usr/bin/env python
# Copyright (C) 2013 Johannes Dewender
# Copyright (C) 2017 Frederik “Freso” S. Olesen
# Copyright (C) 2025, 2026 Philipp Wolfer
# This test is free. You can redistribute and/or modify it at will.
import math
import os
import unittest
from collections.abc import Sequence
from dataclasses import dataclass
import discid
import discid.util
@dataclass
class DiscTestData:
name: str
first: int
last: int
sectors: int
offsets: Sequence[int]
id: str
freedb: str
test_discs = [
DiscTestData(
name="Guano Apes - Don't give Me Names, without last data track",
first=1,
last=15,
sectors=258725,
offsets=[
150,
17510,
33275,
45910,
57805,
78310,
94650,
109580,
132010,
149160,
165115,
177710,
203325,
215555,
235590,
],
id="TqvKjMu7dMliSfmVEBtrL7sBSno-",
freedb="b60d770f",
),
DiscTestData(
name="Lunar - There Is No 1, first track is 2",
first=2,
last=11,
sectors=225781,
offsets=(
150,
11512,
34143,
50747,
63640,
98491,
123534,
174410,
195438,
201127,
),
id="6RDuz0d7.M5SVMLe1z4DP0yaEC8-",
freedb="840bc20b",
),
DiscTestData(
name="Minimal",
first=1,
last=1,
sectors=44942,
offsets=[150],
id="ANJa4DGYN_ktpzOwvVPtcjwP7mE-",
freedb="02025501",
),
DiscTestData(
name="Korn - See You on the Other Side, with pre-gap audio track",
first=1,
last=14,
sectors=275749,
offsets=[
5475,
19645,
34416,
51655,
68900,
90015,
111090,
130510,
158652,
173635,
189015,
208122,
224413,
252866,
],
id="CnkXRItZOUxex7JwyWmHfdbFdqE-",
freedb="be0e130e",
),
]
class TestModulePrivate(unittest.TestCase):
# lots of encoding tests
# not part of the actual API, but used internally to handle both bytes and str
def test_encode(self):
self.assertTrue(type(discid.util._encode("test")) is bytes)
self.assertEqual(discid.util._encode("test"), b"test")
self.assertEqual(discid.util._encode(b"test"), b"test")
with self.assertRaises(TypeError):
discid.util._encode(42) # type: ignore
def test_decode(self):
self.assertTrue(type(discid.util._decode(b"test")) is str)
self.assertEqual(discid.util._decode(b"test"), "test")
self.assertEqual(discid.util._decode("test"), "test")
with self.assertRaises(TypeError):
discid.util._encode(42) # type: ignore
def test_encoding(self):
string = "test"
self.assertEqual(discid.util._decode(discid.util._encode(string)), string)
bytestring = b"test"
self.assertEqual(
discid.util._encode(discid.util._decode(bytestring)), bytestring
)
def test_sectors_to_seconds(self):
self.assertEqual(0, discid.util._sectors_to_seconds(0))
self.assertEqual(
1, discid.util._sectors_to_seconds(discid.util.SECTORS_PER_SECOND)
)
self.assertEqual(
1, discid.util._sectors_to_seconds(discid.util.SECTORS_PER_SECOND / 2)
)
self.assertEqual(
0,
discid.util._sectors_to_seconds((discid.util.SECTORS_PER_SECOND / 2) - 0.1),
)
self.assertIsInstance(discid.util._sectors_to_seconds(90.5), int)
class TestModule(unittest.TestCase):
def test_version_string(self):
version_string = discid.LIBDISCID_VERSION_STRING
self.assertTrue(version_string is not None, "No version string given")
def test_default_device(self):
device = discid.get_default_device()
self.assertTrue(device is not None, "No default device given")
def test_features(self):
features = discid.FEATURES
self.assertTrue(features is not None, "No feature list given")
def test_features_implemented(self):
features = discid.FEATURES_IMPLEMENTED
self.assertTrue(features, "No feature list implemented")
def test_invalid_device(self):
device = "non_existing_device"
self.assertRaises(discid.DiscError, discid.read, device)
def test_device_encoding(self):
device = b"non_existing_device".decode()
self.assertRaises(discid.DiscError, discid.read, device)
devicebytes = b"non_existing_device"
self.assertRaises(discid.DiscError, discid.read, devicebytes)
def test_put_fail(self):
# not enough offsets
self.assertRaises(discid.TOCError, discid.put, 1, 2, 150, [150])
# too many offsets
self.assertRaises(discid.TOCError, discid.put, 1, 2, 1000, [150, 500, 750])
# total sectors / offset mismatch
self.assertRaises(discid.TOCError, discid.put, 1, 2, 150, [150, 500])
# too many tracks
self.assertRaises(discid.TOCError, discid.put, 98, 100, 2000, [150, 500, 750])
def test_put_success(self):
for test_disc in test_discs:
disc = discid.put(
test_disc.first,
test_disc.last,
test_disc.sectors,
test_disc.offsets,
)
self.assertEqual(disc.id, test_disc.id)
self.assertEqual(disc.freedb_id, test_disc.freedb)
self.assertEqual(disc.first_track_num, test_disc.first)
self.assertEqual(disc.last_track_num, test_disc.last)
self.assertEqual(disc.pregap, test_disc.offsets[0])
self.assertEqual(disc.sectors, test_disc.sectors)
track_offsets = [track.offset for track in disc.tracks]
self.assertEqual(track_offsets, list(test_disc.offsets))
self.assertEqual(
disc.sectors, disc.tracks[-1].offset + disc.tracks[-1].sectors
)
self.assertEqual(disc.seconds, math.floor((disc.sectors / 75.0) + 0.5))
self.assertEqual(type(disc.seconds), int)
for track in disc.tracks:
self.assertEqual(
track.seconds, math.floor((track.sectors / 75.0) + 0.5)
)
self.assertEqual(type(track.seconds), int)
toc = [test_disc.first, disc.last_track_num, disc.sectors, *track_offsets]
toc_string = " ".join(map(str, toc))
self.assertEqual(disc.toc_string, toc_string)
cddb_query = [
disc.freedb_id,
disc.last_track_num,
*track_offsets,
disc.seconds,
]
cddb_query_string = " ".join(map(str, cddb_query))
self.assertEqual(disc.cddb_query_string, cddb_query_string)
@unittest.skipUnless(
os.environ.get("PYTHON_DISCID_TEST_DEVICE"),
"tests require physical CD drive with inserted disc",
)
class TestDisc(unittest.TestCase):
"""Test reading the disc currently in the drive"""
def test_default_device(self):
# Can't be empty, in contrast to the test in TestModule
device = discid.get_default_device()
self.assertTrue(device, "No default device given")
def test_features(self):
# Can't be empty, in contrast to the test in TestModule
features = discid.FEATURES
self.assertTrue(features, "No feature list given")
def test_read_simple(self):
disc = discid.read() # read from default drive
self.assertEqual(len(disc.id), 28, "Invalid Disc ID")
self.assertEqual(len(disc.freedb_id), 8, "Invalid FreeDB Disc ID")
self.assertTrue(disc.submission_url, "Invalid submission url")
self.assertTrue(disc.toc_string, "Invalid toc string")
self.assertEqual(
disc.last_track_num, len(disc.tracks), "Wrong amount of tracks"
)
self.assertEqual(disc.sectors, disc.tracks[-1].offset + disc.tracks[-1].sectors)
self.assertEqual(disc.pregap, disc.tracks[0].offset)
for track in disc.tracks:
self.assertTrue(track.offset <= disc.sectors, "Invalid offset")
if track.number > 1:
previous_offset = disc.tracks[track.number - 2].offset
self.assertTrue(
track.offset >= previous_offset, "Invalid offset series"
)
# additional features should be unset, not empty
self.assertTrue(disc.mcn is None)
for track in disc.tracks:
self.assertTrue(track.isrc is None)
# check idempotence (use output again as input to put)
disc_id = disc.id
freedb_id = disc.freedb_id
submission_url = disc.submission_url
toc_string = disc.toc_string
first = disc.first_track_num
last = disc.last_track_num
sectors = disc.sectors
track_sectors = [track.sectors for track in disc.tracks]
track_offsets = [track.offset for track in disc.tracks]
cddb_query_string = disc.cddb_query_string
disc = discid.put(first, last, sectors, track_offsets)
self.assertEqual(disc.id, disc_id, "different id after put")
self.assertEqual(disc.freedb_id, freedb_id, "different freedb id after put")
self.assertEqual(
disc.submission_url, submission_url, "different submission_url after put"
)
self.assertEqual(disc.toc_string, toc_string, "different toc_string after put")
self.assertEqual(disc.first_track_num, first, "different first track after put")
self.assertEqual(disc.last_track_num, last, "different last track after put")
self.assertEqual(disc.sectors, sectors, "different sector count after put")
new_offsets = [track.offset for track in disc.tracks]
self.assertEqual(new_offsets, track_offsets, "different offsets after put")
new_sectors = [track.sectors for track in disc.tracks]
self.assertEqual(new_sectors, track_sectors, "different lengths after put")
self.assertEqual(
disc.cddb_query_string,
cddb_query_string,
"different cddb_query_string after put",
)
def test_read_features(self):
disc = discid.read(features=["mcn", "isrc"]) # read from default drive
self.assertEqual(len(disc.id), 28, "Invalid Disc ID")
self.assertTrue(disc.submission_url, "Invalid submission url")
self.assertTrue(disc.toc_string, "Invalid toc string")
if "mcn" in discid.FEATURES:
self.assertTrue(disc.mcn is not None)
else:
self.assertTrue(disc.mcn is None)
for track in disc.tracks:
if "isrc" in discid.FEATURES:
self.assertTrue(track.isrc is not None)
else:
self.assertTrue(track.isrc is None)
def test_read_put(self):
# a read followed with a put, which should clear the features
disc = discid.read(features=["mcn", "isrc"]) # read from default drive
test_disc = test_discs[0]
disc = discid.put(
test_disc.first,
test_disc.last,
test_disc.sectors,
test_disc.offsets,
)
self.assertTrue(disc.mcn is None)
for track in disc.tracks:
self.assertTrue(track.isrc is None)
if __name__ == "__main__":
unittest.main()
# vim:set shiftwidth=4 smarttab expandtab: