Giter Club home page Giter Club logo

cd-discid's Introduction

cd-discid

cd-discid is a backend utility to get CDDB discid information from a CD-ROM disc.

Using cd-discid is very simple. It accepts a command line parameter, the device name of the CD-ROM drive to look up. For example:

$ cd-discid /dev/cdrom
7c0b8b0b 11 150 23115 42165 60015 79512 101560 118757 136605 159492 176067 198875 2957

The information returned is, in order:

  • 32-bit hex CDDB disc-id. The first byte of this is the track checksum, the next two are the length of the CD in seconds, and the last is the number of tracks
  • Number of tracks
  • Frame offset of each track
  • Second offset for the leadout track (length of the CD in seconds)

The (lack of) inspiration behind this output format was the CDDB database server. It accepts requests like so:

http://freedb.freedb.org/~cddb/cddb.cgi?cmd=cddb+query+7c0b8b0b+11+150+23115+42165+60015+79512+101560+118757+136605+159492+176067+198875+2957&hello=user+hostname+program+version&proto=3

There is --musicbrainz option which outputs a TOC that is suitable for calculating the MusicBrainz disc id. This feature is courtesy of Lars Magne Ingebrigtsen.

cd-discid was developed with attention to the CDDB specifications, available at http://www.freedb.org/sections.php?name=Sections?sop=viewarticle&artid=28, using portions of their sample code.

cd-discid should work in Linux, Solaris, FreeBSD, OpenBSD, NetBSD, MacOS X and DragonFly.

Installation

To compile cd-discid you need the recent version of standards compliant C compiler. To build binary, type in terminal:

$ make
$ make install

Second command will install cd-discid files using prefix /usr/local. To change prefix, append to the command: PREFIX=/my/dir.

TODO

Output ID3v2 MCDI (Music CD Identifier) frames. Since these are binary in nature it is unclear what the best method of outputting these should be.

Development

If you have patches, please fork cd-discid at GitHub or simply send your patches by e-mail (see below). If you found a bug, please report it at https://github.com/taem/cd-discid/issues.

Homepage

Latest program version can be found at http://linukz.org/cd-discid.shtml.

License

cd-discid is distributed under the terms GNU General Public License Version 2 or greater, or Larry Wall's Artistic license. Please see COPYING for full GNU GPL text.

Author

Original author is Robert Woodcock. Later Timur Birsh picked up maintenance.

cd-discid's People

Contributors

dunn avatar scop avatar taem avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cd-discid's Issues

IRIX support

The patch below adds support for IRIX to cd-discid:

diff -ur ./cd-discid.c ../../cd-discid-1.4//cd-discid.c
--- ./cd-discid.c   Tue May 14 11:02:00 CEST 2013
+++ ../../cd-discid-1.4//cd-discid.c    Sun May 22 18:39:33 CEST 2016
@@ -95,6 +95,19 @@
 #define cdte_track_address      trackStartAddress
 #define DEVICE_NAME             "/dev/disk1"

+#elif defined(__sgi)
+#include <dmedia/cdaudio.h>
+#define CD_FRAMES               75               /* per second */
+#define CD_MSF_OFFSET           150              /* MSF offset of first frame */
+#define cdrom_tochdr            CDSTATUS
+#define cdth_trk0               first
+#define cdth_trk1               last
+#define close                   CDclose
+struct cdrom_tocentry 
+{
+        int cdte_track_address      ;
+};
+#define DEVICE_NAME             "/dev/scsi/sc0d4l0"
 #else
 #error "Your OS isn't supported yet."
 #endif  /* os selection */
@@ -127,13 +140,20 @@
 int main(int argc, char *argv[])
 {
    int len;
-   int drive, i, totaltime;
+   int i, totaltime;
    long int cksum = 0;
    int musicbrainz = 0;
    unsigned char first = 1, last = 1;
    char *devicename = DEVICE_NAME;
-   struct cdrom_tochdr hdr;
    struct cdrom_tocentry *TocEntry;
+#ifndef __sgi
+   int drive;
+   struct cdrom_tochdr hdr;
+#else
+   CDPLAYER *drive;
+   CDTRACKINFO info;
+   cdrom_tochdr hdr;
+#endif
    char *command = argv[0];

 #if defined(__OpenBSD__) || defined(__NetBSD__)
@@ -162,8 +182,13 @@
        exit(EXIT_FAILURE);
    }

+#if defined(__sgi)
+   drive = CDopen(devicename, "r");
+   if (drive == 0) {
+#else
    drive = open(devicename, O_RDONLY | O_NONBLOCK);
    if (drive < 0) {
+#endif
        fprintf(stderr, "%s: %s: ", command, devicename);
        perror("open");
        exit(EXIT_FAILURE);
@@ -179,6 +204,11 @@
        perror("DKIOCCDREADDISCINFO");
        exit(EXIT_FAILURE);
    }
+#elif defined(__sgi)
+   if (0 == CDgetstatus(drive, &hdr)) {
+       perror("CDROMREADTOCHDR");
+       exit(EXIT_FAILURE);
+   }
 #else
    if (ioctl(drive, CDROMREADTOCHDR, &hdr) < 0) {
        fprintf(stderr, "%s: %s: ", command, devicename);
@@ -238,6 +268,14 @@
     */
    TocEntry[last].cdte_track_address = TocEntry[last - 1].trackSize +
        TocEntry[last - 1].trackStartAddress;
+#elif defined(__sgi)
+   for (i = 0; i < last; i++) {
+       if (0 == CDgettrackinfo(drive, i + 1, &info)) {
+           fprintf(stderr, "CDgettrackinfo failed on track %i: %s\n", i + 1, devicename);
+       }
+       TocEntry[i].cdte_track_address = info.start_min*60*CD_FRAMES  + info.start_sec*CD_FRAMES + info.start_frame;
+   }
+   TocEntry[last].cdte_track_address = TocEntry[last - 1].cdte_track_address + info.total_min*60*CD_FRAMES + info.total_sec*CD_FRAMES + info.total_frame;
 #else   /* FreeBSD, Linux, Solaris */
    for (i = 0; i < last; i++) {
        /* tracks start with 1, but I must start with 0 on OpenBSD */

Producing bad TOCs?

Trying to use it together with cddb_query (from libcddb) gives an error:

freso@kotake> cd-discid --version
cd-discid 1.4.
freso@kotake> cd-discid
60100919 25 150 13455 23860 35583 43712 52994 66828 77283 86154 105083 120642 130551 143796 158474 170604 182849 198225 210288 221351 231534 242998 261047 27
3360 284556 295670 4107
freso@kotake> cddb_query calc $(cd-discid)

error: track count is 25, but 26 frame offset(s) specified

--musicbrainz option which outputs a TOC

I.e. I get this correct FreeDB-ID:
38098c05

If I do: cd-discid --musicbrainz /dev/sr1 , I get:
5 183 51735 90810 126230 165433 183465

This TOC couldn't be found here, if you give in (FreeDB-ID:) 38098c05 (you will find 6 CDs)
https://musicbrainz.org/search

My own code in a windows program finds it normally at FreeDB this way (and via Telnet):
cddb query 38098c05 5 183 51735 90810 126230 165433 2445

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.