How to write ID3v1 tags?

The place for "I can't figure out how to..." questions.

How to write ID3v1 tags?

Postby h4t » Sun Jun 27, 2010 11:24 am

This library needs some serious help, I can't seem to find any documentation anywhere! I've been trying to work this out for over a week and haven't had any luck yet...

I'm trying to remove the ID3v1 tag from a file, and later I will need write a new tag to some files. The two demos that demonstrate the 'write' library show two totally different ways of setting up the write library, neither of which work for me. I've already had to replace all instances of eregi with preg_match to make the library work, but I'm not sure what the problem is now.

First I try to include the write library as per the demo.simple.write.php like so:

Code: Select all
require_once('../getid3/write.php');

results in the error ...
Code: Select all
Cannot redeclare class getid3_lib


-----------------------------------

And when I try to include the write library as per the demo.write.php file:

Code: Select all
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'write.php', __FILE__, true);

results in the error ...
Code: Select all
Call to undefined method getid3_lib::IncludeDependency()


------------------------------------

This has been driving my crazy for the last week, I could really use a solution! I am using GetID3 version 1.7.9 (i couldn't find 2.0.0 anywhere...) on my local server which I believe is using PHP5
h4t
User
 
Posts: 2
Joined: Sun Jun 20, 2010 9:23 pm

Re: How to write ID3v1 tags?

Postby Pernod » Wed Jun 30, 2010 7:01 am

If you are having to change code then you are likely using an unsupported version of PHP. I suspect you're using PHP 5.3, you should have fewer problems using 5.2.
Pernod
User
 
Posts: 40
Joined: Sat Mar 21, 2009 12:30 pm
Location: London, UK

Re: How to write ID3v1 tags?

Postby h4t » Thu Jul 01, 2010 7:24 pm

Alright, I just downgraded to PHP version 5.2.11 then restarted my server and tried my script again. I get the exact same errors, see the first post :S

Here is the section of code that does not work, what am I doing wrong?
Code: Select all
         // Save ID3 tag information
         require('./plugins/getid3/getid3.php');
         
         $getID3 = new getID3;
         $info = $getID3->analyze("./upload/" . $_POST["filename"]);
         
         $id3['band_name'] = $info['tags']['id3v1']['artist'][0];                                                   ;
         $id3['album_name'] = $info['tags']['id3v1']['album'][0];
         $id3['track_number'] = $info['tags']['id3v1']['track'][0];
         $id3['track_name'] = $info['tags']['id3v1']['title'][0];
         $id3['duration'] = $info['playtime_string'];
         $id3['genre'] = getid3_id3v1::LookupGenreID( $info['tags']['id3v1']['genre'][0] );
         $id3['filename'] = $_POST["filename"];
         
         // Put filename and ID3 information into db
         
         // Remove ID3 tag information
         require_once('./plugins/getid3/write.php');
         #getid3_lib::IncludeDependency('./plugins/getid3/write.php', __FILE__, true);
            
         $writer = new getid3_writetags;   
         $writer->filename = $_POST["filename"];
         
         if (!empty($_POST['remove_other_tags']))
            $writer->remove_other_tags = true;
         
         $success = $writer->DeleteTags('id3v1');
         
         if(!$success)   die("Could not remove ID3v1 tag");
h4t
User
 
Posts: 2
Joined: Sun Jun 20, 2010 9:23 pm


Return to Support 1.7.x

Who is online

Users browsing this forum: No registered users and 2 guests