+sub opusinfo {
+ my $file = $_[0];
+ my $of = Audio::Opusfile->new_from_file($file);
+ my $tags = $of->tags;
+
+ my %data = (
+ format => 'Opus',
+ title => $tags->query('TITLE'),
+ artist => $tags->query('ARTIST'),
+ year => $tags->query('DATE'),
+ album => $tags->query('ALBUM'),
+ tracknumber => $tags->query('TRACKNUMBER'),
+ tracktotal => $tags->query('TRACKTOTAL'),
+ genre => $tags->query('GENRE'),
+ file => scalar fileparse $file,
+ );
+
+ freeze \%data;
+}
+
+my @optional_modules = (
+ [ 'Audio::FLAC::Header', \&flacinfo, '.flac' ],
+ [ 'MP3::Info', \&mp3info, '.mp3' ],
+ [ 'Ogg::Vorbis::Header::PurePerl', \&vorbisinfo, '.ogg', '.oga' ],
+ [ 'MP4::Info', \&mp4info, '.mp4', '.aac', '.m4a' ],
+ [ 'Audio::Opusfile', \&opusinfo, '.opus' ],
+);
+
+my %info;
+
+for (@optional_modules) {
+ my ($module, $coderef, @extensions_handled) = @$_;
+ if (eval "require $module") {
+ $info{$_} = $coderef for @extensions_handled
+ }
+}
+
+unless (%info) {
+ carp 'No tags-reading module detected. Install one of the following modules: ' . join ', ', map { $_->[0] } @optional_modules;
+}
+