MusicBr...::DiscID(3)

πŸ’Ώ MusicBr...::DiscID(3) β€” your girl's guide to the Perl interface for the MusicBrainz libdiscid library

okay so this is a User Contributed Perl Documentation page for MusicBr...::DiscID (the full name is MusicBrainz::DiscID, the header just got a little truncated, it's fine, she's slaying anyway) πŸ’…


✨ NAME ✨

MusicBrainz::DiscID β€” it's the Perl interface for the MusicBrainz libdiscid library, no cap πŸŽ€


🌸 SYNOPSIS 🌸

here's the vibe, literally copy-paste this and go:

use MusicBrainz::DiscID;

my $discid = MusicBrainz::DiscID->new();
if ( $disc->read() == 0 ) {
    print STDERR "Error: " . $discid->error_msg() . "\n";
    exit(1);
}
print "DiscID: " . $discid->id() . "\n";

(yes bestie, $disc->read() and $discid->error_msg() are both in there β€” that's exactly how the original wrote it, so I'm not touching it πŸ™ˆ)


πŸ¦‹ DESCRIPTION πŸ¦‹

MusicBrainz::DiscID is a whole class whose entire main character job is calculating a MusicBrainz DiscID from an audio CD chilling in your drive. 🎧

The coding style is slightly different to the C interface to libdiscid, because it makes use of perl's Object Oriented functionality. it's giving glow-up, it's giving OO era. ✨

  • MusicBrainz::DiscID::default_device() β€” returns a device string for the default device for this platform. your platform, your device, your default, periodt.
  • MusicBrainz::DiscID::new( [$device] ) β€” constructs a brand new DiscID object. πŸ‘‘

as an optional argument you can pass the name of the device to read the ID from. and if you don't specify a device here, no stress β€” you can later read the ID with the read method.

  • $discid->error_msg() β€” returns a human-readable error message of the last error that occured. when things go wrong, at least they explain themselves πŸ’€
  • $discid->first_track_num() β€” returns the number of the first track on this disc (usually 1). returns undef if no ID was yet read.
  • $discid->last_track_num() β€” returns the number of the last track on this disc.
  • $discid->id() β€” returns the DiscID as a string. returns undef if no ID was yet read. this is the one you came for fr fr πŸ’–
  • $discid->last_track_num() β€” returns the number of the last track on this disc. returns undef if no ID was yet read. (yes she appears twice in the original β€” iconic behaviour, I don't make the rules 🫢)
  • $discid->put( $first_track, $sectors, $offset1, $offset2, ... ) β€” this one's for when you already read the TOC earlier and now you want to calculate the disc ID afterwards, without touching the disc drive. no drive, no problem πŸ”₯
  • $discid->read( [$device] ) β€” reads the disc ID from the given device. if no device is given, the default device of the platform will be used. on error, this function returns false and sets the error message, which you can access with $discid->error_msg(). ⭐
  • $discid->sectors() β€” returns the length of the disc in sectors. returns undef if no ID was yet read.
  • $discid->submission_url() β€” returns a submission URL for the DiscID as a string. returns undef if no ID was yet read. go submit, bestie 🌈
  • $discid->track_length( $track_num ) β€” returns the length of a track in sectors.
  • $discid->track_offset( $track_num ) β€” returns the sector offset of a track.

🧚 SEE ALSO 🧚

<http://musicbrainz.org/doc/libdiscid> β€” the lore, the backstory, the iykyk πŸ’œ


πŸŽ€ AUTHOR πŸŽ€

Nicholas J. Humfrey <njh@aelius.com> β€” thank you king πŸ‘‘


The MIT License (MIT)

Copyright (c) 2009-2019 Nicholas J Humfrey

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 😭 that's the whole legal wall, but read it, it matters πŸ’€

and that's the whole page bestie!! 🌸 this version walked so you could run: perl v5.42.0, dated 2025-08-04, closing out the MusicBr...::DiscID(3) moment. mwah πŸ’‹πŸ¦‹

πŸ“¦ where this page comes from