suaveant has asked for the wisdom of the Perl Monks concerning the following question:

A friend asked me about making a program to generate a catalog of cds using the cddb. This would be very simple under linux, however, they need a windows solution. The modules that do this don't seem to play nice with windows, however, due to fcntl issues. Apparently windows does not define the macro O_NONBLOCK which CDDB_get needs (NT 4.0 at least).

The CDDB stuff most likely works fine... it is the cd table of contents gathering that seems defunct. Does anyone know of a way to gather this info into perl on windows? (either perl code or a command line prog?)

                - Ant
                - Some of my best work - (1 2 3)

Replies are listed 'Best First'.
Re: CDDB info on Windows
by particle (Vicar) on May 05, 2003 at 15:58 UTC

    check out WebService::FreeDB. it's OO and easy to add functionality via subclassing--i'm quite happy with it. i downloaded it last week, and i'm in the process of writing a script to catalog my collection in my free time.

    ~Particle *accelerates*

      The problem is that this module only queries the cddb for keywords artist/title stuff. Too much work. I want to set it up so you simply pop in the disc, get the TOC, and query the cddb with that. Much the way winamp and the like do it. I could do it no problem in linux. But not so easily in windows.

                      - Ant
                      - Some of my best work - (1 2 3)

        It's not a Perl solution, but I use a program called CDex on my windows machine to make MP3s for my player and PC at the office. It is fairly fast at getting the CDDB info when you pop in a disc.

        Hope that helps.

        There is no emoticon for what I'm feeling now.

Re: CDDB info on Windows
by hardburn (Abbot) on May 05, 2003 at 15:53 UTC

    You could hunt through the current CDDB module and pick out the no-blocking fcntl stuff, preferablly converted to something nearly equivilent on Win32. If you do, it'd be great if it was released as a new ...::Win32 module.

    ----
    I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
    -- Schemer

    Note: All code is untested, unless otherwise stated

      Well.. I also noticed that it was looking at /dev/cdrom for the cdrom device, which I doubt works on windows. I'm a linux man, myself, and have no idea how to access cd info in windows from a perl script.

                      - Ant
                      - Some of my best work - (1 2 3)

Re: CDDB info on Windows
by PodMaster (Abbot) on May 06, 2003 at 07:45 UTC
    That's easy. Use CDDB-1.08 along with Win32::API. Check out Win32-MCI-CD-0.02 and then do some research to figure out how to get the TOC (should be a matter of looking it up in the manual)

    If you can't figure out how to do it using Win32::API (at one point I was looking into how to do it, but I lost interest -- it is possible using mci), i think you should be able to extract the info you need using cdlib-0.4.4 (i looked into writing a wrapper to the library, but it's easier to just use the binary, cdlib.exe)

    update: Here's how the pythong folks do it http://cddb-py.sourceforge.net/CDDB/win32/mci.c.

    Between this and the CDA details from http://www.wotsit.org, you read the info you need and feed it to CDDB to query by "id".

    update: I have written Get CDDB info on Win32.

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.