Jump to content

bschultz

Members
  • Posts

    486
  • Joined

  • Last visited

Posts posted by bschultz

  1. I'm trying to scrape a page, and replace a given string with a link to an mp3.  The format of the page is always as such:

     

    <td>0-1</td> 
    <td>0-2</td> 
    <td>1-2</td> 
    <td>1-3</td> 
    
     

    I need it to return like this:  this will always be the first number + the second number...while removing the dash.

     

    <td><a href='1.mp3'>1</a></td>
    <td><a href='2.mp3'>2</a></td>
    <td><a href='3.mp3'>3</a></td>
    <td><a href='4.mp3'>4</a></td>

    Is there a way to combine the regex (which as many times as I've tried, I can't wrap my around) of the matching of the numbers inside the <td> tags with the explode of the dash and the math into one piece of code? 

  2. I'm scraping a page with table contents like such:
     

    <table border="1" style="width:100%;" cellspacing="0" cellpadding="3">
    <tr class="stats-section">
    <td colspan="99">Scoring</td>
    </tr>
    <tr class="stats-section">
    <td colspan="99">2nd Period</td>
    </tr>
    <tr class="hscore">
    <td>UMD</td>
    <td>4&#215;4</td>
    <td>
    Kobe Roth (1)</td>
    <td> 				Noah Cates, Casey Gilling			</td>
    <td align="right">12:35</td>
    </tr>
    <tr class="vscore">
    <td>BSU</td>
    <td>4&#215;4</td>
    <td>
    Alex Ierullo (1)</td>
    <td> 				Kyle Looft			</td>
    <td align="right">13:06</td>
    </tr>
    <tr class="stats-section">
    <td colspan="99">3rd Period</td>
    </tr>
    <tr class="hscore">
    <td>UMD</td>
    <td></td>
    <td>
    Blake Biondi (1)</td>
    <td> 				Quinn Olson			</td>
    <td align="right">10:10</td>
    </tr>
    </table>

    I want to match the <tr class="hscore" AND the <tr class="vscore and change them into the following:

     

    <tr class="hscore">
    <td>#1 UMD</td> <!--added #1 -->
    ...
    <tr class="vscore">
    <td>#2 BSU</td> <!-- added #2 -->
    ...
    </tr></table>

    I don't know what order, or even how many of each hscore or vscore entries there will be.  I need to auto increment a variable ($i++;)  upon each match to echo the #1 and #2.  Is regex my best bet?  Maybe str_replace or is Simple Dom and a foreach of each <tr> better?

    I can't think of a way to add to the $i variable on each match.

    Thanks!

  3. NO ETCO tags written...new var dump.  This is the only tag writer I've seen that even mentions ETCO tags or I would have tried something else a LONG time ago!

    Thank you for this!

     

    array(19) {
      ["GETID3_VERSION"]=>
      string(19) "1.9.20-202107131440"
      ["filesize"]=>
      int(262521)
      ["filepath"]=>
      string(19) "/home/brian/Desktop"
      ["filename"]=>
      string(5) "1.mp3"
      ["filenamepath"]=>
      string(25) "/home/brian/Desktop/1.mp3"
      ["avdataoffset"]=>
      int(4096)
      ["avdataend"]=>
      int(262393)
      ["fileformat"]=>
      string(3) "mp3"
      ["audio"]=>
      array(12) {
        ["dataformat"]=>
        string(3) "mp3"
        ["channels"]=>
        int(2)
        ["sample_rate"]=>
        int(44100)
        ["bitrate"]=>
        int(128000)
        ["channelmode"]=>
        string(6) "stereo"
        ["bitrate_mode"]=>
        string(3) "cbr"
        ["codec"]=>
        string(4) "LAME"
        ["encoder"]=>
        string(9) "LAME3.100"
        ["lossless"]=>
        bool(false)
        ["encoder_options"]=>
        string(6) "CBR128"
        ["compression_ratio"]=>
        float(0.090702947845805)
        ["streams"]=>
        array(1) {
          [0]=>
          array(11) {
            ["dataformat"]=>
            string(3) "mp3"
            ["channels"]=>
            int(2)
            ["sample_rate"]=>
            int(44100)
            ["bitrate"]=>
            int(128000)
            ["channelmode"]=>
            string(6) "stereo"
            ["bitrate_mode"]=>
            string(3) "cbr"
            ["codec"]=>
            string(4) "LAME"
            ["encoder"]=>
            string(9) "LAME3.100"
            ["lossless"]=>
            bool(false)
            ["encoder_options"]=>
            string(6) "CBR128"
            ["compression_ratio"]=>
            float(0.090702947845805)
          }
        }
      }
      ["tags"]=>
      array(2) {
        ["id3v1"]=>
        array(4) {
          ["title"]=>
          array(1) {
            [0]=>
            string(7) "My Song"
          }
          ["artist"]=>
          array(1) {
            [0]=>
            string(10) "The Artist"
          }
          ["album"]=>
          array(1) {
            [0]=>
            string(13) "Greatest Hits"
          }
          ["year"]=>
          array(1) {
            [0]=>
            string(4) "2004"
          }
        }
        ["id3v2"]=>
        array(5) {
          ["title"]=>
          array(1) {
            [0]=>
            string(7) "My Song"
          }
          ["artist"]=>
          array(1) {
            [0]=>
            string(10) "The Artist"
          }
          ["album"]=>
          array(1) {
            [0]=>
            string(13) "Greatest Hits"
          }
          ["year"]=>
          array(1) {
            [0]=>
            string(4) "2004"
          }
          ["genre"]=>
          array(1) {
            [0]=>
            string(5) "Dance"
          }
        }
      }
      ["encoding"]=>
      string(5) "UTF-8"
      ["id3v2"]=>
      array(15) {
        ["header"]=>
        bool(true)
        ["flags"]=>
        array(3) {
          ["unsynch"]=>
          bool(false)
          ["exthead"]=>
          bool(false)
          ["experim"]=>
          bool(false)
        }
        ["majorversion"]=>
        int(3)
        ["minorversion"]=>
        int(0)
        ["headerlength"]=>
        int(4096)
        ["tag_offset_start"]=>
        int(0)
        ["tag_offset_end"]=>
        int(4096)
        ["encoding"]=>
        string(5) "UTF-8"
        ["comments"]=>
        array(5) {
          ["title"]=>
          array(1) {
            [0]=>
            string(7) "My Song"
          }
          ["artist"]=>
          array(1) {
            [0]=>
            string(10) "The Artist"
          }
          ["album"]=>
          array(1) {
            [0]=>
            string(13) "Greatest Hits"
          }
          ["year"]=>
          array(1) {
            [0]=>
            string(4) "2004"
          }
          ["genre"]=>
          array(1) {
            [0]=>
            string(5) "Dance"
          }
        }
        ["TIT2"]=>
        array(1) {
          [0]=>
          array(10) {
            ["frame_name"]=>
            string(4) "TIT2"
            ["frame_flags_raw"]=>
            int(0)
            ["data"]=>
            string(7) "My Song"
            ["datalength"]=>
            int(8)
            ["dataoffset"]=>
            int(10)
            ["framenamelong"]=>
            string(34) "Title/songname/content description"
            ["framenameshort"]=>
            string(5) "title"
            ["flags"]=>
            array(6) {
              ["TagAlterPreservation"]=>
              bool(false)
              ["FileAlterPreservation"]=>
              bool(false)
              ["ReadOnly"]=>
              bool(false)
              ["compression"]=>
              bool(false)
              ["Encryption"]=>
              bool(false)
              ["GroupingIdentity"]=>
              bool(false)
            }
            ["encodingid"]=>
            int(0)
            ["encoding"]=>
            string(10) "ISO-8859-1"
          }
        }
        ["TPE1"]=>
        array(1) {
          [0]=>
          array(10) {
            ["frame_name"]=>
            string(4) "TPE1"
            ["frame_flags_raw"]=>
            int(0)
            ["data"]=>
            string(10) "The Artist"
            ["datalength"]=>
            int(11)
            ["dataoffset"]=>
            int(28)
            ["framenamelong"]=>
            string(28) "Lead performer(s)/Soloist(s)"
            ["framenameshort"]=>
            string(6) "artist"
            ["flags"]=>
            array(6) {
              ["TagAlterPreservation"]=>
              bool(false)
              ["FileAlterPreservation"]=>
              bool(false)
              ["ReadOnly"]=>
              bool(false)
              ["compression"]=>
              bool(false)
              ["Encryption"]=>
              bool(false)
              ["GroupingIdentity"]=>
              bool(false)
            }
            ["encodingid"]=>
            int(0)
            ["encoding"]=>
            string(10) "ISO-8859-1"
          }
        }
        ["TALB"]=>
        array(1) {
          [0]=>
          array(10) {
            ["frame_name"]=>
            string(4) "TALB"
            ["frame_flags_raw"]=>
            int(0)
            ["data"]=>
            string(13) "Greatest Hits"
            ["datalength"]=>
            int(14)
            ["dataoffset"]=>
            int(49)
            ["framenamelong"]=>
            string(22) "Album/Movie/Show title"
            ["framenameshort"]=>
            string(5) "album"
            ["flags"]=>
            array(6) {
              ["TagAlterPreservation"]=>
              bool(false)
              ["FileAlterPreservation"]=>
              bool(false)
              ["ReadOnly"]=>
              bool(false)
              ["compression"]=>
              bool(false)
              ["Encryption"]=>
              bool(false)
              ["GroupingIdentity"]=>
              bool(false)
            }
            ["encodingid"]=>
            int(0)
            ["encoding"]=>
            string(10) "ISO-8859-1"
          }
        }
        ["TYER"]=>
        array(1) {
          [0]=>
          array(10) {
            ["frame_name"]=>
            string(4) "TYER"
            ["frame_flags_raw"]=>
            int(0)
            ["data"]=>
            string(4) "2004"
            ["datalength"]=>
            int(5)
            ["dataoffset"]=>
            int(73)
            ["framenamelong"]=>
            string(4) "Year"
            ["framenameshort"]=>
            string(4) "year"
            ["flags"]=>
            array(6) {
              ["TagAlterPreservation"]=>
              bool(false)
              ["FileAlterPreservation"]=>
              bool(false)
              ["ReadOnly"]=>
              bool(false)
              ["compression"]=>
              bool(false)
              ["Encryption"]=>
              bool(false)
              ["GroupingIdentity"]=>
              bool(false)
            }
            ["encodingid"]=>
            int(0)
            ["encoding"]=>
            string(10) "ISO-8859-1"
          }
        }
        ["TCON"]=>
        array(1) {
          [0]=>
          array(10) {
            ["frame_name"]=>
            string(4) "TCON"
            ["frame_flags_raw"]=>
            int(0)
            ["data"]=>
            string(1) "3"
            ["datalength"]=>
            int(2)
            ["dataoffset"]=>
            int(88)
            ["framenamelong"]=>
            string(12) "Content type"
            ["framenameshort"]=>
            string(5) "genre"
            ["flags"]=>
            array(6) {
              ["TagAlterPreservation"]=>
              bool(false)
              ["FileAlterPreservation"]=>
              bool(false)
              ["ReadOnly"]=>
              bool(false)
              ["compression"]=>
              bool(false)
              ["Encryption"]=>
              bool(false)
              ["GroupingIdentity"]=>
              bool(false)
            }
            ["encodingid"]=>
            int(0)
            ["encoding"]=>
            string(10) "ISO-8859-1"
          }
        }
        ["padding"]=>
        array(3) {
          ["start"]=>
          int(100)
          ["length"]=>
          int(3996)
          ["valid"]=>
          bool(true)
        }
      }
      ["id3v1"]=>
      array(10) {
        ["title"]=>
        string(7) "My Song"
        ["artist"]=>
        string(10) "The Artist"
        ["album"]=>
        string(13) "Greatest Hits"
        ["year"]=>
        string(4) "2004"
        ["comment"]=>
        string(0) ""
        ["comments"]=>
        array(5) {
          ["title"]=>
          array(1) {
            [0]=>
            string(7) "My Song"
          }
          ["artist"]=>
          array(1) {
            [0]=>
            string(10) "The Artist"
          }
          ["album"]=>
          array(1) {
            [0]=>
            string(13) "Greatest Hits"
          }
          ["year"]=>
          array(1) {
            [0]=>
            string(4) "2004"
          }
          ["comment"]=>
          array(1) {
            [0]=>
            string(0) ""
          }
        }
        ["padding_valid"]=>
        bool(true)
        ["tag_offset_end"]=>
        int(262521)
        ["tag_offset_start"]=>
        int(262393)
        ["encoding"]=>
        string(10) "ISO-8859-1"
      }
      ["mime_type"]=>
      string(10) "audio/mpeg"
      ["mpeg"]=>
      array(1) {
        ["audio"]=>
        array(23) {
          ["raw"]=>
          array(13) {
            ["synch"]=>
            int(4094)
            ["version"]=>
            int(3)
            ["layer"]=>
            int(1)
            ["protection"]=>
            int(1)
            ["bitrate"]=>
            int(9)
            ["sample_rate"]=>
            int(0)
            ["padding"]=>
            int(0)
            ["private"]=>
            int(0)
            ["channelmode"]=>
            int(0)
            ["modeextension"]=>
            int(0)
            ["copyright"]=>
            int(0)
            ["original"]=>
            int(1)
            ["emphasis"]=>
            int(0)
          }
          ["version"]=>
          string(1) "1"
          ["layer"]=>
          int(3)
          ["channelmode"]=>
          string(6) "stereo"
          ["channels"]=>
          int(2)
          ["sample_rate"]=>
          int(44100)
          ["protection"]=>
          bool(false)
          ["private"]=>
          bool(false)
          ["modeextension"]=>
          string(0) ""
          ["copyright"]=>
          bool(false)
          ["original"]=>
          bool(true)
          ["emphasis"]=>
          string(4) "none"
          ["padding"]=>
          bool(false)
          ["bitrate"]=>
          int(128000)
          ["framelength"]=>
          float(418)
          ["bitrate_mode"]=>
          string(3) "cbr"
          ["VBR_method"]=>
          string(4) "Xing"
          ["xing_flags_raw"]=>
          int(15)
          ["xing_flags"]=>
          array(4) {
            ["frames"]=>
            bool(true)
            ["bytes"]=>
            bool(true)
            ["toc"]=>
            bool(true)
            ["vbr_scale"]=>
            bool(true)
          }
          ["VBR_frames"]=>
          int(617)
          ["VBR_bytes"]=>
          int(258297)
          ["toc"]=>
          array(100) {
            [0]=>
            int(0)
            [1]=>
            int(3)
            [2]=>
            int(5)
            [3]=>
            int(8)
            [4]=>
            int(10)
            [5]=>
            int(13)
            [6]=>
            int(15)
            [7]=>
            int(18)
            [8]=>
            int(20)
            [9]=>
            int(23)
            [10]=>
            int(25)
            [11]=>
            int(28)
            [12]=>
            int(30)
            [13]=>
            int(34)
            [14]=>
            int(36)
            [15]=>
            int(39)
            [16]=>
            int(41)
            [17]=>
            int(43)
            [18]=>
            int(46)
            [19]=>
            int(48)
            [20]=>
            int(51)
            [21]=>
            int(53)
            [22]=>
            int(56)
            [23]=>
            int(58)
            [24]=>
            int(61)
            [25]=>
            int(64)
            [26]=>
            int(67)
            [27]=>
            int(69)
            [28]=>
            int(72)
            [29]=>
            int(74)
            [30]=>
            int(77)
            [31]=>
            int(79)
            [32]=>
            int(82)
            [33]=>
            int(84)
            [34]=>
            int(87)
            [35]=>
            int(89)
            [36]=>
            int(92)
            [37]=>
            int(94)
            [38]=>
            int(97)
            [39]=>
            int(100)
            [40]=>
            int(102)
            [41]=>
            int(105)
            [42]=>
            int(107)
            [43]=>
            int(110)
            [44]=>
            int(112)
            [45]=>
            int(115)
            [46]=>
            int(117)
            [47]=>
            int(120)
            [48]=>
            int(122)
            [49]=>
            int(125)
            [50]=>
            int(128)
            [51]=>
            int(131)
            [52]=>
            int(133)
            [53]=>
            int(136)
            [54]=>
            int(138)
            [55]=>
            int(141)
            [56]=>
            int(143)
            [57]=>
            int(146)
            [58]=>
            int(148)
            [59]=>
            int(151)
            [60]=>
            int(153)
            [61]=>
            int(156)
            [62]=>
            int(158)
            [63]=>
            int(161)
            [64]=>
            int(164)
            [65]=>
            int(166)
            [66]=>
            int(169)
            [67]=>
            int(171)
            [68]=>
            int(174)
            [69]=>
            int(176)
            [70]=>
            int(179)
            [71]=>
            int(181)
            [72]=>
            int(184)
            [73]=>
            int(186)
            [74]=>
            int(189)
            [75]=>
            int(192)
            [76]=>
            int(195)
            [77]=>
            int(197)
            [78]=>
            int(199)
            [79]=>
            int(202)
            [80]=>
            int(204)
            [81]=>
            int(207)
            [82]=>
            int(209)
            [83]=>
            int(212)
            [84]=>
            int(214)
            [85]=>
            int(217)
            [86]=>
            int(219)
            [87]=>
            int(222)
            [88]=>
            int(225)
            [89]=>
            int(228)
            [90]=>
            int(230)
            [91]=>
            int(233)
            [92]=>
            int(235)
            [93]=>
            int(238)
            [94]=>
            int(240)
            [95]=>
            int(243)
            [96]=>
            int(245)
            [97]=>
            int(248)
            [98]=>
            int(250)
            [99]=>
            int(253)
          }
          ["LAME"]=>
          array(24) {
            ["short_version"]=>
            string(9) "LAME3.100"
            ["numeric_version"]=>
            string(5) "3.100"
            ["integer_version"]=>
            array(2) {
              [0]=>
              int(3)
              [1]=>
              int(100)
            }
            ["raw"]=>
            array(10) {
              ["vbr_method"]=>
              int(1)
              ["RGAD_track"]=>
              int(0)
              ["RGAD_album"]=>
              int(0)
              ["abrbitrate_minbitrate"]=>
              int(128)
              ["noise_shaping"]=>
              int(2)
              ["stereo_mode"]=>
              int(1)
              ["not_optimal_quality"]=>
              int(0)
              ["source_sample_freq"]=>
              int(1)
              ["mp3_gain"]=>
              int(0)
              ["surround_info"]=>
              int(0)
            }
            ["vbr_quality"]=>
            int(57)
            ["tag_revision"]=>
            int(0)
            ["vbr_method"]=>
            string(3) "cbr"
            ["lowpass_frequency"]=>
            int(17000)
            ["encoding_flags"]=>
            array(4) {
              ["nspsytune"]=>
              bool(true)
              ["nssafejoint"]=>
              bool(false)
              ["nogap_next"]=>
              bool(false)
              ["nogap_prev"]=>
              bool(false)
            }
            ["ath_type"]=>
            int(4)
            ["encoder_delay"]=>
            int(576)
            ["end_padding"]=>
            int(1600)
            ["noise_shaping"]=>
            int(2)
            ["stereo_mode"]=>
            string(6) "stereo"
            ["not_optimal_quality"]=>
            bool(false)
            ["source_sample_freq"]=>
            string(8) "44.1 kHz"
            ["mp3_gain_db"]=>
            float(0)
            ["mp3_gain_factor"]=>
            float(1)
            ["surround_info"]=>
            string(16) "no surround info"
            ["preset_used_id"]=>
            int(128)
            ["preset_used"]=>
            string(20) "--alt-preset cbr 128"
            ["audio_bytes"]=>
            int(258297)
            ["music_crc"]=>
            int(14435)
            ["lame_tag_crc"]=>
            int(57321)
          }
        }
      }
      ["playtime_seconds"]=>
      float(16.1174375)
      ["tags_html"]=>
      array(2) {
        ["id3v1"]=>
        array(4) {
          ["title"]=>
          array(1) {
            [0]=>
            string(7) "My Song"
          }
          ["artist"]=>
          array(1) {
            [0]=>
            string(10) "The Artist"
          }
          ["album"]=>
          array(1) {
            [0]=>
            string(13) "Greatest Hits"
          }
          ["year"]=>
          array(1) {
            [0]=>
            string(4) "2004"
          }
        }
        ["id3v2"]=>
        array(5) {
          ["title"]=>
          array(1) {
            [0]=>
            string(7) "My Song"
          }
          ["artist"]=>
          array(1) {
            [0]=>
            string(10) "The Artist"
          }
          ["album"]=>
          array(1) {
            [0]=>
            string(13) "Greatest Hits"
          }
          ["year"]=>
          array(1) {
            [0]=>
            string(4) "2004"
          }
          ["genre"]=>
          array(1) {
            [0]=>
            string(5) "Dance"
          }
        }
      }
      ["bitrate"]=>
      int(128000)
      ["playtime_string"]=>
      string(4) "0:16"
    }

     

  4. <?php
    /////////////////////////////////////////////////////////////////
    /// getID3() by James Heinrich <info@getid3.org>               //
    //  available at https://github.com/JamesHeinrich/getID3       //
    //            or https://www.getid3.org                        //
    //            or http://getid3.sourceforge.net                 //
    //                                                             //
    // /demo/demo.simple.write.php - part of getID3()              //
    // Sample script showing basic syntax for writing tags         //
    //  see readme.txt for more details                            //
    //                                                            ///
    /////////////////////////////////////////////////////////////////
    
    //die('For security reasons, this demo has been disabled. It can be enabled by removing line '.__LINE__.' in demos/'.basename(__FILE__));
    
    
    $TextEncoding = 'UTF-8';
    
    require_once('/home/brian/getID3/getid3/getid3.php');
    // Initialize getID3 engine
    $getID3 = new getID3;
    $getID3->setOption(array('encoding'=>$TextEncoding));
    
    require_once('/home/brian/getID3/getid3/write.php');
    // Initialize getID3 tag-writing module
    $tagwriter = new getid3_writetags;
    
    $tagwriter->filename = '/home/brian/Desktop/1.mp3';
    
    $tagwriter->tagformats = array('id3v1', 'id3v2.3');
    
    // set various options (optional)
    $tagwriter->overwrite_tags    = true;  // if true will erase existing tag data and write only passed data; if false will merge passed data with existing tag data (experimental)
    $tagwriter->remove_other_tags = true; // if true removes other tag formats (e.g. ID3v1, ID3v2, APE, Lyrics3, etc) that may be present in the file and only write the specified tag format(s). If false leaves any unspecified tag formats as-is.
    $tagwriter->tag_encoding      = $TextEncoding;
    
    
    // populate data array
    $TagData = array(
    	'title'                  => array('My Song'),
    	'artist'                 => array('The Artist'),
    	'album'                  => array('Greatest Hits'),
    	'year'                   => array('2004'),
    	'genre'                  => array('3')
    );
    
    
    
    $TagData['id3v2']['ETCO'] = [
    	"timestampformat" => 2,
    	["typeid" => 3, "timestamp" => 1000],
    	["typeid" => 4, "timestamp" => 1500],
    	// etc
    ];
    
    
    /*
    
    other ways I've tried
    
    $TagData['id3v2'][0] = array(
    'frame_name' => 'ETCO', 
    'data' => 3,
    'type' => 3,
    'timestamp' => 1000,
    'framenamelong' => 'Event Timing Codes',
    'framenameshort' => 'event timing codes',
    'timestampformat' => '2'
    );
    
    $TagData['id3v2'][0] = array(
    'frame_name' => 'ETCO', 
    'data' => 4,
    'type' => 4,
    'timestamp' => 1500,
    'framenamelong' => 'Event Timing Codes',
    'framenameshort' => 'event timing codes',
    'timestampformat' => '2'
    );
    
    
    
    
    
    $TagData['id3v2']['ETCO']['frame_name'] = 'ETCO';
    $TagData['id3v2']['ETCO']['data'] = 3;  // from the standard at https://id3.org/id3v2.3.0#sec4.6
    $TagData['id3v2']['ETCO']['type'] = 3;  // type 3 is mainpart start
    $TagData['id3v2']['ETCO']['timestamp'] = 1000; // milliseconds 
    $TagData['id3v2']['ETCO']['timestampformat'] = 2; // timestamp format #2 which is Absolute time, 32 bit sized, using milliseconds as unit
    
    $TagData['id3v2']['ETCO']['data'] = 4;  // from the standard at https://id3.org/id3v2.3.0#sec4.6
    $TagData['id3v2']['ETCO']['type'] = 4;  // type 4 is outro start
    $TagData['id3v2']['ETCO']['timestamp'] = 1500;  // milliseconds 
    $TagData['id3v2']['ETCO']['timestampformat'] = 2; // timestamp format #2 which is Absolute time, 32 bit sized, using milliseconds as unit
    
    
    
    
    $TagData['id3v2'][0]['TCON']['frame_flags_raw'] = 0; 
    $TagData['id3v2'][0]['TCON']['data'] = 3;
    $TagData['id3v2'][0]['TCON']['datalength'] = 4;
    $TagData['id3v2'][0]['TCON']['dataoffset'] = 55;
    $TagData['id3v2'][0]['TCON']['framenameshort'] = 'genre';
    
    
    
     */
    
    
    
    
    
    
    
    
    
    
    $tagwriter->tag_data = $TagData;
    
    // write tags
    if ($tagwriter->WriteTags()) {
    	echo 'Successfully wrote tags<br>';
    	if (!empty($tagwriter->warnings)) {
    		echo 'There were some warnings:<br>'.implode('<br><br>', $tagwriter->warnings);
    	}
    } else {
    	echo 'Failed to write tags!<br>'.implode('<br><br>', $tagwriter->errors);
    }
    
    ?>

     

  5. It does write other tags...normal ones like artist, title, year, etc...but not ETCo tags.  The change to the write.id3v2.php did NOT write these tags.  here's the new var_dump

    array(19) {
      ["GETID3_VERSION"]=>
      string(19) "1.9.20-202107131440"
      ["filesize"]=>
      int(181019)
      ["filepath"]=>
      string(19) "/home/brian/Desktop"
      ["filename"]=>
      string(5) "1.mp3"
      ["filenamepath"]=>
      string(25) "/home/brian/Desktop/1.mp3"
      ["avdataoffset"]=>
      int(4096)
      ["avdataend"]=>
      int(180891)
      ["fileformat"]=>
      string(3) "mp3"
      ["audio"]=>
      array(12) {
        ["dataformat"]=>
        string(3) "mp3"
        ["channels"]=>
        int(2)
        ["sample_rate"]=>
        int(44100)
        ["bitrate"]=>
        int(128000)
        ["channelmode"]=>
        string(6) "stereo"
        ["bitrate_mode"]=>
        string(3) "cbr"
        ["codec"]=>
        string(4) "LAME"
        ["encoder"]=>
        string(9) "LAME3.99r"
        ["lossless"]=>
        bool(false)
        ["encoder_options"]=>
        string(6) "CBR128"
        ["compression_ratio"]=>
        float(0.090702947845805)
        ["streams"]=>
        array(1) {
          [0]=>
          array(11) {
            ["dataformat"]=>
            string(3) "mp3"
            ["channels"]=>
            int(2)
            ["sample_rate"]=>
            int(44100)
            ["bitrate"]=>
            int(128000)
            ["channelmode"]=>
            string(6) "stereo"
            ["bitrate_mode"]=>
            string(3) "cbr"
            ["codec"]=>
            string(4) "LAME"
            ["encoder"]=>
            string(9) "LAME3.99r"
            ["lossless"]=>
            bool(false)
            ["encoder_options"]=>
            string(6) "CBR128"
            ["compression_ratio"]=>
            float(0.090702947845805)
          }
        }
      }
      ["tags"]=>
      array(2) {
        ["id3v1"]=>
        array(4) {
          ["title"]=>
          array(1) {
            [0]=>
            string(7) "My Song"
          }
          ["artist"]=>
          array(1) {
            [0]=>
            string(10) "The Artist"
          }
          ["album"]=>
          array(1) {
            [0]=>
            string(13) "Greatest Hits"
          }
          ["year"]=>
          array(1) {
            [0]=>
            string(4) "2004"
          }
        }
        ["id3v2"]=>
        array(5) {
          ["title"]=>
          array(1) {
            [0]=>
            string(7) "My Song"
          }
          ["artist"]=>
          array(1) {
            [0]=>
            string(10) "The Artist"
          }
          ["album"]=>
          array(1) {
            [0]=>
            string(13) "Greatest Hits"
          }
          ["year"]=>
          array(1) {
            [0]=>
            string(4) "2004"
          }
          ["genre"]=>
          array(1) {
            [0]=>
            string(5) "Dance"
          }
        }
      }
      ["encoding"]=>
      string(5) "UTF-8"
      ["id3v2"]=>
      array(15) {
        ["header"]=>
        bool(true)
        ["flags"]=>
        array(3) {
          ["unsynch"]=>
          bool(false)
          ["exthead"]=>
          bool(false)
          ["experim"]=>
          bool(false)
        }
        ["majorversion"]=>
        int(3)
        ["minorversion"]=>
        int(0)
        ["headerlength"]=>
        int(4096)
        ["tag_offset_start"]=>
        int(0)
        ["tag_offset_end"]=>
        int(4096)
        ["encoding"]=>
        string(5) "UTF-8"
        ["comments"]=>
        array(5) {
          ["title"]=>
          array(1) {
            [0]=>
            string(7) "My Song"
          }
          ["artist"]=>
          array(1) {
            [0]=>
            string(10) "The Artist"
          }
          ["album"]=>
          array(1) {
            [0]=>
            string(13) "Greatest Hits"
          }
          ["year"]=>
          array(1) {
            [0]=>
            string(4) "2004"
          }
          ["genre"]=>
          array(1) {
            [0]=>
            string(5) "Dance"
          }
        }
        ["TIT2"]=>
        array(1) {
          [0]=>
          array(10) {
            ["frame_name"]=>
            string(4) "TIT2"
            ["frame_flags_raw"]=>
            int(0)
            ["data"]=>
            string(7) "My Song"
            ["datalength"]=>
            int(8)
            ["dataoffset"]=>
            int(10)
            ["framenamelong"]=>
            string(34) "Title/songname/content description"
            ["framenameshort"]=>
            string(5) "title"
            ["flags"]=>
            array(6) {
              ["TagAlterPreservation"]=>
              bool(false)
              ["FileAlterPreservation"]=>
              bool(false)
              ["ReadOnly"]=>
              bool(false)
              ["compression"]=>
              bool(false)
              ["Encryption"]=>
              bool(false)
              ["GroupingIdentity"]=>
              bool(false)
            }
            ["encodingid"]=>
            int(0)
            ["encoding"]=>
            string(10) "ISO-8859-1"
          }
        }
        ["TPE1"]=>
        array(1) {
          [0]=>
          array(10) {
            ["frame_name"]=>
            string(4) "TPE1"
            ["frame_flags_raw"]=>
            int(0)
            ["data"]=>
            string(10) "The Artist"
            ["datalength"]=>
            int(11)
            ["dataoffset"]=>
            int(28)
            ["framenamelong"]=>
            string(28) "Lead performer(s)/Soloist(s)"
            ["framenameshort"]=>
            string(6) "artist"
            ["flags"]=>
            array(6) {
              ["TagAlterPreservation"]=>
              bool(false)
              ["FileAlterPreservation"]=>
              bool(false)
              ["ReadOnly"]=>
              bool(false)
              ["compression"]=>
              bool(false)
              ["Encryption"]=>
              bool(false)
              ["GroupingIdentity"]=>
              bool(false)
            }
            ["encodingid"]=>
            int(0)
            ["encoding"]=>
            string(10) "ISO-8859-1"
          }
        }
        ["TALB"]=>
        array(1) {
          [0]=>
          array(10) {
            ["frame_name"]=>
            string(4) "TALB"
            ["frame_flags_raw"]=>
            int(0)
            ["data"]=>
            string(13) "Greatest Hits"
            ["datalength"]=>
            int(14)
            ["dataoffset"]=>
            int(49)
            ["framenamelong"]=>
            string(22) "Album/Movie/Show title"
            ["framenameshort"]=>
            string(5) "album"
            ["flags"]=>
            array(6) {
              ["TagAlterPreservation"]=>
              bool(false)
              ["FileAlterPreservation"]=>
              bool(false)
              ["ReadOnly"]=>
              bool(false)
              ["compression"]=>
              bool(false)
              ["Encryption"]=>
              bool(false)
              ["GroupingIdentity"]=>
              bool(false)
            }
            ["encodingid"]=>
            int(0)
            ["encoding"]=>
            string(10) "ISO-8859-1"
          }
        }
        ["TYER"]=>
        array(1) {
          [0]=>
          array(10) {
            ["frame_name"]=>
            string(4) "TYER"
            ["frame_flags_raw"]=>
            int(0)
            ["data"]=>
            string(4) "2004"
            ["datalength"]=>
            int(5)
            ["dataoffset"]=>
            int(73)
            ["framenamelong"]=>
            string(4) "Year"
            ["framenameshort"]=>
            string(4) "year"
            ["flags"]=>
            array(6) {
              ["TagAlterPreservation"]=>
              bool(false)
              ["FileAlterPreservation"]=>
              bool(false)
              ["ReadOnly"]=>
              bool(false)
              ["compression"]=>
              bool(false)
              ["Encryption"]=>
              bool(false)
              ["GroupingIdentity"]=>
              bool(false)
            }
            ["encodingid"]=>
            int(0)
            ["encoding"]=>
            string(10) "ISO-8859-1"
          }
        }
        ["TCON"]=>
        array(1) {
          [0]=>
          array(10) {
            ["frame_name"]=>
            string(4) "TCON"
            ["frame_flags_raw"]=>
            int(0)
            ["data"]=>
            string(1) "3"
            ["datalength"]=>
            int(2)
            ["dataoffset"]=>
            int(88)
            ["framenamelong"]=>
            string(12) "Content type"
            ["framenameshort"]=>
            string(5) "genre"
            ["flags"]=>
            array(6) {
              ["TagAlterPreservation"]=>
              bool(false)
              ["FileAlterPreservation"]=>
              bool(false)
              ["ReadOnly"]=>
              bool(false)
              ["compression"]=>
              bool(false)
              ["Encryption"]=>
              bool(false)
              ["GroupingIdentity"]=>
              bool(false)
            }
            ["encodingid"]=>
            int(0)
            ["encoding"]=>
            string(10) "ISO-8859-1"
          }
        }
        ["padding"]=>
        array(3) {
          ["start"]=>
          int(100)
          ["length"]=>
          int(3996)
          ["valid"]=>
          bool(true)
        }
      }
      ["id3v1"]=>
      array(10) {
        ["title"]=>
        string(7) "My Song"
        ["artist"]=>
        string(10) "The Artist"
        ["album"]=>
        string(13) "Greatest Hits"
        ["year"]=>
        string(4) "2004"
        ["comment"]=>
        string(0) ""
        ["comments"]=>
        array(5) {
          ["title"]=>
          array(1) {
            [0]=>
            string(7) "My Song"
          }
          ["artist"]=>
          array(1) {
            [0]=>
            string(10) "The Artist"
          }
          ["album"]=>
          array(1) {
            [0]=>
            string(13) "Greatest Hits"
          }
          ["year"]=>
          array(1) {
            [0]=>
            string(4) "2004"
          }
          ["comment"]=>
          array(1) {
            [0]=>
            string(0) ""
          }
        }
        ["padding_valid"]=>
        bool(true)
        ["tag_offset_end"]=>
        int(181019)
        ["tag_offset_start"]=>
        int(180891)
        ["encoding"]=>
        string(10) "ISO-8859-1"
      }
      ["mime_type"]=>
      string(10) "audio/mpeg"
      ["mpeg"]=>
      array(1) {
        ["audio"]=>
        array(23) {
          ["raw"]=>
          array(13) {
            ["synch"]=>
            int(4094)
            ["version"]=>
            int(3)
            ["layer"]=>
            int(1)
            ["protection"]=>
            int(1)
            ["bitrate"]=>
            int(9)
            ["sample_rate"]=>
            int(0)
            ["padding"]=>
            int(0)
            ["private"]=>
            int(0)
            ["channelmode"]=>
            int(0)
            ["modeextension"]=>
            int(0)
            ["copyright"]=>
            int(0)
            ["original"]=>
            int(1)
            ["emphasis"]=>
            int(0)
          }
          ["version"]=>
          string(1) "1"
          ["layer"]=>
          int(3)
          ["channelmode"]=>
          string(6) "stereo"
          ["channels"]=>
          int(2)
          ["sample_rate"]=>
          int(44100)
          ["protection"]=>
          bool(false)
          ["private"]=>
          bool(false)
          ["modeextension"]=>
          string(0) ""
          ["copyright"]=>
          bool(false)
          ["original"]=>
          bool(true)
          ["emphasis"]=>
          string(4) "none"
          ["padding"]=>
          bool(false)
          ["bitrate"]=>
          int(128000)
          ["framelength"]=>
          float(418)
          ["bitrate_mode"]=>
          string(3) "cbr"
          ["VBR_method"]=>
          string(4) "Xing"
          ["xing_flags_raw"]=>
          int(15)
          ["xing_flags"]=>
          array(4) {
            ["frames"]=>
            bool(true)
            ["bytes"]=>
            bool(true)
            ["toc"]=>
            bool(true)
            ["vbr_scale"]=>
            bool(true)
          }
          ["VBR_frames"]=>
          int(422)
          ["VBR_bytes"]=>
          int(176795)
          ["toc"]=>
          array(100) {
            [0]=>
            int(0)
            [1]=>
            int(3)
            [2]=>
            int(6)
            [3]=>
            int(8)
            [4]=>
            int(10)
            [5]=>
            int(13)
            [6]=>
            int(15)
            [7]=>
            int(18)
            [8]=>
            int(20)
            [9]=>
            int(23)
            [10]=>
            int(26)
            [11]=>
            int(29)
            [12]=>
            int(31)
            [13]=>
            int(33)
            [14]=>
            int(36)
            [15]=>
            int(38)
            [16]=>
            int(41)
            [17]=>
            int(43)
            [18]=>
            int(46)
            [19]=>
            int(49)
            [20]=>
            int(52)
            [21]=>
            int(54)
            [22]=>
            int(57)
            [23]=>
            int(59)
            [24]=>
            int(61)
            [25]=>
            int(64)
            [26]=>
            int(66)
            [27]=>
            int(69)
            [28]=>
            int(72)
            [29]=>
            int(75)
            [30]=>
            int(77)
            [31]=>
            int(80)
            [32]=>
            int(82)
            [33]=>
            int(84)
            [34]=>
            int(87)
            [35]=>
            int(89)
            [36]=>
            int(92)
            [37]=>
            int(95)
            [38]=>
            int(98)
            [39]=>
            int(100)
            [40]=>
            int(103)
            [41]=>
            int(105)
            [42]=>
            int(107)
            [43]=>
            int(110)
            [44]=>
            int(112)
            [45]=>
            int(115)
            [46]=>
            int(118)
            [47]=>
            int(121)
            [48]=>
            int(123)
            [49]=>
            int(126)
            [50]=>
            int(128)
            [51]=>
            int(131)
            [52]=>
            int(133)
            [53]=>
            int(135)
            [54]=>
            int(138)
            [55]=>
            int(141)
            [56]=>
            int(144)
            [57]=>
            int(146)
            [58]=>
            int(149)
            [59]=>
            int(151)
            [60]=>
            int(154)
            [61]=>
            int(156)
            [62]=>
            int(158)
            [63]=>
            int(161)
            [64]=>
            int(165)
            [65]=>
            int(167)
            [66]=>
            int(169)
            [67]=>
            int(172)
            [68]=>
            int(174)
            [69]=>
            int(177)
            [70]=>
            int(179)
            [71]=>
            int(181)
            [72]=>
            int(184)
            [73]=>
            int(188)
            [74]=>
            int(190)
            [75]=>
            int(192)
            [76]=>
            int(195)
            [77]=>
            int(197)
            [78]=>
            int(200)
            [79]=>
            int(202)
            [80]=>
            int(205)
            [81]=>
            int(207)
            [82]=>
            int(211)
            [83]=>
            int(213)
            [84]=>
            int(215)
            [85]=>
            int(218)
            [86]=>
            int(220)
            [87]=>
            int(223)
            [88]=>
            int(225)
            [89]=>
            int(228)
            [90]=>
            int(230)
            [91]=>
            int(234)
            [92]=>
            int(236)
            [93]=>
            int(239)
            [94]=>
            int(241)
            [95]=>
            int(243)
            [96]=>
            int(246)
            [97]=>
            int(248)
            [98]=>
            int(251)
            [99]=>
            int(253)
          }
          ["LAME"]=>
          array(24) {
            ["short_version"]=>
            string(9) "LAME3.99r"
            ["numeric_version"]=>
            string(5) "3.99r"
            ["integer_version"]=>
            array(2) {
              [0]=>
              int(3)
              [1]=>
              int(99)
            }
            ["raw"]=>
            array(10) {
              ["vbr_method"]=>
              int(1)
              ["RGAD_track"]=>
              int(0)
              ["RGAD_album"]=>
              int(0)
              ["abrbitrate_minbitrate"]=>
              int(128)
              ["noise_shaping"]=>
              int(2)
              ["stereo_mode"]=>
              int(1)
              ["not_optimal_quality"]=>
              int(0)
              ["source_sample_freq"]=>
              int(1)
              ["mp3_gain"]=>
              int(0)
              ["surround_info"]=>
              int(0)
            }
            ["vbr_quality"]=>
            int(57)
            ["tag_revision"]=>
            int(0)
            ["vbr_method"]=>
            string(3) "cbr"
            ["lowpass_frequency"]=>
            int(17000)
            ["encoding_flags"]=>
            array(4) {
              ["nspsytune"]=>
              bool(true)
              ["nssafejoint"]=>
              bool(false)
              ["nogap_next"]=>
              bool(false)
              ["nogap_prev"]=>
              bool(false)
            }
            ["ath_type"]=>
            int(4)
            ["encoder_delay"]=>
            int(576)
            ["end_padding"]=>
            int(1088)
            ["noise_shaping"]=>
            int(2)
            ["stereo_mode"]=>
            string(6) "stereo"
            ["not_optimal_quality"]=>
            bool(false)
            ["source_sample_freq"]=>
            string(8) "44.1 kHz"
            ["mp3_gain_db"]=>
            float(0)
            ["mp3_gain_factor"]=>
            float(1)
            ["surround_info"]=>
            string(16) "no surround info"
            ["preset_used_id"]=>
            int(128)
            ["preset_used"]=>
            string(20) "--alt-preset cbr 128"
            ["audio_bytes"]=>
            int(176795)
            ["music_crc"]=>
            int(33268)
            ["lame_tag_crc"]=>
            int(56695)
          }
        }
      }
      ["playtime_seconds"]=>
      float(11.0235625)
      ["tags_html"]=>
      array(2) {
        ["id3v1"]=>
        array(4) {
          ["title"]=>
          array(1) {
            [0]=>
            string(7) "My Song"
          }
          ["artist"]=>
          array(1) {
            [0]=>
            string(10) "The Artist"
          }
          ["album"]=>
          array(1) {
            [0]=>
            string(13) "Greatest Hits"
          }
          ["year"]=>
          array(1) {
            [0]=>
            string(4) "2004"
          }
        }
        ["id3v2"]=>
        array(5) {
          ["title"]=>
          array(1) {
            [0]=>
            string(7) "My Song"
          }
          ["artist"]=>
          array(1) {
            [0]=>
            string(10) "The Artist"
          }
          ["album"]=>
          array(1) {
            [0]=>
            string(13) "Greatest Hits"
          }
          ["year"]=>
          array(1) {
            [0]=>
            string(4) "2004"
          }
          ["genre"]=>
          array(1) {
            [0]=>
            string(5) "Dance"
          }
        }
      }
      ["bitrate"]=>
      int(128000)
      ["playtime_string"]=>
      string(4) "0:11"
    }

     

  6. If you want to see the raw tags for yourself, the file is at http://brian-schultz.com/1.mp3

    Here's the var_dump

     

    array(19) {
      ["GETID3_VERSION"]=>
      string(19) "1.9.20-202107131440"
      ["filesize"]=>
      int(258297)
      ["filepath"]=>
      string(19) "/home/brian/Desktop"
      ["filename"]=>
      string(5) "1.mp3"
      ["filenamepath"]=>
      string(25) "/home/brian/Desktop/1.mp3"
      ["avdataoffset"]=>
      int(4178)
      ["avdataend"]=>
      int(258297)
      ["fileformat"]=>
      string(3) "mp3"
      ["audio"]=>
      array(10) {
        ["dataformat"]=>
        string(3) "mp3"
        ["channels"]=>
        int(2)
        ["sample_rate"]=>
        int(44100)
        ["bitrate"]=>
        int(128000)
        ["channelmode"]=>
        string(6) "stereo"
        ["bitrate_mode"]=>
        string(3) "cbr"
        ["lossless"]=>
        bool(false)
        ["encoder_options"]=>
        string(6) "CBR128"
        ["compression_ratio"]=>
        float(0.090702947845805)
        ["streams"]=>
        array(1) {
          [0]=>
          array(9) {
            ["dataformat"]=>
            string(3) "mp3"
            ["channels"]=>
            int(2)
            ["sample_rate"]=>
            int(44100)
            ["bitrate"]=>
            int(128000)
            ["channelmode"]=>
            string(6) "stereo"
            ["bitrate_mode"]=>
            string(3) "cbr"
            ["lossless"]=>
            bool(false)
            ["encoder_options"]=>
            string(6) "CBR128"
            ["compression_ratio"]=>
            float(0.090702947845805)
          }
        }
      }
      ["tags"]=>
      array(1) {
        ["id3v2"]=>
        array(2) {
          ["title"]=>
          array(1) {
            [0]=>
            string(5) "1.mp3"
          }
          ["genre"]=>
          array(1) {
            [0]=>
            string(5) "Dance"
          }
        }
      }
      ["warning"]=>
      array(1) {
        [0]=>
        string(100) "Unknown data before synch (ID3v2 header ends at 4096, then 82 bytes garbage, synch detected at 4178)"
      }
      ["encoding"]=>
      string(5) "UTF-8"
      ["id3v2"]=>
      array(13) {
        ["header"]=>
        bool(true)
        ["flags"]=>
        array(3) {
          ["unsynch"]=>
          bool(false)
          ["exthead"]=>
          bool(false)
          ["experim"]=>
          bool(false)
        }
        ["majorversion"]=>
        int(3)
        ["minorversion"]=>
        int(0)
        ["headerlength"]=>
        int(4096)
        ["tag_offset_start"]=>
        int(0)
        ["tag_offset_end"]=>
        int(4096)
        ["encoding"]=>
        string(5) "UTF-8"
        ["comments"]=>
        array(2) {
          ["title"]=>
          array(1) {
            [0]=>
            string(5) "1.mp3"
          }
          ["genre"]=>
          array(1) {
            [0]=>
            string(5) "Dance"
          }
        }
        ["TIT2"]=>
        array(1) {
          [0]=>
          array(10) {
            ["frame_name"]=>
            string(4) "TIT2"
            ["frame_flags_raw"]=>
            int(0)
            ["data"]=>
            string(5) "1.mp3"
            ["datalength"]=>
            int(7)
            ["dataoffset"]=>
            int(10)
            ["framenamelong"]=>
            string(34) "Title/songname/content description"
            ["framenameshort"]=>
            string(5) "title"
            ["flags"]=>
            array(6) {
              ["TagAlterPreservation"]=>
              bool(false)
              ["FileAlterPreservation"]=>
              bool(false)
              ["ReadOnly"]=>
              bool(false)
              ["compression"]=>
              bool(false)
              ["Encryption"]=>
              bool(false)
              ["GroupingIdentity"]=>
              bool(false)
            }
            ["encodingid"]=>
            int(0)
            ["encoding"]=>
            string(10) "ISO-8859-1"
          }
        }
        ["TCON"]=>
        array(1) {
          [0]=>
          array(10) {
            ["frame_name"]=>
            string(4) "TCON"
            ["frame_flags_raw"]=>
            int(0)
            ["data"]=>
            string(2) " 3"
            ["datalength"]=>
            int(4)
            ["dataoffset"]=>
            int(27)
            ["framenamelong"]=>
            string(12) "Content type"
            ["framenameshort"]=>
            string(5) "genre"
            ["flags"]=>
            array(6) {
              ["TagAlterPreservation"]=>
              bool(false)
              ["FileAlterPreservation"]=>
              bool(false)
              ["ReadOnly"]=>
              bool(false)
              ["compression"]=>
              bool(false)
              ["Encryption"]=>
              bool(false)
              ["GroupingIdentity"]=>
              bool(false)
            }
            ["encodingid"]=>
            int(0)
            ["encoding"]=>
            string(10) "ISO-8859-1"
          }
        }
        ["ETCO"]=>
        array(1) {
          [0]=>
          array(11) {
            ["frame_name"]=>
            string(4) "ETCO"
            ["frame_flags_raw"]=>
            int(0)
            ["datalength"]=>
            int(12)
            ["dataoffset"]=>
            int(41)
            ["framenamelong"]=>
            string(18) "Event timing codes"
            ["framenameshort"]=>
            string(18) "event_timing_codes"
            ["flags"]=>
            array(6) {
              ["TagAlterPreservation"]=>
              bool(false)
              ["FileAlterPreservation"]=>
              bool(false)
              ["ReadOnly"]=>
              bool(false)
              ["compression"]=>
              bool(false)
              ["Encryption"]=>
              bool(false)
              ["GroupingIdentity"]=>
              bool(false)
            }
            ["timestampformat"]=>
            int(2)
            ["typeid"]=>
            string(1) ""
            ["type"]=>
            string(0) ""
            ["timestamp"]=>
            bool(false)
          }
        }
        ["PRIV"]=>
        array(1) {
          [0]=>
          array(9) {
            ["frame_name"]=>
            string(4) "PRIV"
            ["frame_flags_raw"]=>
            int(0)
            ["data"]=>
            string(4022) ""
            ["datalength"]=>
            int(4023)
            ["dataoffset"]=>
            int(63)
            ["framenamelong"]=>
            string(13) "Private frame"
            ["framenameshort"]=>
            string(13) "private_frame"
            ["flags"]=>
            array(6) {
              ["TagAlterPreservation"]=>
              bool(false)
              ["FileAlterPreservation"]=>
              bool(false)
              ["ReadOnly"]=>
              bool(false)
              ["compression"]=>
              bool(false)
              ["Encryption"]=>
              bool(false)
              ["GroupingIdentity"]=>
              bool(false)
            }
            ["ownerid"]=>
            string(0) ""
          }
        }
      }
      ["mime_type"]=>
      string(10) "audio/mpeg"
      ["mpeg"]=>
      array(1) {
        ["audio"]=>
        array(16) {
          ["raw"]=>
          array(13) {
            ["synch"]=>
            int(4094)
            ["version"]=>
            int(3)
            ["layer"]=>
            int(1)
            ["protection"]=>
            int(1)
            ["bitrate"]=>
            int(9)
            ["sample_rate"]=>
            int(0)
            ["padding"]=>
            int(1)
            ["private"]=>
            int(0)
            ["channelmode"]=>
            int(0)
            ["modeextension"]=>
            int(0)
            ["copyright"]=>
            int(0)
            ["original"]=>
            int(1)
            ["emphasis"]=>
            int(0)
          }
          ["version"]=>
          string(1) "1"
          ["layer"]=>
          int(3)
          ["channelmode"]=>
          string(6) "stereo"
          ["channels"]=>
          int(2)
          ["sample_rate"]=>
          int(44100)
          ["protection"]=>
          bool(false)
          ["private"]=>
          bool(false)
          ["modeextension"]=>
          string(0) ""
          ["copyright"]=>
          bool(false)
          ["original"]=>
          bool(true)
          ["emphasis"]=>
          string(4) "none"
          ["padding"]=>
          bool(true)
          ["bitrate"]=>
          int(128000)
          ["framelength"]=>
          int(418)
          ["bitrate_mode"]=>
          string(3) "cbr"
        }
      }
      ["playtime_seconds"]=>
      float(15.8824375)
      ["tags_html"]=>
      array(1) {
        ["id3v2"]=>
        array(2) {
          ["title"]=>
          array(1) {
            [0]=>
            string(5) "1.mp3"
          }
          ["genre"]=>
          array(1) {
            [0]=>
            string(5) "Dance"
          }
        }
      }
      ["bitrate"]=>
      int(128000)
      ["playtime_string"]=>
      string(4) "0:16"
    }

     

  7. I won't ever have to GET the tags...once they're set, I don't have to touch the file again.  The biggest problem is our radio automation system is a Mac program.  The only way to set the tags on our Mac is to play the file...in real time...and press the space bar to set the intro and outro tags.  That's how the Mac program works.  Not time efficient at all!

    Here's what getID3 reported back for a file with the tags as written by the Mac:

     

    Array
    (
        [GETID3_VERSION] => 1.9.20-202107131440
        [filesize] => 258297
        [filepath] => /home/brian/Desktop
        [filename] => 1.mp3
        [filenamepath] => /home/brian/Desktop/1.mp3
        [avdataoffset] => 4178
        [avdataend] => 258297
        [fileformat] => mp3
        [audio] => Array
            (
                [dataformat] => mp3
                [channels] => 2
                [sample_rate] => 44100
                [bitrate] => 128000
                [channelmode] => stereo
                [bitrate_mode] => cbr
                [lossless] => 
                [encoder_options] => CBR128
                [compression_ratio] => 0.090702947845805
                [streams] => Array
                    (
                        [0] => Array
                            (
                                [dataformat] => mp3
                                [channels] => 2
                                [sample_rate] => 44100
                                [bitrate] => 128000
                                [channelmode] => stereo
                                [bitrate_mode] => cbr
                                [lossless] => 
                                [encoder_options] => CBR128
                                [compression_ratio] => 0.090702947845805
                            )
    
                    )
    
            )
    
        [tags] => Array
            (
                [id3v2] => Array
                    (
                        [title] => Array
                            (
                                [0] => 1.mp3
                            )
    
                        [genre] => Array
                            (
                                [0] => Dance
                            )
    
                    )
    
            )
    
        [warning] => Array
            (
                [0] => Unknown data before synch (ID3v2 header ends at 4096, then 82 bytes garbage, synch detected at 4178)
            )
    
        [encoding] => UTF-8
        [id3v2] => Array
            (
                [header] => 1
                [flags] => Array
                    (
                        [unsynch] => 
                        [exthead] => 
                        [experim] => 
                    )
    
                [majorversion] => 3
                [minorversion] => 0
                [headerlength] => 4096
                [tag_offset_start] => 0
                [tag_offset_end] => 4096
                [encoding] => UTF-8
                [comments] => Array
                    (
                        [title] => Array
                            (
                                [0] => 1.mp3
                            )
    
                        [genre] => Array
                            (
                                [0] => Dance
                            )
    
                    )
    
                [TIT2] => Array
                    (
                        [0] => Array
                            (
                                [frame_name] => TIT2
                                [frame_flags_raw] => 0
                                [data] => 1.mp3
                                [datalength] => 7
                                [dataoffset] => 10
                                [framenamelong] => Title/songname/content description
                                [framenameshort] => title
                                [flags] => Array
                                    (
                                        [TagAlterPreservation] => 
                                        [FileAlterPreservation] => 
                                        [ReadOnly] => 
                                        [compression] => 
                                        [Encryption] => 
                                        [GroupingIdentity] => 
                                    )
    
                                [encodingid] => 0
                                [encoding] => ISO-8859-1
                            )
    
                    )
    
                [TCON] => Array
                    (
                        [0] => Array
                            (
                                [frame_name] => TCON
                                [frame_flags_raw] => 0
                                [data] =>  3
                                [datalength] => 4
                                [dataoffset] => 27
                                [framenamelong] => Content type
                                [framenameshort] => genre
                                [flags] => Array
                                    (
                                        [TagAlterPreservation] => 
                                        [FileAlterPreservation] => 
                                        [ReadOnly] => 
                                        [compression] => 
                                        [Encryption] => 
                                        [GroupingIdentity] => 
                                    )
    
                                [encodingid] => 0
                                [encoding] => ISO-8859-1
                            )
    
                    )
    
                [ETCO] => Array
                    (
                        [0] => Array
                            (
                                [frame_name] => ETCO
                                [frame_flags_raw] => 0
                                [datalength] => 12
                                [dataoffset] => 41
                                [framenamelong] => Event timing codes
                                [framenameshort] => event_timing_codes
                                [flags] => Array
                                    (
                                        [TagAlterPreservation] => 
                                        [FileAlterPreservation] => 
                                        [ReadOnly] => 
                                        [compression] => 
                                        [Encryption] => 
                                        [GroupingIdentity] => 
                                    )
    
                                [timestampformat] => 2
                                [typeid] => 
                                [type] => 
                                [timestamp] => 
                            )
    
                    )
    
                [PRIV] => Array
                    (
                        [0] => Array
                            (
                                [frame_name] => PRIV
                                [frame_flags_raw] => 0
                                [data] => 
                                [datalength] => 4023
                                [dataoffset] => 63
                                [framenamelong] => Private frame
                                [framenameshort] => private_frame
                                [flags] => Array
                                    (
                                        [TagAlterPreservation] => 
                                        [FileAlterPreservation] => 
                                        [ReadOnly] => 
                                        [compression] => 
                                        [Encryption] => 
                                        [GroupingIdentity] => 
                                    )
    
                                [ownerid] => 
                            )
    
                    )
    
            )
    
        [mime_type] => audio/mpeg
        [mpeg] => Array
            (
                [audio] => Array
                    (
                        [raw] => Array
                            (
                                [synch] => 4094
                                [version] => 3
                                [layer] => 1
                                [protection] => 1
                                [bitrate] => 9
                                [sample_rate] => 0
                                [padding] => 1
                                [private] => 0
                                [channelmode] => 0
                                [modeextension] => 0
                                [copyright] => 0
                                [original] => 1
                                [emphasis] => 0
                            )
    
                        [version] => 1
                        [layer] => 3
                        [channelmode] => stereo
                        [channels] => 2
                        [sample_rate] => 44100
                        [protection] => 
                        [private] => 
                        [modeextension] => 
                        [copyright] => 
                        [original] => 1
                        [emphasis] => none
                        [padding] => 1
                        [bitrate] => 128000
                        [framelength] => 418
                        [bitrate_mode] => cbr
                    )
    
            )
    
        [playtime_seconds] => 15.8824375
        [tags_html] => Array
            (
                [id3v2] => Array
                    (
                        [title] => Array
                            (
                                [0] => 1.mp3
                            )
    
                        [genre] => Array
                            (
                                [0] => Dance
                            )
    
                    )
    
            )
    
        [bitrate] => 128000
        [playtime_string] => 0:16
    )

    Oddly enough, there's a warning on line 61...and the tags I'm expecting to see under ETCO are blank!  Maybe this library can't even read these tags properly...much less write them!

                                [timestampformat] => 2
                                [typeid] =>
                                [type] =>
                                [timestamp] =>

  8. This is the standard getID3 code for submitting the data...which calls the warning and errors reported back...and it reported nothing.

     

    $tagwriter->tag_data = $TagData;
    
    // write tags
    if ($tagwriter->WriteTags()) {
    	echo 'Successfully wrote tags<br>';
    	if (!empty($tagwriter->warnings)) {
    		echo 'There were some warnings:<br>'.implode('<br><br>', $tagwriter->warnings);
    	}
    } else {
    	echo 'Failed to write tags!<br>'.implode('<br><br>', $tagwriter->errors);
    }

     

  9. I've started to dabble with getID3 to write tags for use with a given audio program we use at the radio station I work for.  The program uses id3v2.3 tags for frame_name ETCO:

    Here's the code that getID3 uses for handling ETCO tags:

     

    		} elseif ((($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'ETCO')) || // 4.5   ETCO Event timing codes
    				(($id3v2_majorversion == 2) && ($parsedFrame['frame_name'] == 'ETC'))) {     // 4.6   ETC  Event timing codes
    			//   There may only be one 'ETCO' frame in each tag
    			// <Header for 'Event timing codes', ID: 'ETCO'>
    			// Time stamp format    $xx
    			//   Where time stamp format is:
    			// $01  (32-bit value) MPEG frames from beginning of file
    			// $02  (32-bit value) milliseconds from beginning of file
    			//   Followed by a list of key events in the following format:
    			// Type of event   $xx
    			// Time stamp      $xx (xx ...)
    			//   The 'Time stamp' is set to zero if directly at the beginning of the sound
    			//   or after the previous event. All events MUST be sorted in chronological order.
    
    			$frame_offset = 0;
    			$parsedFrame['timestampformat'] = ord(substr($parsedFrame['data'], $frame_offset++, 1));
    
    			while ($frame_offset < strlen($parsedFrame['data'])) {
    				$parsedFrame['typeid']    = substr($parsedFrame['data'], $frame_offset++, 1);
    				$parsedFrame['type']      = $this->ETCOEventLookup($parsedFrame['typeid']);
    				$parsedFrame['timestamp'] = getid3_lib::BigEndian2Int(substr($parsedFrame['data'], $frame_offset, 4));
    				$frame_offset += 4;
    			}
    			unset($parsedFrame['data']);


    This says that I'm to include $parsedFrame['data'] as one of the array items.  The standard does not list a data field.  Also, the standard says that the value of timestamp should be HEX.  So, do I put 0011 in for 3 milliseconds or do I put 3 as the vale of timestamp?

    The documentation for ETCO tags is pretty scarce...so, what I'm trying to ask is how do I write an 1d3v2.3 ETCO array for getID3?

    Here's version 50 of what I've tried, and it doesn't work.
     

    $TagData['id3v2']['ETCO']['frame_name'] = 'ETCO';
    $TagData['id3v2']['ETCO']['data'] = 3;  // from the standard at https://id3.org/id3v2.3.0#sec4.6
    $TagData['id3v2']['ETCO']['type'] = 3;  // type 3 is mainpart start
    $TagData['id3v2']['ETCO']['timestamp'] = 1000; // milliseconds 
    $TagData['id3v2']['ETCO']['timestampformat'] = 2; // timestamp format #2 which is Absolute time, 32 bit sized, using milliseconds as unit
    
    $TagData['id3v2']['ETCO']['data'] = 4;  // from the standard at https://id3.org/id3v2.3.0#sec4.6
    $TagData['id3v2']['ETCO']['type'] = 4;  // type 4 is outro start
    $TagData['id3v2']['ETCO']['timestamp'] = 1500;  // milliseconds 
    $TagData['id3v2']['ETCO']['timestampformat'] = 2; // timestamp format #2 which is Absolute time, 32 bit sized, using milliseconds as unit
    



    Thanks!

  10. I had a script to automatically login to a site, and download data from it.  The provider just updated their pages.  They now appear to be JSON.  The previous code was straight php and curl.  When trying to login now, I get this error page echoed:

    405 - HTTP verb used to access this page is not allowed.

    Any pointers as to where I can look to re-write the code based on this error?  I'm not looking for someone to write the code for me...just a pointer to where to look for how to login to this site.

    FYI, the site is:  https://www.premiereaffidavits.com/login

    Thanks!

  11. <?php
    
    $username = 'xxx';
    $password = 'xxx';
    $postdata = '?username='.$username.'&password='.$password;
    
    $url = 'https://www.premiereaffidavits.com/scripts/cgiip.exe/WService=webprime/login.html';
    
    $ch = curl_init(); 
    curl_setopt ($ch, CURLOPT_URL, $url); 
    curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
    curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); 
    curl_setopt ($ch, CURLOPT_TIMEOUT, 60); 
    curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); 
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt ($ch, CURLOPT_REFERER, $url); 
    curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata); 
    curl_setopt ($ch, CURLOPT_POST, 1); 
    $result = curl_exec ($ch); 
    
    echo $result;  
    
    curl_close($ch);
    ?>

    This only returns the login page...not the redirect page

  12. I'm trying to login to a site, navigate a couple of pages deep, and then scrape a table.  I had all this working, but the site changed their login workflow...and I can't figure out what I need to do to make this work.

    The form used in a browser to login has itself as the action page.  In a browser, you are automatically redirected to another page, that puts a random get variable at the end of the URL.

    Here's the main login page:  https://www.premiereaffidavits.com/scripts/cgiip.exe/WService=webprime/login.html

    When I run a standard curl login code...I only get the login page returned to me.  How can I get the redirected page (including the random GET variable at the end of the URL) that you get using a browser?  I see no javascript, or other ways for the action page to redirect to the second page you get in a browser.  What am I missing here?

    I can generate login info if you need it.

    Thanks.

  13. This is always echoing FIRST...even for today (12/30)...any ideas why?

     

    <?php
    $year = date('Y');
    $yearplus = ($year + 1);
    
    $first = date('m-d', strtotime("12-25"));
    $second = date('m-d', strtotime("01-01"));
    
    
    
    if (date('m-d') <= $first || date('m-d') >= $second)
    {
    $first_monday = date('Y-m-d', strtotime("January 2 $year last Monday")); echo "FIRST";
    }
    else
    {
    $first_monday = date('Y-m-d', strtotime("January 2 $yearplus last Monday"));  echo "SECOND";
    }
    
    echo $first_monday; exit;
    
    
    ?>

     

  14. The broadcast industry (radio and TV) has a special calendar.  The week starts on Monday.  Week #1 is ALWAYS the week with January 1st.

    So, if January 1st is on a Sunday, week #1 will include December 26th through January 1st.

    This differs from the ISO standard used by PHP.  I don't know where to start to write a function to give me the broadcast calendar week numbers for a given date.  Google didn't have much...and Stack Overflow had a couple examples...but none of them worked.  They all showed today being week #53, where today (December 30) is in week #1.

    Any help would be appreciated.

    Thanks...happy New Year!

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.