---
name: "FreeDB"
section: "3pm"
platform: "linux"
package: "libfreedb-perl"
version: "1.1.4-3"
release: "Debian 3.0 (Woody)"
platforms: ["linux"]
url: "https://new.carta.tech/FreeDB"
---

# FreeDB(3pm)

Perl extension for accessing the free internet database of CD information

## NAME

FreeDB.pm - Perl extension for accessing the free internet database of CD information

## SYNOPSIS

```
  use FreeDB;
```

```
  my $cddb = new FreeDB;
  my $success = 0;
```

```
  $success = $cddb->fetch;
```

```
  if (!$success) {
     print "couldn't fetch cd info\n";
     exit 1;
  }
```

```
  print $cddb->artist . "\n";
  print $cddb->title  . "\n\n";
```

```
  while ($cddb->next_track) {
     print $cddb->current_track_number_padded, ". ";
     print $cddb->current_track_info;
     print " (", $cddb->current_track_time_in_minutes, ")\n";
  }
```

```
  print "\n\n", $cddb->disc_info, "\n";
```

## VERSION

- Version 1.0.1

  ## ITERATIVE METHODS

- **next\_track**

  Tells FreeDB to advance to the next track on the cd. You must call this before calling any of the current\_\* methods to set FreeDB on the first track. This way you can conveniently use this method in a while loop.  Returns the track\_number or 0 when you run out of tracks.\

- **current\_track\_info**

  Returns the track info for the current track.\

- **current\_track\_number**

  Returns the number of the current track. You can give a specific track number to set FreeDB on a particular track. \

- **current\_track\_number\_padded**

  Returns the number of the current track in 2 digit format. That is, 9 will print as 09 if you call this method.\

- **current\_track\_extended\_info**

  Returns any extended info that the current track may have in its record.\

- **current\_track\_detailed\_info**

  Returns all relevant info for the current track-- number, info, extended info, and time in seconds.\

- **current\_track\_time\_in\_minutes**

  Returns the track's length in minutes.\

- **current\_track\_time\_in\_seconds**

  Returns the track's length in seconds.\

- **current\_track\_offset**

  ## CONFIGURATION METHODS

- **cddb\_server**

  This sets and gets the full URL for the cddb server. `$cddb`-\>*new()* sets this for you, but you can customize it by setting it after you call `$cddb`-\>*new()* and before you call `$cddb`-\>*fetch()*.\

- **cdrom\_device**

  The device that corresponds to your cdrom drive (eg /dev/cdrom). )$cddb-\>*new()* sets this for you, but you can customize it by setting it after you call `$cddb`-\>*new()* and before you call `$cddb`-\>*fetch()*.\

- **cache\_directory**

  The directory where FreeDB will cache fetched records for you (eg ~/.cddb). `$cddb`-\>*new()* sets this for you, but you can customize it by setting it after you call `$cddb`-\>*new()* and before you call `$cddb`-\>*fetch()*.\

- **ignore\_cache**

  Set this to a non-zero value if you want to force FreeDB to make a trip to the server and not attempt to load your disc's record from the local cache. `$cddb`-\>*new()* sets this to 0, but you can customize it by setting it after you call `$cddb`-\>*new()* and before you call `$cddb`-\>*fetch()*.\

- **proxy\_value**

  $cddb-\>*new()* sets this to "", but if you need to go through a proxy, you can customize it by setting it after you call `$cddb`-\>*new()* and before you call `$cddb`-\>*fetch()*.

## OTHER METHODS

- **fetch**

  This is the method that actually goes and gets the record (either from the server or your local cache). It returns 1 on success or 0 on failure. Optionally you can give a cddb entry as argument. It will use this information and consequently does not look at the cdrom device, cache, or cddb server.\

- **create\_new**

  Creates a new \

- **artist**

  Returns the disc's artist. Big surprise there.\

- **discid**

  Returns the discid that FreeDB uses as a a filename for your locally cached disc record.\

- **disc\_info**

  Returns info from the EXTD field of the record\

- **title**

  Returns the disc's title. We're just full of surprises today.\

- **disc\_length**

  Returns the disc's length (running time) in seconds.\

- **total\_tracks**

  Returns the total number of tracks on the disc.

## ARRAY ACCESSOR METHODS

These methods return arrays containing all the info for the tracks on the disc. They're listed here in case you want to use them, but you'll probably do best with the current\_\* methods above as they provide the easiest method for plowing through the tracks on the disc. \

- **track\_info**

  Returns an array containing the track names for all tracks on the disc.\

- **offsets**

  Returns an array containing the byte offsets (Is that right?) for all tracks on the disc.\

- **extended\_track\_info**

  Returns an array containing the extended info for all tracks on the disc.\

- **detailed\_track\_info**

  Returns an array containing all the info for all tracks on the disc.\

- **track\_lengths**

  Returns an array containing all the track lengths in seconds for all tracks on the disc.

## DESCRIPTION

A Perl module to provide convenient OO access to the free CDDB

## THANKS

Thanks to J.I. van Hemert for graciously giving me permission to use the cddb storage and retrieval code from his wonderful program disc-cover (http://www.liacs.nl/~jvhemert/disc-cover), as well as some nice patches to FreeDB.pm . I originally wrote FreeDB.pm for use with my own Free Software cd labelling program called cdlabelgen (http://www.red-bean.com/~bwf/software/cdlabelgen/).

## AUTHOR

Design, Code cleanup and objectification/modularization by B. W. Fitzpatrick \<*fitz@red-bean.com*\>. J.I. van Hemert \<*jvhemert@cs.leidenuniv.nl*\> and Richard Martin wrote the original cddb routines.

## LAST MODIFIED

$Id: FreeDB.pm,v 1.16 1999/12/08 13:46:32 bwf Exp $
