www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - ID3 tag reader module in D - id3tag.d

reply James Dunne <jdunne4 bradley.edu> writes:
Attached is a present for anyone wishing for a native D ID3 tag reader! :)

It works with Phobos streams.  An example program is included in a debug {}
block to test it yourselves.  ID3v2 and v1 tags are supported.  I don't know
about 100% ID3v1, but I'm pulling the most relevant fields from v2.

The default behavior is to find an ID3v2 tag at the start of the stream and an
ID3v1 tag at 0x80 bytes from the end of the stream, in that order.

Enjoy!

P.S. - feel free to post/use this code anywhere you like, but give credit where
credit is due.

Regards,
James Dunne
begin 0644 id3tag.d








M;VX 9FEE;&1S. T*"6-H87);70ET:71L93L-" EC:&%R6UT)87)T:7-T.PT*


M=VX 8GD <F5A9$E$,U1A9R I. T*8VQA<W, 240S17AC97!T:6]N(#H 17AC
M97!T:6]N('L-" ET:&ES*&-H87);72!M<V<I('L-" D)<W5P97(H;7-G*3L-

M96%M+ T*+R\ 4W1R96%M(&UU<W0 8F4 870 ;&5A<W0 8F]T:"!S965K86)L


M;F9O<FUA=&EO;B!R96%D(&EN+B` 240S=C( =&%G(&ES('-E87)C:&5D(&9O
M<B!F:7)S="P-"B\O(&%N9"!I9B!N;W0 9F]U;F0L($E$,W8Q(&ES('-E87)C
M:&5D(&9O<BX ($EF(&YE:71H97( :7, 9F]U;F0-"B\O('1H92!F=6YC=&EO
M;B!R971U<FYS("=N=6QL)RX-" T*240S5&%G*B!R96%D240S5&%G*%-T<F5A

M;F< 9G)O;2!A('-T<F5A;3H-" EC:&%R6UT <F5A9%-T<FEN9RA3=')E86T 

M" D)8VAA<BH)<W1R(#T ;F5W(&-H87);=&%G;&5N73L-" D)<W1R96%M+G)E
M861";&]C:RAC87-T*'9O:60J*7-T<BP =&%G;&5N*3L-" T*"0ER971U<FX 

M<')O<&5R=&EE<SH-" EI9B`H(7-T<F5A;2YS965K86)L92D =&AR;W< ;F5W
M($E$,T5X8V5P=&EO;B B4W1R96%M(&UU<W0 8F4 <V5E:V%B;&4B*3L-" EI
M9B`H(7-T<F5A;2YR96%D86)L92D =&AR;W< ;F5W($E$,T5X8V5P=&EO;B B
M4W1R96%M(&UU<W0 8F4 <F5A9&%B;&4B*3L-" T*"6-H87(J"6)L:R`](&YE

M+R\ 3&]O:R!F;W( 86X 240S('8R('1A9R!A="!T:&4 <W1A<G0 ;V8 =&AE



M+R\ 5&AE(&-O9&4 8F5L;W< :7, 8F%S960 =&]T86QL>2!O;B!M>2!H86-K
M:6YG(&%B:6QI='DL(&%N9"!)(&MN;W< :70-" D)+R\ =&\ 8F4 :6YC;W)R
M96-T(&9O<B!C97)T86EN($E$,W8R(&QA>6]U=',N("!)(&AA=F4 >65T('1O






M"0DO+R!296%D('1H92!B;&]C:R!I9&5N=&EF:65R. T*"0D)<W1R96%M+G)E






M(&)Y=&4M<W=A<'!E9"!A;'-O("AO;FQY(&%S(&$ =7-H;W)T*0T*"0D)+R\ 
M:&]W979E<BP :70 :7, ;F5V97( =7-E9"X-" T*"0D)+R\ 3F]W+"!W:&%T
M('1O(&1O('=I=&  =&AE('-T<FEN9S\-" D)"7-W:71C:"`H8FQK6S` +BX 

M"0D)"0ES=')E86TN<V5E:R Q+"!3965K4&]S+D-U<G)E;G0I.R`M+71A9VQE
M;CL-" D)"0D)=&%G+G1I=&QE(#T <F5A9%-T<FEN9RAS=')E86TL('1A9VQE


M;W,N0W5R<F5N="D[("TM=&%G;&5N.PT*"0D)"0ET86<N87)T:7-T(#T <F5A

M($%L8G5M('1I=&QE. T*"0D)"6-A<V4 (E1!3$(B. T*"0D)"0ES=')E86TN
M<V5E:R Q+"!3965K4&]S+D-U<G)E;G0I.R`M+71A9VQE;CL-" D)"0D)=&%G
M+F%L8G5M(#T


M.PT*"0D)"0ET86<N9V5N<F4 /2!R96%D4W1R:6YG*'-T<F5A;2P =&%G;&5N

M;R!B92`B;B].(B!F;W)M870 =VAE<F4 ;B!I<R!T<F%C:R!A;F0 3B!I<R!T

M(%-E96M0;W,N0W5R<F5N="D[("TM=&%G;&5N.PT*"0D)"0EC:&%R6UU;72!T
M<FMS=')S(#T <W!L:70H<F5A9%-T<FEN9RAS=')E86TL('1A9VQE;BDL("(O

M"2\O($EF(&YO("\ <V5P87)A=&]R+"!J=7-T('-E="!A(&1U;6( 9&5F875L
M="!F;W( ;6%X=')A8VMS. T*"0D)"0EI9B`H=')K<W1R<RYL96YG=&  /3T 
M,BD-" D)"0D)"71A9RYT<F%C:W, /2!A=&]I*'1R:W-T<G-;,5TI.PT*"0D)

M"0D)+R\ 06QB=6T >65A<B!R96QE87-E. T*"0D)"6-A<V4 (E1915(B. T*
M"0D)"0ES=')E86TN<V5E:R Q+"!3965K4&]S+D-U<G)E;G0I.R`M+71A9VQE
M;CL-" D)"0D)=&%G+GEE87( /2!A=&]I*')E8613=')I;F<H<W1R96%M+"!T

M:6=N;W)E9#H-" D)"0ED969A=6QT. T*"0D)"0ES=')E86TN<V5E:RAT86=L


M(&%N($E$,R!V,2!T86< ,' X,"!B>71E<R!F<F]M(&5N9"!O9B!S=')E86TZ


M,"`N+B`S72`]/2`B5$%'(BD >PT*"0D)8VAA<BH)<W1R(#T ;F5W(&-H87);
M,S!=.PT*"0D)=6)Y=&4)=')K(#T ,#L-" T*"0D)=&%G(#T ;F5W($E$,U1A

M<R!A<F4 ,S` 8VAA<F%C=&5R<R!L;VYG. T*"0D)<W1R96%M+G)E861";&]C
M:RAC87-T*'9O:60J*7-T<BP ,S`I.PT*"0D)=&%G+G1I=&QE(#T <W1R:7`H
M<W1D+G-T<FEN9RYT;U-T<FEN9RAS='(I*3L-" T*"0D)<W1R(#T ;F5W(&-H
M87);,S!=.PT*"0D)<W1R96%M+G)E861";&]C:RAC87-T*'9O:60J*7-T<BP 
M,S`I.PT*"0D)=&%G+F%R=&ES="`]('-T<FEP*'-T9"YS=')I;F<N=&]3=')I



M<B`](&YE=R!C:&%R6S1=.PT*"0D)<W1R96%M+G)E861";&]C:RAC87-T*'9O




M.PT*"0D)=&%G+G1R86-K(#T =')K.PT*"0D)+R\ 3F\ ;6%X('1R86-K<R!P


M?2!E;'-E('L-" T*"0D)+R\ 3F\ 240S=C$ ;W( 240S=C( =&%G(&9O=6YD

M(&5X8V5P=&EO;B!H97)E+`T*"0D)+R\ <VEN8V4 :70 :7, 3D]4(&%N(&5R

M(&9I;&5S('-I;7!L>2!D;R!N;W0 8V]N=&%I;B!T:&5M+B` 06QS;RP =&AE
M<F4 :7,-" D)"2\O('1H92!P;W-S:6)I;&ET>2!T:&%T('1H92!S=')E86T 

M"0ER971U<FX ;G5L;#L-





M1FEL92AA<F=S6S%=*3L-" T*"0DO+R!396%R8V  9F]R($E$,R!T86< *'8R
M(&9I<G-T+"!T:&5N('8Q*3H-" D)240S5&%G* ET86< /2!R96%D240S5&%G


M=&QE.B` ("` ("<E+BIS)UQN(BP =&%G+G1I=&QE*3L-" D)"7!R:6YT9B B
M07)I<W0Z("` ("` )R4N*G,G7&XB+"!T86<N87)T:7-T*3L-" D)"7!R:6YT
M9B B06QB=6TZ("` ("` )R4N*G,G7&XB+"!T86<N86QB=6TI.PT*"0D)<')I
M;G1F*")!;&)U;2!996%R.B`E9%QN(BP =&%G+GEE87(I.PT*"0D)<')I;G1F
M*")4<F%C:SH ("` ("`E9"\E9%QN(BP =&%G+G1R86-K+"!T86<N=')A8VMS
M*3L-" D)"7!R:6YT9B B1V5N<F4Z("` ("` )R4N*G,G7&XB+"!T86<N9V5N



&?0T*?0T*
`
end
Dec 06 2004
parent "Niko Korhonen" <niktheblak hotmail.com> writes:
I've actually been working for a full object oriented tag processing library 
for D quite a while now :)

It currently supports:

ID3v1 and limited ID3v2
limited Lyrics3
APEv1 and v2 (full support)
VorbisComment

It features a CLI tag scanner program which examines files for known tags.

I've been working on two versions of the library; one for D and one for 
.NET. My biggest problem is to which version I should concentrate on, and 
which version I should publish. I've already decided that  won't be updating 
both versions when I start hacking ID3v2 and Lyrics3 support (such a pain!). 
But which one to drop, I can't decide.

I personally enjoy working in D very much, but I also have to ask myself the 
question: which version of the library will be more useful to the community, 

usable from every .NET language. It's a tough decision, I tells you.

Whichever version should I choose to work with will be published under BSD 
license, naturally. 
Dec 07 2004