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
use php to open itunes file and edit the lyrics propery
Moderator: General Moderators
-
madspoihur
- Forum Newbie
- Posts: 6
- Joined: Wed Oct 07, 2009 10:24 am
-
madspoihur
- Forum Newbie
- Posts: 6
- Joined: Wed Oct 07, 2009 10:24 am
Re: use php to open itunes file and edit the lyrics propery
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
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
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().
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
The getID3 library might be useful.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
-
madspoihur
- Forum Newbie
- Posts: 6
- Joined: Wed Oct 07, 2009 10:24 am
Re: use php to open itunes file and edit the lyrics propery
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
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
-
madspoihur
- Forum Newbie
- Posts: 6
- Joined: Wed Oct 07, 2009 10:24 am
Re: use php to open itunes file and edit the lyrics propery
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
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
In C:\xampp\apache\bin\php.ini, remove the semicolon from this line:
Edit: This post was recovered from search engine cache.
Code: Select all
;extension=php_id3.dll