www.webdeveloper.com
Results 1 to 4 of 4

Thread: Read contents of zip file and Get info stored in an ID3 tag

  1. #1
    Join Date
    Jun 2004
    Location
    London UK
    Posts
    541

    Read contents of zip file and Get info stored in an ID3 tag

    Hi again

    I have a zip file with an mp3 in it. what i would like to do is have a script that reads the ID3 tag info from the mp3 stored in the zip file.

    I found this info on reading zip file but it's all a bit confussing.

    PHP Code:
    <?php

    $zip 
    zip_open("/tmp/test2.zip");

    if (
    $zip) {

        while (
    $zip_entry zip_read($zip)) {
            echo 
    "Name:               " zip_entry_name($zip_entry) . "\n";
            echo 
    "Actual Filesize:    " zip_entry_filesize($zip_entry) . "\n";
            echo 
    "Compressed Size:    " zip_entry_compressedsize($zip_entry) . "\n";
            echo 
    "Compression Method: " zip_entry_compressionmethod($zip_entry) . "\n";

            if (
    zip_entry_open($zip$zip_entry"r")) {
                echo 
    "File Contents:\n";
                
    $buf zip_entry_read($zip_entryzip_entry_filesize($zip_entry));
                echo 
    "$buf\n";

                
    zip_entry_close($zip_entry);
            }
            echo 
    "\n";

        }

        
    zip_close($zip);

    }

    ?>
    and this on getting the ID3 tag info:

    PHP Code:
    <?php
    $tag 
    id3_get_tag"path/to/example2.mp3"ID3_V2_3 );
    print_r($tag);
    ?>
    Array
    (
    [title] => DN-38416
    [artist] => Re:\Legion
    [album] => Reflections
    [year] => 2004
    [genre] => 19
    )


    Any ideas on how to put this together?

    even a starting pointer whould be great.

    Cheers
    Chris

  2. #2
    Join Date
    Feb 2005
    Location
    BC, Canada
    Posts
    1,098
    I suspect you are going to need to extract the file from the ZIP into a temperary location, use the id3_get_tag to read from the temp location, save that value into the database, and then next time call from the database instead of doing everything else.

  3. #3
    Join Date
    Jun 2004
    Location
    London UK
    Posts
    541
    for a few reason I have to try this way.

    I've look at the zip reading code and it apears that it can read the contents of the zip file:
    PHP Code:
    (zip_entry_open($zip$zip_entry"r")) {
    echo 
    "File Contents:\n";
    $buf zip_entry_read($zip_entryzip_entry_filesize($zip_entry));
    echo 
    "$buf\n";

    zip_entry_close($zip_entry); 
    so am I correct in saying it's posible to read the ID3tags from that mp3 file?

    if it can be done i'de like to push on with it.

    Cheers
    Chris

  4. #4
    Join Date
    Mar 2011
    Posts
    1
    Hello ! What a beautifull idea ! Y client is a deejay and he upload alot of zip compressed mpt archives for users to downloads. But that give a lots of job to describe each time thé music content to the visitors or for my client to put mixes on his website. Those mp3 are heavy for uploading so it will be more pleasent if it's not nesseary to extract content for get the information on the Mp3 Id3 tag inside...

    I'll look foward too, if I try to develope this Idea...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles