aramds / php-reader

code.google.com/p/php-reader
0 stars 0 forks source link

Id3v2 r218 won't write ISO88591 tag, only UTF8. #69

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello; thanks for this great library. I can read tags just fine, but cannot 
seem to write tags that can be read in WMP or the Ubuntu id3v2 linux client, or 
pass MP3diags. WMP shows no details, Winamp shows some details but gets the 
genre wrong (shows "blues" when it's "speech"), id3v2 for linux shows the 
correct genre and that tags have been written but are empty, and MP3diags says:

ID3V2.3.0 tag contains a text frame encoded as UTF-8, which is valid in 
ID3V2.4.0 but not in ID3V2.3.0. (Frame:TPUB)

I've followed the Wiki very closely, using all of your examples.

The version I'm using is the very latest, checked out via SVN:
 * @version    $Id: Id3v2.php 218 2011-05-02 19:35:18Z svollbehr $

My code looks like this - and as you can see, I am even trying utf8_decode on 
some of the fields. 

Server OS: Linux 2.6.32-21-generic - Ubuntu 11.10 64 bit.
HTTP Server: nginx/1.2.3
PHP Version: 5.3.15-1~dotdeb.0 (Zend: 2.3.0)
PHP Memory Limit: 256M

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

require_once 'Zend/Media/Id3v2.php';
require_once 'Zend/Media/Id3/Encoding.php';
require_once 'Zend/Media/Id3/TextFrame.php';
require_once 'Zend/Media/Id3/Frame/Tpub.php';
require_once 'Zend/Media/Id3/Frame/Talb.php';
require_once 'Zend/Media/Id3/Frame/Txxx.php';
require_once 'Zend/Media/Id3/Frame/Tpe3.php';
require_once 'Zend/Media/Id3/Frame/Tpe4.php';
require_once 'Zend/Media/Id3/Frame/Tenc.php';
require_once 'Zend/Media/Id3/Frame/Tcon.php';
require_once 'Zend/Media/Id3/Frame/Trck.php';
require_once 'Zend/Media/Id3/Frame/Tit1.php';
require_once 'Zend/Media/Id3/Frame/Tit2.php';
require_once 'Zend/Media/Id3/Exception.php';
try {
    $id3 = new Zend_Media_Id3v2("file.mp3", array(
        "version" => 3.0,
        "encoding" => Zend_Media_Id3_Encoding::ISO88591,
        "compat" => true
    ));

    $id3->tpub->text = utf8_decode("publisher"); //the main group
    $id3->tit1->text = utf8_decode("title 1"); //the publication
    $id3->talb->text = utf8_decode("edition");
    $id3->tit2->text = "track_name";
    $id3->tpe4->text = "producer";
    $id3->tenc->text = "Talking Newspaper Services Ltd";
    $id3->tpe3->text = "The editor was John";
    $id3->tcon->text = "Speech";

    $id3->write(null);
}
catch (Zend_Media_Id3_Exception $e) {
    echo "  " . $e->getMessage() . "\n";
    continue;
}

Original issue reported on code.google.com by digitaltoast on 12 Aug 2012 at 2:01

GoogleCodeExporter commented 9 years ago
I meant to say that mp3diags gives that UFT8 message for ALL frames; however, 
in the "raw data" panel below, I can see that the data IS there, even though 
windows and other taggers (except winamp) won't display it. 

Original comment by digitaltoast on 12 Aug 2012 at 2:40

Attachments:

GoogleCodeExporter commented 9 years ago
New texts can be set using setText(string) with the default encoding (which is 
UTF-8). Should you want to set the new text in ISO8859-1 encoding you can call 
setText(string, Zend_Media_Id3_Encoding::ISO88591). The text is stored in the 
class unaltered (ie assumed to be in the given encoding).

It was good that you reported this incident. The default value of the class 
should indeed correspond to the given options. I have made a patch and 
committed that to the repository. Please checkout the latest code and report 
any further faults.

Original comment by svollbehr on 21 Aug 2012 at 5:24