Example #1
0
function SynchronizeAllTags($filename, $synchronizefrom = 'all', $synchronizeto = 'A12', &$errors)
{
    global $getID3;
    set_time_limit(30);
    $ThisFileInfo = $getID3->analyze($filename);
    getid3_lib::CopyTagsToComments($ThisFileInfo);
    if ($synchronizefrom == 'all') {
        $SourceArray = !empty($ThisFileInfo['comments']) ? $ThisFileInfo['comments'] : array();
    } elseif (!empty($ThisFileInfo['tags'][$synchronizefrom])) {
        $SourceArray = !empty($ThisFileInfo['tags'][$synchronizefrom]) ? $ThisFileInfo['tags'][$synchronizefrom] : array();
    } else {
        die('ERROR: $ThisFileInfo[tags][' . $synchronizefrom . '] does not exist');
    }
    $SQLquery = 'DELETE FROM `' . mysql_real_escape_string(GETID3_DB_TABLE) . '`';
    $SQLquery .= ' WHERE (`filename` = "' . mysql_real_escape_string($filename) . '")';
    mysql_query_safe($SQLquery);
    $TagFormatsToWrite = array();
    if (strpos($synchronizeto, '2') !== false && $synchronizefrom != 'id3v2') {
        $TagFormatsToWrite[] = 'id3v2.3';
    }
    if (strpos($synchronizeto, 'A') !== false && $synchronizefrom != 'ape') {
        $TagFormatsToWrite[] = 'ape';
    }
    if (strpos($synchronizeto, 'L') !== false && $synchronizefrom != 'lyrics3') {
        $TagFormatsToWrite[] = 'lyrics3';
    }
    if (strpos($synchronizeto, '1') !== false && $synchronizefrom != 'id3v1') {
        $TagFormatsToWrite[] = 'id3v1';
    }
    getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'write.php', __FILE__, true);
    $tagwriter = new GetId3_Write_Tags();
    $tagwriter->filename = $filename;
    $tagwriter->tagformats = $TagFormatsToWrite;
    $tagwriter->overwrite_tags = true;
    $tagwriter->tag_encoding = $getID3->encoding;
    $tagwriter->tag_data = $SourceArray;
    if ($tagwriter->WriteTags()) {
        $errors = $tagwriter->errors;
        return true;
    }
    $errors = $tagwriter->errors;
    return false;
}
Example #2
0
$TaggingFormat = 'UTF-8';
header('Content-Type: text/html; charset=' . $TaggingFormat);
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
echo '<html><head><title>getID3() - Sample tag writer</title></head><style type="text/css">BODY,TD,TH { font-family: sans-serif; font-size: 9pt;" }</style><body>';
require_once '../getid3/getid3.php';
// Initialize getID3 engine
$getID3 = new getID3();
$getID3->setOption(array('encoding' => $TaggingFormat));
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'write.php', __FILE__, true);
$browsescriptfilename = 'demo.browse.php';
$Filename = isset($_REQUEST['Filename']) ? $_REQUEST['Filename'] : '';
if (isset($_POST['WriteTags'])) {
    $TagFormatsToWrite = isset($_POST['TagFormatsToWrite']) ? $_POST['TagFormatsToWrite'] : array();
    if (!empty($TagFormatsToWrite)) {
        echo 'starting to write tag(s)<BR>';
        $tagwriter = new GetId3_Write_Tags();
        $tagwriter->filename = $Filename;
        $tagwriter->tagformats = $TagFormatsToWrite;
        $tagwriter->overwrite_tags = false;
        $tagwriter->tag_encoding = $TaggingFormat;
        if (!empty($_POST['remove_other_tags'])) {
            $tagwriter->remove_other_tags = true;
        }
        $commonkeysarray = array('Title', 'Artist', 'Album', 'Year', 'Comment');
        foreach ($commonkeysarray as $key) {
            if (!empty($_POST[$key])) {
                $TagData[strtolower($key)][] = $_POST[$key];
            }
        }
        if (!empty($_POST['Genre'])) {
            $TagData['genre'][] = $_POST['Genre'];