Page 1 of 1

use php to open itunes file and edit the lyrics propery

Posted: Wed Oct 07, 2009 10:31 am
by madspoihur
Hello, I would appreciate any suggestions on how to use a php script open an itunes music file and edit the file's 'lyrics' property.
Thanks,
-Mads

Re: use php to open itunes file and edit the lyrics propery

Posted: Wed Oct 07, 2009 10:36 am
by jackpf

Re: use php to open itunes file and edit the lyrics propery

Posted: Wed Oct 07, 2009 11:24 am
by madspoihur
Thanks Jack

I didnt realize fopen and fwrite would work with mp3 files. But I dont understand how to direct fopen and fwrite to a specific property of the mp3 file, in this case the 'lyrics' property.

$fp = fopen( "songfile.mp3", "w");
fwrite( $fp, "some lyrics some lyrics" );

This seems to rewrite the entire file, losing all the music.

Thanks again for any suggestions,

Mads

Re: use php to open itunes file and edit the lyrics propery

Posted: Wed Oct 07, 2009 11:54 am
by jackpf
Oh yeah, forgot this one lol: http://uk3.php.net/fread

Using fread(), you can pull the contents of the file. Then edit it however you want...then rewrite it with fwrite().

Re: use php to open itunes file and edit the lyrics propery

Posted: Wed Oct 07, 2009 2:05 pm
by pickle
The getID3 library might be useful.

Re: use php to open itunes file and edit the lyrics propery

Posted: Wed Oct 07, 2009 7:34 pm
by madspoihur
Thanks again, Jack,

I used fread, and the lyrics were displayed along with the rest of the song info just as you said. The lyrics are legible, but the rest seems to be a jumble. Editing this looks difficult, and like it might not reproduce the audio and the rest of the info.

Thanks pickle,

GetID3 could be useful. This also led me to find out about the ID3 functions ( http://www.php.net/manual/en/intro.id3.php ), one of which, the id3_set_tag function, looks like it could directly edit a tag.

Im going to try this out, but im wondering if anyone is familiar with the ID3 functions and knows whether they are capable of editing ID3v2.4 lyrics tags.

thanks again,

Mads

Re: use php to open itunes file and edit the lyrics propery

Posted: Thu Oct 08, 2009 2:26 pm
by madspoihur
I am having some difficulty installing the PECL id3 package. I am trying to install with pear install. 5 example files appear in C:\xampp\php\PEAR\docs\id3\examples and 4 files appear in C:\xampp\php\PEAR\data\id3. So it looks like something has been installed, though even after restarting apache and my computer, a simple example file returns an error indicating that it cant find the id3 function.

Here is my cmd prompt:

C:\xampp\php>pear install id3-0.2
No releases available for package "pear.php.net/id3" - package pecl/id3 can be installed with "pecl install id3"
install failed

C:\xampp\php>pecl install id3-0.2
downloading id3-0.2.tgz ...
Starting to download id3-0.2.tgz <20,693 bytes>
........done: 20, 693 bytes
$ source files, building
WARNING: php_bin \xampp\php\php.exe appears to have a suffix \php.exe, but config variable php_suffix does not match
running: msdev id3.dsp \MAKE "id3 - Release"
ERROR: Did not understand the completion status returned from msdev.exe.


Here is the file and the error message:


<?php
$longName = id3_get_frame_long_name("TOLY");
echo $longName;
?>

Fatal error: Call to undefined function id3_get_frame_long_name() in C:\xampp\htdocs\id3trial.php on line 2



Id be thankful for any advice

Thanks,

Mads

Re: use php to open itunes file and edit the lyrics propery

Posted: Thu Oct 08, 2009 6:32 pm
by McInfo
In C:\xampp\apache\bin\php.ini, remove the semicolon from this line:

Code: Select all

;extension=php_id3.dll
Edit: This post was recovered from search engine cache.