[Templates] [RFC] Template::Plugin::MP3

Doug Gorley douggorley@shaw.ca
Thu, 07 Nov 2002 00:57:30 -0800


--=-X8Md0IKDl5+XU6AH2fA9
Content-Type: multipart/mixed; boundary="=-pGVOUE0uHCUIyePBSN0D"


--=-pGVOUE0uHCUIyePBSN0D
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

I tried your plugin with an MP3 using the following script:

----
[% USE songfile =3D MP3( "/home/doug/eminem/mp3s/square_dance.mp3" ) %]

  Artist: [% songfile.artist %]
  Title: [% songfile.title %]
  Album: [% songfile.album %]
  Track: [% songfile.tracknum %]
  Running Time: [% songfile.time %]
----

The output I got was the following:

----
Use of uninitialized value in sprintf at
/usr/local/lib/perl5/site_perl/5.8.0/i686-linux/Template/Plugin/MP3.pm
line 35.
Use of uninitialized value in sprintf at
/usr/local/lib/perl5/site_perl/5.8.0/i686-linux/Template/Plugin/MP3.pm
line 35.
No method 'TRACKNUM' available in package MP3::Info. at
/usr/local/lib/perl5/site_perl/5.8.0/i686-linux/Template/Plugin/MP3.pm
line 84


  Artist: Eminem
  Title: Square Dance
  Album: The Eminem Show
  Track: 1
  Running Time: 05:23
----

The first two errors are simply because there's no keyword substitution
going on in the file.  I fixed up my copy so it would avoid the third
error, and attached the patch; please let me know if this is useful or
not.

Thanks,

Doug Gorley | douggorley@shaw.ca     OpenPGP Key ID: 0xA221559B
Fingerprint: D707 DB92 E64B 69DA B8C7  2F65 C5A9 5415 A221 559B
Interested in public-key cryptography?    http://www.gnupg.org/

 2002-11-05 at 19:42, darren chamberlain wrote:
> As I found myself creating several directories full of HTML files for my
> MP3 collection, I realized that I needed Template::Plugin::MP3, so I
> wrote it.  It's a wrapper around Pudge's MP3::Info (read-only access,
> though).
>=20
> Basic usage is straightforward:
>=20
>   [% USE songfile =3D MP3("Camarillo_Brillo.mp3") %]
>=20
>   Artist: [% songfile.artist %]
>   Title: [% songfile.title %]
>   Album: [% songfile.album %]
>   Track: [% songfile.tracknum %]
>   Running Time: [% songfile.time %]
>=20
> And so on.  Comments?
>=20
> (darren)
>=20
> --=20
> An idea is not responsible for the people who believe in it.
>=20
> _______________________________________________
> templates mailing list
> templates@template-toolkit.org
> http://www.template-toolkit.org/mailman/listinfo/templates


--=-pGVOUE0uHCUIyePBSN0D
Content-Disposition: attachment; filename=patch.txt
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; name=patch.txt; charset=ISO-8859-1

--- /usr/local/lib/perl5/site_perl/5.8.0/i686-linux/Template/Plugin/MP3.pm	=
Thu Nov  7 00:06:55 2002
+++ perl_modules/Template/Plugin/MP3.pm	Thu Nov  7 00:48:18 2002
@@ -81,7 +81,14 @@
     my $self =3D shift;
    (my $a =3D $AUTOLOAD) =3D~ s/.*:://;
=20
-    $self->{ _MP3 }->$a(@_);
+    if ( exists $self->{ _MP3 }->{uc $a} )
+    {
+        return $self->{ _MP3 }->$a(@_) ;
+    }
+    else
+    {
+        return undef ;
+    }
 }
=20
 sub mp3_genres    { [ @MP3::Info::mp3_genres    ] }

--=-pGVOUE0uHCUIyePBSN0D--

--=-X8Md0IKDl5+XU6AH2fA9
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.0 (GNU/Linux)

iD8DBQA9yir6xalUFaIhVZsRAkAvAJ9IK4KwCehfYHvk326RYX4ktRbO9wCgw8Oo
gjRD4A5JgcbSph8vGdG2/ls=
=R0Ja
-----END PGP SIGNATURE-----

--=-X8Md0IKDl5+XU6AH2fA9--