JamesHeinrich / getID3

http://www.getid3.org/
Other
1.15k stars 246 forks source link

Copyright tag not writing #273

Open kiernan7 opened 4 years ago

kiernan7 commented 4 years ago

Hey GetID3 folks!

I've been using your great GetID3 for years now, but when I upgraded (belatedly) to the latest version, it broke my system (you can get a look at it at: https://www.oalaig.org/laig-virtual-speakers-bureau/

I've tracked down the problem to the fact that the upload ($tagwriter->WriteTags()) is not writing to the copyright tag. I store three key pieces of info there (concatenated) and it's causing a problem. I can't easily change over to a different tag, as I have LOTS of legacy files.

Help! (Thanks in advance.) John Kiernan

JamesHeinrich commented 4 years ago

Can you provide an example of how you're calling getID3 to write the tag (the actual data doesn't matter, just how you're calling WriteTags, what kind of data/parameters you're passing, etc), so I can see what it's doing or not doing. Do you get any error messages, or just the tag is not written as expected?

kiernan7 commented 3 years ago

I realized that I was replying to the email I got from this and I don't think it was getting to you. I tried upload the code, but the upload won't take a PHP file. So I'll paste the code below. The results show on this link: https://www.oalaig.org/laig-virtual-speakers-bureau/. CODE:

<html>
  <head>
      <title>Virtual Speakers Bureau Upload</title>
      <META NAME="robots" CONTENT="noindex, nofollow">
      <META NAME="GOOGLEBOT" CONTENT="NOINDEX, NOFOLLOW">
      <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
      <meta http-equiv="Pragma" content="no-cache">
      <meta http-equiv="Expires" content="1"> 
      <link rel="icon" href="favicon.gif" type="image/x-icon" />
      <link rel="shortcut icon" href="favicon.gif" type="image/x-icon" />
      <link href='/uploadify/uploadify.css' type='text/css' rel='stylesheet' />
      <link rel="stylesheet" type="text/css" href="JQuery/jquery-ui.css">
      <link rel="stylesheet" type="text/css" href="style.css">
      <meta http-equiv="Content-Type" content="text/html;">
      <meta name="viewport" content="width=device-width" />
  </head>
  <body>

<?php
    require_once('getid3/getid3.php');

    $title    = $_POST['title'];
    $title2   = $_POST['title2'];
    $date     = $_POST['date'];
    $since    = $_POST['since'];
    $meeting  = $_POST['meeting'];
    $overeater = $_POST['overeater'];
    $multiple  = $_POST['multiple'];
    $anorexic  = $_POST['anorexic'];
    $hundred   = $_POST['hundred'];
    $gay       = $_POST['gay'];
    $color     = $_POST['color'];
    $filename = $_POST['hidfilename'];

    $key = "";

    if ($overeater != "") {
        $key .= "O,";
    }

    if ($multiple != "") {
        $key .= "+,";
    }

    if ($anorexic != "") {
        $key .= "A,";
    }

    if ($hundred != "") {
        $key .= "#,";
    }

    if ($gay != "") {
        $key .= "G,";
    }

    if ($color != "") {
        $key .= "C,";
    }

    switch($meeting) {
        case "K":
          $meeting = "the Kitchen Sink meeting in Beverly Hills, CA";
          $meeting2 = "Kitchen Sink|Beverly Hills, CA";
          $shortmeet = "KS";
          break;

        case "L":
          $meeting = "the Light a Candle meeting in Brentwood, CA";
          $meeting2 = "Light a Candle|Brentwood, CA";
          $shortmeet = "LAC";
          break;

        default:
          $meeting = "a meeting in Los Angeles, CA";
          $meeting2 = "a meeting in Los Angeles, CA";
          $shortmeet = "OTH";
          break;

    }

    $key = substr_replace($key, "", -1);

    $album = "The LAIG Virtual Speakers Bureau";
    $genre = "Speech";

    $getID3 = new getID3;
    $TextEncoding = 'UTF-8';
    $getID3->setOption(array('encoding'=>$TextEncoding));
    require_once('getid3/write.php');

    $tagwriter = new getid3_writetags;
    $tagwriter->filename = $filename;
//  $tagwriter->tagformats = array('id3v2.3');
    $tagwriter->tagformats = array('id3v2.4');
    $tagwriter->overwrite_tags = true; 
    $tagwriter->remove_other_tags = false;
    $tagwriter->tag_encoding = $TextEncoding;
    $tagwriter->remove_other_tags = true;
    $origartist = $title." ".$title2;
    if ($title2 != "") {
        $title2 = $title2.".";
    }
    $oldtitle = $title." ".$title2;
    $year = substr($date, 6, 4);

    $artist   = $oldtitle;
    $oldtitle = $artist." - ".$date;
    $comment = "A share of experience, strength, and hope by ".$artist." on: ".$date." at ".$meeting;
    $copyright = $date."|".$key."|".$meeting2;

echo "Title: ".$oldtitle."<br>";
echo "Artist: ".$artist."<br>";
echo "Album: ".$album."<br>";
echo "Year: ".$year."<br>";
echo "Genre: ".$genre."<br>";
echo "Tracknumer (since): ".$since."<br>";
echo "Copyright: ".$copyright."<br>";
echo "Comment: ".$comment."<br>";

    $TagData = array(
        'title' => array($oldtitle),
        'artist' => array($artist),
        'album' => array($album),
        'year' => array($year),
        'genre' => array($genre),
        'tracknumber' => array($since),
        'copyright' => array($copyright),
        'comment' => array($comment)
    );

/*  
    $cover = "logo.jpg";
    $fd = fopen($cover, 'rb');
    $APICdata = fread($fd, filesize($cover));
    fclose ($fd);

    if($APICdata) {
        $TagData += array(
        'attached_picture' => array(
        'picturetypeid'=>'0x03', // Cover. More: module.tag.id3v2.php -> function APICPictureTypeLookup
        'description'=>'cover', // text field
        'mime'=>'image/jpeg', // Mime type image
        'data'=>$APICdata)); // Image data        
    }
*/    
    //and   
    $tagwriter->tag_data = $TagData;
    echo("<div align='center'><br />\n");

    if ($tagwriter->WriteTags()) {
//  if (true) {
        echo '<h1>Successfully uploaded and set ID3 tags<h1>';

        if (!empty($tagwriter->warnings)) {
            echo '<h1>There were some warnings:<br>'.implode('<br><br>', $tagwriter->warnings."</h1>");
        }

        $origartist = strtr($origartist, " ", "_");
        $origartist = trim($origartist);
        $titledate =  $year."-".substr($date, 0, 2)."-".substr($date, 3, 2);
        $finalname = strtolower($titledate."_".$origartist."_".$shortmeet.".mp3");
        rename($filename,$finalname);
    } else {
        echo '<h1>Error updating ID3 tags</h1>';
    }           
?>
    <br />
    <form action="fileedit.php" method="post">
        <input type="submit" value="Return to add another file"/>
    </form>
    </div>
  </body>
kiernan7 commented 3 years ago

P.S.: If you want me to send you the PHP file, let me know where to send it. Thanks again! -- John

guoxiangke commented 10 months ago

copyright_message not copyright !