Python OO interface to libcdio (CD Input and Control library)
Project description
Introduction
pycdio is a Python interface to the libcdio, the CD Input and Control library http://www.gnu.org/software/libcdio
You can get the source at the same place as libcdio: ftp://ftp.gnu.org:/pub/gnu/libcdio/
The pycdio and libcdio libraries encapsulate CD-ROM reading and control. Python programs wishing to be oblivious of the OS- and device-dependent properties of a CD-ROM can use this library.
Sample Usage
Getting CD-ROM Drive Information
import sys
import cdio, pycdio
try:
d = cdio.Device(driver_id=pycdio.DRIVER_UNKNOWN)
drive_name = d.get_device()
except IOError:
print("Problem finding a CD-ROM")
sys.exit(1)
ok, vendor, model, release = d.get_hwinfo()
print("drive: %s, vendor: %s, model: %s, release: %s" \
% (drive_name, vendor, model, release))
# Show CD-Text for an audio CD
cdt = d.get_cdtext()
i_tracks = d.get_num_tracks()
i_first_track = pycdio.get_first_track_num(d.cd)
for t in range(i_first_track, i_tracks + i_first_track):
for i in range(pycdio.MIN_CDTEXT_FIELD, pycdio.MAX_CDTEXT_FIELDS):
value = cdt.get(i, t)
# value can be empty but exist, compared to NULL values
if value is not None:
print("\t%s: %s" % (pycdio.cdtext_field2str(i), value))
pass
pass
pass
return
d.close()
Other sample code can be found in the example directory of the distribution.
Requirements
A C compiler so the extension can be compiled when it is installed.
libcdio (http://www.gnu.org/software/libcdio) and it’s header files installed.
SWIG http://www.swig.org
pkg-config http://pkg-config.freedesktop.org
To build on Debian (e.g. Ubuntu):
$ apt-get install python-dev $ apt-get install libcdio-dev $ apt-get install libiso9660-dev $ apt-get install swig pkg-config $ pip install -e . $ make check
SWIG Problems
I’ve tried to make this work back to Python 2.3 or so.
I’ve noticed however problems in various distutils.
If you see a message like this when running make check:
File "/home/rocky/.pyenv/versions/3.5.6/lib/python3.5/distutils/unixccompiler.py", line 207, in library_dir_option return "-L" + dir TypeError: Can't convert 'bytes' object to str implicitly
Copy in a recent distutils unixccompiler.py like this:
$ cp admin-tools/unixccompiler.py /home/rocky/.pyenv/versions/3.5.6/lib/python3.5/distutils/unixccompiler.py
The distutils distribution says that it tries to be compatible with all Python versions from 2.3. The unixccompiler.py in admin_tools is from the Python 3.7.4 distribution.
Completeness
libcdio is rather large and yet may still grow a bit.
What is in pycdio is incomplete; over time it may grow to completion depending on various factors: e.g. interest, whether others help out.
Sections of libcdio that are currently missing are the (SCSI) MMC commands, and the cdparanoia library. Of the audio controls, I put in those things that didn’t require any thought. The ISO 9660 library is pretty complete, except file stat() information which is at present is pretty minimal.
That said, what’s in there is very usable. It contains probably more access capabilities than what most media players that don’t use libcdio have.
The encapsulation by SWIG is done in two parts. The lower-level python interface is called pycdio and is generated by SWIG.
The more object-oriented module is cdio; it is a Python class that uses pycdio. Although pycdio is perfectly usable on its own, it is expected that cdio is what most people will use. As pycdio more closely models the C interface, it is conceivable (if unlikely) that diehard libcdio C users who are very familiar with that interface could prefer that.
It is probably possible to change the SWIG in such a way to combine these pieces. However there are the problems. First, I’m not that much of a SWIG expert. Second it looks as though the resulting SWIG code would be more complex. Third the separation makes translation very straight forward to understand and maintain: first get what’s in C into Python as a one-to-one translation. Then we implement some nice abstraction off of that. The abstraction can be modified without having to redo the underlying translation. (But the reverse is generally not true: usually changes to the C-to-python translation, pycdio, do result in small, but obvious and straightforward changes to the abstraction layer cdio.)
There is much to be done - you want to help out, please do so!
Standalone documentation is missing although many of the methods, classes and functions have some document strings. See also the programs in the example directory.
pycdio for enterprise
Available as part of the Tidelift Subscription.
The maintainers of pycdio and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.
Security contact information
To report a security vulnerability, please use the Tidelift security contact and Tidelift will coordinate the fix and disclosure.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file pycdio-2.1.1.tar.gz
.
File metadata
- Download URL: pycdio-2.1.1.tar.gz
- Upload date:
- Size: 246.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61734db8c554b7b1a2cb2da2e2c15d3f9f5973a57cfb06f8854c38029004a9f8 |
|
MD5 | 0d0e293ad18ecdda2c04a2afb95bd28c |
|
BLAKE2b-256 | 7302e482cd03681c641aba3863216029814443c023ac772ea5c638b3ff8e699f |
File details
Details for the file pycdio-2.1.1-py3.9-linux-x86_64.egg
.
File metadata
- Download URL: pycdio-2.1.1-py3.9-linux-x86_64.egg
- Upload date:
- Size: 464.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e72c896cc02b2282e6fdc66b16682820e8bb8d0764ca3efbd43481a450c02432 |
|
MD5 | d238dbd0707dffb75baf46403fac9592 |
|
BLAKE2b-256 | c49daaff18c098fb6a9ab7f98beaf3e8291858d006af7dc49716421553ea236c |
File details
Details for the file pycdio-2.1.1-py3.8-linux-x86_64.egg
.
File metadata
- Download URL: pycdio-2.1.1-py3.8-linux-x86_64.egg
- Upload date:
- Size: 457.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea304e496c91c6eab219c053e9cad8b976bac70df9e43e5b362787c33a3f445d |
|
MD5 | 169808b9c8b87195f4cd3bbf11f7467c |
|
BLAKE2b-256 | a09779c087f08e8f35ab80e511d1389ac35d680b6f9266afaa54adb91570f889 |
File details
Details for the file pycdio-2.1.1-py3.7-linux-x86_64.egg
.
File metadata
- Download URL: pycdio-2.1.1-py3.7-linux-x86_64.egg
- Upload date:
- Size: 446.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18c34df4f05064037c264310791a96f63d5b69de69cda87720e0e9a6c0ad320b |
|
MD5 | f5377d83d86e2d33d7af89717d781c07 |
|
BLAKE2b-256 | 70156a654ae04d9cec38650f83dd4c5e4fd610a6671782c1758ade3ee674ad2f |
File details
Details for the file pycdio-2.1.1-py3.6-linux-x86_64.egg
.
File metadata
- Download URL: pycdio-2.1.1-py3.6-linux-x86_64.egg
- Upload date:
- Size: 444.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f5adf9076b985cd47bdeca365f020abdb9e400a1d90effab3832b23f496ab94 |
|
MD5 | 583195ef19718832bd51f5bfc2b6608f |
|
BLAKE2b-256 | 0974096e9474bbb72f0b522c9d32bef2ad3b0184ec3493ef899652767b2a69dc |
File details
Details for the file pycdio-2.1.1-py3.5-linux-x86_64.egg
.
File metadata
- Download URL: pycdio-2.1.1-py3.5-linux-x86_64.egg
- Upload date:
- Size: 444.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1da96ffca622e0a057e27408afe5de79b5f8eadd1de41e70eebdaf3070fbb8ca |
|
MD5 | b4cbd08844e2e9dc0631d758eea86016 |
|
BLAKE2b-256 | 755b0a6cd14c274b48bf95b3e6aad1dd5f824c13a3be99f0f1b37ff94bab5910 |
File details
Details for the file pycdio-2.1.1-py3.3-linux-x86_64.egg
.
File metadata
- Download URL: pycdio-2.1.1-py3.3-linux-x86_64.egg
- Upload date:
- Size: 438.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95bb4d60a5a5390b6be1c1505f714043f0afc29c3aebc5142718aca98b8fd8ef |
|
MD5 | 3d395e35ada9b24afc4291ad318e2459 |
|
BLAKE2b-256 | caba1e9cb42a9c06f428ab83ca9346d186d6e292ce557801954bc352bf26b942 |
File details
Details for the file pycdio-2.1.1-py2.7-linux-x86_64.egg
.
File metadata
- Download URL: pycdio-2.1.1-py2.7-linux-x86_64.egg
- Upload date:
- Size: 438.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ec0d413ede189429c9f1e0d6cce559de2ef12eb8b0ad7478a163c3a663255c7 |
|
MD5 | 3d7aa3190ac7142242196be9bb9a8b4d |
|
BLAKE2b-256 | 1646aea3a36aa20923f48083a75f284dc4e5a2a3e217bbb4f4486ea5f147ddee |