Giter Club home page Giter Club logo

pycdio's Introduction

Package Status 1 Package Status 2 Pypi Installs

Introduction

arcctgx-pycdio is a fork of pycdio: a Python interface to the libcdio, the CD Input and Control library http://www.gnu.org/software/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.

This fork makes no functional changes to pycdio, and only provides Python wheels to make the installation convenient for the end user. Upstream only provides a source distribution which requires the end user to set up the environment to build the extension from source.

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

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's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.