Esempio n. 1
5
/**
 * Fonction de récupération des métadonnées sur les fichiers vidéo
 * appelée à l'insertion en base dans le plugin medias (inc/renseigner_document)
 *
 * @param string $file
 *    Le chemin du fichier à analyser
 * @return array $metas
 *    Le tableau comprenant les différentes metas à mettre en base
 */
function metadata_video($file)
{
    $meta = array();
    include_spip('lib/getid3/getid3');
    $getID3 = new getID3();
    $getID3->setOption(array('tempdir' => _DIR_TMP));
    // Scan file - should parse correctly if file is not corrupted
    $file_info = $getID3->analyze($file);
    /**
     * Les pistes vidéos
     */
    if (isset($file_info['video'])) {
        $id3['hasvideo'] = 'oui';
        if (isset($file_info['video']['resolution_x'])) {
            $meta['largeur'] = $file_info['video']['resolution_x'];
        }
        if (isset($file_info['video']['resolution_y'])) {
            $meta['hauteur'] = $file_info['video']['resolution_y'];
        }
        if (isset($file_info['video']['frame_rate'])) {
            $meta['framerate'] = $file_info['video']['frame_rate'];
        }
    }
    if (isset($file_info['playtime_seconds'])) {
        $meta['duree'] = round($file_info['playtime_seconds'], 0);
    }
    return $meta;
}
Esempio n. 2
2
function tag_mp3($filename, $songname, $albumname, $artist, $time)
{
    $TaggingFormat = 'UTF-8';
    // Initialize getID3 engine
    $getID3 = new getID3();
    $getID3->setOption(array('encoding' => $TaggingFormat));
    getid3_lib::IncludeDependency('/var/www/html/getid3/getid3/write.php', __FILE__, true);
    // Initialize getID3 tag-writing module
    $tagwriter = new getid3_writetags();
    $tagwriter->filename = $filename;
    $tagwriter->tagformats = array('id3v1', 'id3v2.3');
    // set various options (optional)
    $tagwriter->overwrite_tags = true;
    $tagwriter->tag_encoding = $TaggingFormat;
    $tagwriter->remove_other_tags = true;
    // populate data array
    $TagData['title'][] = $songname;
    $TagData['artist'][] = $artist;
    $TagData['album'][] = $albumname;
    $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);
    }
}
Esempio n. 3
2
 function write_tags($file, $data = array())
 {
     App::import('Vendor', 'getid3/getid3/getid3');
     //getid3/getid3/getid3/getid3/getid3 ;)
     $g3 = new getID3();
     $g3->setOption(array('encoding' => 'UTF-8'));
     App::import('Vendor', 'getid3/getid3/write');
     $id3 = new getid3_writetags();
     $id3->filename = $file;
     $id3->tagformats = array('id3v1', 'id3v2.3');
     $id3->overwrite_tags = true;
     $id3->tag_encoding = 'UTF-8';
     $id3->remove_other_tags = false;
     $tags = array();
     foreach ($data as $key => $val) {
         if (is_array($val)) {
             foreach ($val as $v) {
                 $tags[$key][] = $v;
             }
         } else {
             $tags[$key][] = $val;
         }
     }
     $old_tags = $g3->analyze($file);
     getid3_lib::CopyTagsToComments($old_tags);
     $id3->tag_data = am($old_tags['comments'], $tags);
     if ($id3->WriteTags()) {
         if (!empty($id3->warnings)) {
             debug($id3->warnings);
         }
         return true;
     } else {
         debug($id3->errors);
     }
 }
Esempio n. 4
1
 public static function tag($mp3, $image_name, $type)
 {
     $mp3_handler = new \getID3();
     $mp3_handler->setOption(['encoding' => 'UTF-8']);
     $mp3_writter = new \getid3_writetags();
     $mp3_writter->filename = Config::get('site.mp3_upload_path') . '/' . $mp3->mp3name;
     $mp3_writter->tagformats = array('id3v1', 'id3v2.3');
     $mp3_writter->overwrite_tags = true;
     $mp3_writter->tag_encoding = 'UTF-8';
     $mp3_writter->remove_other_tags = true;
     $mp3_data['title'][] = $mp3->name;
     $mp3_data['artist'][] = Config::get('site.name') . ' ' . Config::get('site.separator') . ' ' . Config::get('site.url');
     //$mp3_artist;
     $mp3_data['album'][] = Config::get('site.name') . ' ' . Config::get('site.separator') . ' ' . Config::get('site.url');
     // $mp3_data['year'][]    = $mp3_year;
     // $mp3_data['genre'][]   = $mp3_genre;
     $mp3_data['comment'][] = Config::get('site.name') . ' ' . Config::get('site.separator') . Config::get('site.url');
     if ($mp3->price == 'paid') {
         $mp3_data['attached_picture'][0]['data'] = file_get_contents(Config::get('site.image_upload_path') . '/thumbs/' . $image_name);
         $mp3_data['attached_picture'][0]['picturetypeid'] = $type;
         $mp3_data['attached_picture'][0]['mime'] = $type;
     } else {
         $mp3_data['attached_picture'][0]['data'] = file_get_contents(Config::get('site.logo'));
         $mp3_data['attached_picture'][0]['picturetypeid'] = "image/jpg";
         $mp3_data['attached_picture'][0]['mime'] = "image/jpg";
     }
     $mp3_data['attached_picture'][0]['description'] = Config::get('site.name') . ' ' . Config::get('site.separator') . ' ' . Config::get('site.description');
     $mp3_writter->tag_data = $mp3_data;
     return $mp3_writter->WriteTags();
 }
Esempio n. 5
1
 public static function writeSongData(ArchiveSong $song)
 {
     $getID3 = new \getID3();
     $getID3->setOption(array('encoding' => 'UTF8'));
     $tagwriter = new \getid3_writetags();
     $tagwriter->filename = $song->file_path;
     $tagwriter->tagformats = array('id3v1', 'id3v2.3');
     $tagwriter->overwrite_tags = true;
     $tagwriter->tag_encoding = 'UTF8';
     $tagwriter->remove_other_tags = true;
     $tag_data = array('title' => array($song->title), 'artist' => array($song->artist), 'album' => array($song->album), 'year' => array($song->year), 'genre' => array($song->genre), 'track' => array($song->track_number));
     $art_path = $song->art_path;
     if ($art_path) {
         if ($fd = fopen($art_path, 'rb')) {
             $APICdata = fread($fd, filesize($art_path));
             fclose($fd);
             list($APIC_width, $APIC_height, $APIC_imageTypeID) = getimagesize($art_path);
             $imagetypes = array(1 => 'gif', 2 => 'jpeg', 3 => 'png');
             if (isset($imagetypes[$APIC_imageTypeID])) {
                 $tag_data['attached_picture'][0]['data'] = $APICdata;
                 $tag_data['attached_picture'][0]['picturetypeid'] = $APIC_imageTypeID;
                 $tag_data['attached_picture'][0]['description'] = basename($art_path);
                 $tag_data['attached_picture'][0]['mime'] = 'image/' . $imagetypes[$APIC_imageTypeID];
                 $tag_data['comments']['picture'][0] = $tag_data['attached_picture'][0];
             }
         }
     }
     $tagwriter->tag_data = $tag_data;
     // write tags
     if ($tagwriter->WriteTags()) {
         return true;
     } else {
         throw new \Exception(implode('<br><br>', $tagwriter->errors));
         return false;
     }
 }
Esempio n. 6
1
 /**
  * @param $path
  * @param $tags
  *
  * @return bool
  */
 public function write_ID3($path, $tags)
 {
     if (is_file(DOCPATH . $path)) {
         require_once APPPATH . 'libraries/getid3/getid3.php';
         $getID3 = new getID3();
         $getID3->setOption(array('encoding' => 'UTF-8'));
         getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'write.php', __FILE__, TRUE);
         $tagwriter = new getid3_writetags();
         $tagwriter->filename = $path;
         $tagwriter->tag_encoding = 'UTF-8';
         $tagwriter->tagformats = array('id3v1', 'id3v2.3');
         $tagwriter->overwrite_tags = TRUE;
         $tagwriter->tag_data = $tags;
         $tagwriter->WriteTags();
         if (!empty($tagwriter->warnings)) {
             return FALSE;
         }
         return TRUE;
     }
     return FALSE;
 }
function update_id3_tags($newfile, $filename, $dir_path, $line, $start, $stop)
{
    $TextEncoding = 'UTF-8';
    require_once 'getid3/getid3.php';
    // Initialize getID3 engine
    $getID3 = new getID3();
    $getID3->setOption(array('encoding' => $TextEncoding));
    require_once 'getid3/write.php';
    // Initialize getID3 tag-writing module
    $tagwriter = new getid3_writetags();
    //$tagwriter->filename = '/path/to/file.mp3';
    $tagwriter->filename = $newfile;
    //$tagwriter->tagformats = array('id3v1', 'id3v2.3');
    $tagwriter->tagformats = array('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;
    $tagwriter->remove_other_tags = true;
    // populate data array
    $TagData = array('title' => array($line[0] . ' -D-E- ' . $line[7] . '(' . $line[8] . ')'), 'artist' => array('Japanese Core6k shadowing'), 'album' => array('Japanese Core6k shadowing ' . $start . ' to ' . $stop), 'year' => array('2016'), 'genre' => array('Educational'), 'comment' => array($line[7] . '(' . $line[8] . ')'));
    $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);
    }
}
Esempio n. 8
0
<?php

die("This script can be used to update ID3 tags. You must remove this die() statement to run.");
$base = "/var/www/nas/www.example.com/htdocs/streams";
require_once "{$base}/lib/Config.php";
require_once "{$base}/lib/Auth.php";
require_once "{$base}/lib/Streams.php";
require_once "{$base}/lib/getid3/getid3/getid3.php";
foreach (glob("{$base}/lib/getid3/getid3/*.php") as $resource) {
    require_once $resource;
}
$getID3 = new getID3();
$getID3->setOption(array("encoding" => "UTF-8"));
if (isset($_SERVER['argv'][1])) {
    $files[] = $_SERVER['argv'][1];
} else {
    $files = glob("*.mp3");
}
$c = count($files);
foreach ($files as $k => $f) {
    print "[{$k} of {$c}] Processing {$f}\n";
    $id3 = $getID3->analyze($f);
    // Set new ID3 tags
    unset($tagData);
    $tagData['title'] = array($id3['tags']['id3v2']['title'][0]);
    $tagData['artist'] = array($id3['tags']['id3v2']['artist'][0]);
    $tagData['album'] = array($id3['tags']['id3v2']['album'][0]);
    $tagData['genre'] = array($id3['tags']['id3v2']['genre'][0]);
    $tagData['track'] = array($id3['tags']['id3v2']['track_number'][0]);
    $tagData['year'] = array($id3['tags']['id3v2']['year'][0]);
    $tagData['comment'] = array("Ev1l Pr1sm");
Esempio n. 9
0
 /**
  * Method for to write ID3Tags into file
  *
  * @param array $data ID3 tag items
  * @param string Kind of text encoding, for example UTF-8
  * @return boolean
  */
 public function writeID3Tags($data, $TextEncoding = 'UTF-8')
 {
     $dispatcher = JDispatcher::getInstance();
     require_once JPATH_COMPONENT_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'id3' . DIRECTORY_SEPARATOR . 'getid3.php';
     require_once JPATH_COMPONENT_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'id3' . DIRECTORY_SEPARATOR . 'write.php';
     // Initialize getID3 engine
     $getID3 = new getID3();
     $getID3->setOption(array('encoding' => $TextEncoding));
     $tagwriter = new getid3_writetags();
     $tagwriter->tagformats = array('id3v2.3');
     // Set various options
     $tagwriter->overwrite_tags = true;
     $tagwriter->tag_encoding = $TextEncoding;
     $tagwriter->remove_other_tags = true;
     $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => 'Writing tags for: ' . $data['pathatlocal'] . '/' . $data['file'], 'priority' => JLog::INFO, 'section' => 'admin')));
     // Data for ID3 Tag
     $tagwriter->filename = $data['pathatlocal'] . '/' . $data['file'];
     // Get name for Genre ID
     if ($data['catid']) {
         $genre_name = self::getGenrename($data['catid'])->title;
     } else {
         $genre_name = null;
     }
     $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => 'Name for Genre id: ' . $data['catid'] . ' is ' . $genre_name, 'priority' => JLog::INFO, 'section' => 'admin')));
     // Create data array for ID3 tag
     $TagData = array('title' => array($data['title']), 'artist' => array($data['artist']), 'album' => array($data['album']), 'year' => array($data['year']), 'genre' => array($genre_name), 'comment' => array('Edited by PlayJoom streaming server'), 'track' => array($data['tracknumber']));
     $tagwriter->tag_data = $TagData;
     // write ID3 tag
     if ($tagwriter->WriteTags()) {
         $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => 'Writting of ID3 Tag successfully.', 'priority' => JLog::INFO, 'section' => 'admin')));
         if (!empty($tagwriter->warnings)) {
             $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => 'Attention! ' . implode('<br>', $tagwriter->warnings), 'priority' => JLog::WARNING, 'section' => 'admin')));
             return false;
         }
     } else {
         $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => 'Failed to write tags! ' . implode('<br>', $tagwriter->errors), 'priority' => JLog::WARNING, 'section' => 'admin')));
         return true;
     }
 }
Esempio n. 10
0
     $add->videoid = $data->itemoldid;
 }
 if ($slides) {
     foreach ($unicalsjpg as $k => $v) {
         $name = 'image' . ($k + 1);
         $nameimg = 'img' . ($k + 1);
         if ($mediaboard->presetimages == 1) {
             $add->{$name} = $mediaboard->{$nameimg};
         } else {
             if ($file = mediaboard_getfile($v)) {
                 $add->{$name} = $file->id;
             }
         }
     }
     $getID3 = new getID3();
     $getID3->setOption(array('encoding' => 'UTF-8'));
     foreach ($unicalsmp3 as $k => $v) {
         $name = 'audio' . ($k + 1);
         $nameduration = 'duration' . ($k + 1);
         if ($file = mediaboard_getfile($v)) {
             $add->{$name} = $file->id;
             if ($usevoice[$v]) {
                 $ThisFileInfo = $getID3->analyze($file->fullpatch);
                 $add->{$nameduration} = @round((double) $ThisFileInfo['playtime_seconds'] * 1000);
             } else {
                 $add->{$nameduration} = 4000;
             }
         }
     }
 }
 $add->time = time();
Esempio n. 11
0
    public function home()
    {
        global $core;
        error_reporting(0);
        $v = $this->__(w('v'));
        if (!$v['v']) {
            $sql = 'SELECT media_id
				FROM _bio_media
				WHERE media_type = ?
					AND media_mp3 = ?
				LIMIT 1';
            $v['v'] = _field(sql_filter($sql, 1, 0), 'media_id', 0);
        }
        $tag_format = 'UTF-8';
        $relative_path = '/data/artists/%s/media/';
        $absolute_path = '/var/www/vhosts/rockrepublik.net/www' . $relative_path;
        $sql = 'SELECT m.*, b.bio_id, b.bio_name
			FROM _bio_media m
			LEFT JOIN _bio b ON m.media_bio = b.bio_id
			WHERE m.media_id = ?';
        //$spaths = '/data/artists/' . $songd['ub'] . '/media/';
        //$spath = '/var/www/vhosts/rockrepublik.net/httpdocs' . $spaths;
        if ($media = _fieldrow(sql_filter($sql, $v['v']))) {
            $row_relative = sprintf($relative_path, $media['bio_id']);
            $row_absolute = $absolute_path . $row_relative;
            $row_wma = $row_absolute . $media['media_id'] . '.wma';
            $row_mp3 = $row_absolute . $media['media_id'] . '.mp3';
            $rel_wma = '.' . $row_relative . $media['media_id'] . '.wma';
            $rel_mp3 = '.' . $row_relative . $media['media_id'] . '.mp3';
            if (@file_exists($rel_wma) && !@file_exists($rel_mp3) && !$media['media_mp3']) {
                exec('ffmpeg -i ' . $row_wma . ' -vn -ar 44100 -ac 2 -ab 64kb -f mp3 ' . $row_mp3);
                include_once XFS . XCOR . 'getid3/getid3.php';
                $getID3 = new getID3();
                $getID3->setOption(array('encoding' => $tag_format));
                getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'write.php', __FILE__, true);
                $tagwriter = new getid3_writetags();
                $tagwriter->filename = getid3_lib::SafeStripSlashes($row_mp3);
                $tagwriter->tagformats = array('id3v1');
                $tagwriter->overwrite_tags = true;
                $tagwriter->tag_encoding = $tag_format;
                $tagwriter->remove_other_tags = true;
                $tag_comment = 'Visita www.rockrepublik.net';
                $media['album'] = !empty($media['media_album']) ? $media['media_album'] : 'Single';
                $media['genre'] = !empty($media['media_genre']) ? $media['media_genre'] : 'Rock';
                $media_f = array('title', 'name', 'album', 'genre');
                foreach ($media_f as $mr) {
                    $media['media_' . $mr] = getid3_lib::SafeStripSlashes(utf8_encode(html_entity_decode($media['media_' . $mr])));
                }
                $tagwriter->tag_data = array('title' => array($media['media_title']), 'artist' => array($media['media_name']), 'album' => array($media['media_album']), 'year' => array(getid3_lib::SafeStripSlashes($media['media_year'])), 'genre' => array($media['media_genre']), 'comment' => array(getid3_lib::SafeStripSlashes($tag_comment)), 'tracknumber' => array(''));
                $tagwriter->WriteTags();
                $sql = 'UPDATE _bio_media SET media_mp3 = ?
					WHERE media_id = ?';
                _sql(sql_filter($sql, 1, $media['media_id']));
                $fp = @fopen('./conv.txt', 'a+');
                fwrite($fp, $row_mp3 . "\n");
                fclose($fp);
            }
            if (!@file_exists($rel_wma)) {
                $sql = 'UPDATE _bio_media SET media_mp3 = ?
					WHERE media_id = ?';
                _sql(sql_filter($sql, 2, $media['media_id']));
            }
        }
        $sql = 'SELECT media_id
			FROM _bio_media
			WHERE media_type = ?
				AND media_mp3 = ?
			LIMIT 1';
        if ($v_next = _field(sql_filter($sql, 1, 0), 'media_id', 0)) {
            sleep(1);
            _redirect(_link($this->m(), array('v' => $v_next)));
        } else {
            $this->e('no_next');
        }
        return $this->e('.');
    }
 public function getID3()
 {
     $getID3 = new getID3();
     $pageEncoding = 'UTF-8';
     $getID3->setOption(array("encoding" => $pageEncoding));
     return $getID3;
 }
Esempio n. 13
0
 private function manageFileUpload($object)
 {
     $directory = $object->getDirectory();
     $directory = preg_replace("/\\/\$/", '', $directory);
     if (!is_dir('/var/lib/mpd/music' . $directory)) {
         mkdir('/var/lib/mpd/music' . $directory, 0755);
     }
     if ($object->getUrl()) {
         $filename = $object->getUrl();
         $filename = explode("/", $filename);
         if (file_exists('/var/lib/mpd/' . $object->getUrl())) {
             rename('/var/lib/mpd/' . $object->getUrl(), '/var/lib/mpd/music' . $directory . '/' . end($filename));
             $object->setUrl('music' . $directory . '/' . end($filename));
         }
     }
     if ($object->getFile()) {
         $object->file->move('/var/lib/mpd/music' . $directory, $object->file->getClientOriginalName());
         $object->setUrl('music' . $directory . '/' . $object->file->getClientOriginalName());
     }
     /*
             if (null === $this->getFile()) {
                 return;
             }elseif(isset($this->temp) && null === $this->getFile()){
     			$this->getFile()->move('/var/lib/mpd/'.$this->temp, '/var/lib/mpd/'.$this->path);
     		}
     
             // check if we have an old image
             if (isset($this->temp)) {
                 // delete the old image
                 unlink('/var/lib/mpd/'.$this->temp);
                 // clear the temp image path
                 $this->temp = null;
             }
             $this->file = null;
     */
     if ($object->getUrl()) {
         if ($object->getTitle() || $object->getArtist() || $object->getAlbum() || $object->getGenre()) {
             $TextEncoding = 'UTF-8';
             require_once $_SERVER['DOCUMENT_ROOT'] . '/libs/getid3/getid3.php';
             // Initialize getID3 engine
             $getID3 = new \getID3();
             $getID3->setOption(array('encoding' => $TextEncoding));
             require_once $_SERVER['DOCUMENT_ROOT'] . '/libs/getid3/write.php';
             // Initialize getID3 tag-writing module
             $tagwriter = new \getid3_writetags();
             //$tagwriter->filename = '/path/to/file.mp3';
             $tagwriter->filename = '/var/lib/mpd/' . $object->getUrl();
             //$tagwriter->tagformats = array('id3v1', 'id3v2.3');
             $tagwriter->tagformats = array('id3v2.3');
             // set various options (optional)
             //$tagwriter->overwrite_tags = true;
             //$tagwriter->overwrite_tags = false;
             $tagwriter->tag_encoding = $TextEncoding;
             $tagwriter->remove_other_tags = true;
             // populate data array
             $TagData = array('title' => array($object->getTitle()), 'artist' => array($object->getArtist()), 'album' => array($object->getAlbum()), 'genre' => array($object->getGenre()));
             $tagwriter->tag_data = $TagData;
             // write tags
             if (!$tagwriter->WriteTags()) {
                 die('Failed to write tags!<br>' . implode('<br><br>', $tagwriter->errors));
             }
         } else {
             $TextEncoding = 'UTF-8';
             require_once $_SERVER['DOCUMENT_ROOT'] . '/libs/getid3/getid3.php';
             // Initialize getID3 engine
             $getID3 = new \getID3();
             $ThisFileInfo = $getID3->analyze('/var/lib/mpd/' . $object->getUrl());
             if (isset($ThisFileInfo['tags']['id3v2']['title'][0])) {
                 $object->setTitle($ThisFileInfo['tags']['id3v2']['title'][0]);
             }
             if (isset($ThisFileInfo['tags']['id3v2']['artist'][0])) {
                 $object->setArtist($ThisFileInfo['tags']['id3v2']['artist'][0]);
             }
             if (isset($ThisFileInfo['tags']['id3v2']['album'][0])) {
                 $object->setAlbum($ThisFileInfo['tags']['id3v2']['album'][0]);
             }
             if (isset($ThisFileInfo['tags']['id3v2']['genre'][0])) {
                 $object->setGenre($ThisFileInfo['tags']['id3v2']['genre'][0]);
             }
         }
     }
 }
Esempio n. 14
0
    ob_end_clean();
    die('Could not connect to MySQL host: <blockquote style="background-color: #FF9933; padding: 10px;">' . mysql_error() . '</blockquote>');
}
if (!mysql_select_db(GETID3_DB_DB)) {
    $errormessage = ob_get_contents();
    ob_end_clean();
    die('Could not select database: <blockquote style="background-color: #FF9933; padding: 10px;">' . mysql_error() . '</blockquote>');
}
ob_end_clean();
$getid3PHP_filename = realpath('../getid3/getid3.php');
if (!file_exists($getid3PHP_filename) || !(include_once $getid3PHP_filename)) {
    die('Cannot open ' . $getid3PHP_filename);
}
// Initialize getID3 engine
$getID3 = new getID3();
$getID3->setOption(array('option_md5_data' => $getid3_demo_mysql_md5_data, 'encoding' => $getid3_demo_mysql_encoding));
function RemoveAccents($string)
{
    // Revised version by markstewardØhotmail*com
    return strtr(strtr($string, 'ŠŽšžŸÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖØÙÚÛÜÝàáâãäåçèéêëìíîïñòóôõöøùúûüýÿ', 'SZszYAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy'), array('Þ' => 'TH', 'þ' => 'th', 'Ð' => 'DH', 'ð' => 'dh', 'ß' => 'ss', 'Œ' => 'OE', 'œ' => 'oe', 'Æ' => 'AE', 'æ' => 'ae', 'µ' => 'u'));
}
function BitrateColor($bitrate, $BitrateMaxScale = 768)
{
    // $BitrateMaxScale is bitrate of maximum-quality color (bright green)
    // below this is gradient, above is solid green
    $bitrate *= 256 / $BitrateMaxScale;
    // scale from 1-[768]kbps to 1-256
    $bitrate = round(min(max($bitrate, 1), 256));
    $bitrate--;
    // scale from 1-256kbps to 0-255kbps
    $Rcomponent = max(255 - $bitrate * 2, 0);
Esempio n. 15
0
/////////////////////////////////////////////////////////////////
if (!function_exists('getmicrotime')) {
    function getmicrotime()
    {
        list($usec, $sec) = explode(' ', microtime());
        return (double) $usec + (double) $sec;
    }
}
///////////////////////////////////////////////////////////////////////////////
$writescriptfilename = 'demo.write.php';
require_once '../getid3/getid3.php';
// Needed for windows only
define('GETID3_HELPERAPPSDIR', 'C:/helperapps/');
// Initialize getID3 engine
$getID3 = new getID3();
$getID3->setOption(array('encoding' => 'UTF-8'));
$getID3checkColor_Head = 'CCCCDD';
$getID3checkColor_DirectoryLight = 'FFCCCC';
$getID3checkColor_DirectoryDark = 'EEBBBB';
$getID3checkColor_FileLight = 'EEEEEE';
$getID3checkColor_FileDark = 'DDDDDD';
$getID3checkColor_UnknownLight = 'CCCCFF';
$getID3checkColor_UnknownDark = 'BBBBDD';
///////////////////////////////////////////////////////////////////////////////
header('Content-Type: text/html; charset=UTF-8');
ob_start();
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
echo '<html><head>';
echo '<title>getID3() - /demo/demo.browse.php (sample script)</title>';
echo '<link rel="stylesheet" href="getid3.css" type="text/css">';
echo '</head><body>';
Esempio n. 16
0
function cacheUpdateTag($track_id, $profile, $file)
{
    global $cfg, $db;
    $query = mysql_query('SELECT image, bitmap.flag
		FROM bitmap, track
		WHERE bitmap.album_id = track.album_id
		AND track_id = "' . mysql_real_escape_string($track_id) . '"');
    $bitmap = mysql_fetch_assoc($query);
    $query = mysql_query('SELECT
		LOWER(SUBSTRING_INDEX(relative_file, ".", -1)) AS extension,
		track.artist, title, album, year, disc, discs, number, audio_lossless
		FROM track, album
		WHERE track_id = "' . mysql_real_escape_string($track_id) . '" 
		AND track.album_id = album.album_id');
    $track = mysql_fetch_assoc($query);
    $query = mysql_query('SELECT tag_hash
		FROM cache
		WHERE id		= "' . mysql_real_escape_string($track_id) . '"
		AND profile		= ' . (int) $profile);
    $cache = mysql_fetch_assoc($query);
    // populate data array
    $tagData['title'][0] = iconv(NJB_DEFAULT_CHARSET, $cfg['tag_encoding'][$profile], $track['title']);
    $tagData['artist'][0] = iconv(NJB_DEFAULT_CHARSET, $cfg['tag_encoding'][$profile], $track['artist']);
    $tagData['album'][0] = iconv(NJB_DEFAULT_CHARSET, $cfg['tag_encoding'][$profile], $track['album']);
    $tagData['year'][0] = $track['year'];
    $tagData['comment'][0] = $track['audio_lossless'] ? 'Lossless audio source' : 'Transcoded from ' . $track['extension'] . ' source';
    if ($cfg['tag_format'][$profile] == 'id3v2.3' && $track['number']) {
        $tagData['tracknumber'][0] = $track['number'];
    }
    if ($cfg['tag_format'][$profile] == 'id3v2.3' && $track['discs'] > 1) {
        $tagData['part_of_a_set'][0] = $track['disc'] . '/' . $track['discs'];
    }
    if ($cfg['tag_format'][$profile] == 'id3v2.3' && $bitmap['flag'] == 3) {
        $tagData['attached_picture'][0]['data'] = $bitmap['image'];
        $tagData['attached_picture'][0]['picturetypeid'] = 0x3;
        // 0x03 => 'Cover (front)'
        $tagData['attached_picture'][0]['description'] = '';
        $tagData['attached_picture'][0]['mime'] = 'image/jpeg';
    }
    unset($bitmap, $track);
    $hash = $cfg['tag_format'][$profile];
    $hash .= $cfg['tag_encoding'][$profile];
    $hash .= $cfg['tag_padding'][$profile];
    $hash .= print_r($tagData, true);
    $hash = md5($hash);
    if ($hash != $cache['tag_hash']) {
        require_once NJB_HOME_DIR . 'getid3/getid3/getid3.php';
        require_once NJB_HOME_DIR . 'getid3/getid3/write.php';
        // Initialize getID3 engine
        $getID3 = new getID3();
        $getID3->setOption(array('encoding' => $cfg['tag_encoding'][$profile]));
        // Initialize getID3 tag-writing module
        $tagwriter = new getid3_writetags();
        $tagwriter->filename = $file;
        $tagwriter->tagformats = array($cfg['tag_format'][$profile]);
        // array('id3v2.3');
        // set various options (optional)
        $tagwriter->tag_encoding = $cfg['tag_encoding'][$profile];
        $tagwriter->overwrite_tags = true;
        $tagwriter->remove_other_tags = true;
        $tagwriter->id3v2_paddedlength = $cfg['tag_padding'][$profile];
        $tagwriter->tag_data = $tagData;
        if ($tagwriter->WriteTags() == false) {
            message(__FILE__, __LINE__, 'error', '[b]Failed to write tags[/b][br]Error: ' . implode('[br]', $tagwriter->errors) . '[br]File: ' . $file);
        }
        cacheUpdateFile($track_id, $profile, $file, $hash);
    }
}
Esempio n. 17
0
/////////////////////////////////////////////////////////////////
if (!function_exists('getmicrotime')) {
    function getmicrotime()
    {
        list($usec, $sec) = explode(' ', microtime());
        return (double) $usec + (double) $sec;
    }
}
///////////////////////////////////////////////////////////////////////////////
$writescriptfilename = 'demo.write.php';
require_once '../getid3/getid3.php';
// Needed for windows only
define('GETID3_HELPERAPPSDIR', 'C:/helperapps/');
// Initialize getID3 engine
$getID3 = new getID3();
$getID3->setOption(array('encoding' => 'UTF-8'));
$getID3checkColor_Head = 'CCCCDD';
$getID3checkColor_DirectoryLight = 'FFCCCC';
$getID3checkColor_DirectoryDark = 'EEBBBB';
$getID3checkColor_FileLight = 'EEEEEE';
$getID3checkColor_FileDark = 'DDDDDD';
$getID3checkColor_UnknownLight = 'CCCCFF';
$getID3checkColor_UnknownDark = 'BBBBDD';
///////////////////////////////////////////////////////////////////////////////
header('Content-Type: text/html; charset=UTF-8');
ob_start();
echo '<html><head>';
echo '<title>getID3() - /demo/demo.browse.php (sample script)</title>';
echo '<style>BODY,TD,TH { font-family: sans-serif; font-size: 9pt; }</style>';
echo '</head><body>';
if (isset($_REQUEST['deletefile'])) {
//  available at http://getid3.sourceforge.net                 //
//            or http://www.getid3.org                         //
//          also https://github.com/JamesHeinrich/getID3       //
/////////////////////////////////////////////////////////////////
//                                                             //
// /demo/demo.simple.write.php - part of getID3()              //
// Sample script showing basic syntax for writing tags         //
// See readme.txt for more details                             //
//                                                            ///
/////////////////////////////////////////////////////////////////
die('Due to a security issue, this demo has been disabled. It can be enabled by removing line ' . __LINE__ . ' in ' . $_SERVER['PHP_SELF']);
$TextEncoding = 'UTF-8';
require_once '../getid3/getid3.php';
// Initialize getID3 engine
$getID3 = new getID3();
$getID3->setOption(array('encoding' => $TextEncoding));
require_once '../getid3/write.php';
// Initialize getID3 tag-writing module
$tagwriter = new getid3_writetags();
//$tagwriter->filename = '/path/to/file.mp3';
$tagwriter->filename = 'c:/file.mp3';
//$tagwriter->tagformats = array('id3v1', 'id3v2.3');
$tagwriter->tagformats = array('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 = false;
// 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;
$tagwriter->remove_other_tags = true;
// populate data array
Esempio n. 19
0
	function home()
	{
		global $db, $nucleo;
		
		error_reporting(0);
		$v = $this->control->__(array('v' => array('default' => 0)));
		if (!$v['v'])
		{
			$sql = 'SELECT id
				FROM _dl
				WHERE ud = 1
					AND dl_mp3 = 0
				ORDER BY id
				LIMIT 1';
			$v['v'] = $this->_field($sql, 'id');
		}
		
		$sql = 'SELECT d.*, a.name
			FROM _dl d, _artists a
			WHERE d.id = ' . (int) $v['v'] . '
				AND d.ub = a.ub';
		if ($songd = $this->_fieldrow($sql))
		{
			$spaths = '/data/artists/' . $songd['ub'] . '/media/';
			$spath = '/var/www/vhosts/rockrepublik.net/httpdocs' . $spaths;
			$songid = $songd['id'];
			$fwma = $spath . $songid . '.wma';
			$fmp3 = $spath . $songid . '.mp3';
			
			if (@file_exists('.' . $spaths . $songid . '.wma') && !@file_exists('.' . $spaths . $songid . '.mp3') && !$songd['dl_mp3'])
			{
				exec('ffmpeg -i ' . $fwma . ' -vn -ar 44100 -ac 2 -ab 64kb -f mp3 ' . $fmp3);
				
				// MP3 tags
				$tag_format = 'UTF-8';
				
				include_once(SROOT . 'core/getid3/getid3.php');
				$getID3 = new getID3;
				$getID3->setOption(array('encoding' => $tag_format));
				getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'write.php', __FILE__, true);
				
				$tagwriter = new getid3_writetags;
				$tagwriter->filename = getid3_lib::SafeStripSlashes($fmp3);
				$tagwriter->tagformats = array('id3v1');
				$tagwriter->overwrite_tags = true;
				$tagwriter->tag_encoding = $tag_format;
				$tagwriter->remove_other_tags = true;
				$tag_comment = 'Visita www.rockrepublik.net';
				
				$songd['album'] = (!empty($songd['album'])) ? $songd['album'] : 'Single';
				$songd['genre'] = (!empty($songd['genre'])) ? $songd['genre'] : 'Rock';
				
				$songd_f = array('title', 'name', 'album', 'genre');
				foreach ($songd_f as $songd_r)
				{
					$songd[$songd_r] = getid3_lib::SafeStripSlashes(utf8_encode(html_entity_decode($songd[$songd_r])));
				}
				
				$tagwriter->tag_data = array(
					'title' => array($songd['title']),
					'artist' => array($songd['name']),
					'album' => array($songd['album']),
					'year' => array(getid3_lib::SafeStripSlashes($songd['year'])),
					'genre' => array($songd['genre']),
					'comment' => array(getid3_lib::SafeStripSlashes($tag_comment)),
					'tracknumber' => array('')
				);
				$tagwriter->WriteTags();
				
				$sql = 'UPDATE _dl SET dl_mp3 = 1
					WHERE id = ' . (int) $songd['id'];
				$db->sql_query($sql);
				
				$fp = @fopen('./conv.txt', 'a+');
				fwrite($fp, $fmp3 . "\n");
				fclose($fp);
			}
			
			if (!@file_exists('.' . $spaths . $songid . '.wma'))
			{
				$sql = 'UPDATE _dl SET dl_mp3 = 2
					WHERE id = ' . (int) $songd['id'];
				$db->sql_query($sql);
			}
		}
		
		$sql = 'SELECT id
			FROM _dl
			WHERE ud = 1
				AND dl_mp3 = 0
			ORDER BY id
			LIMIT 1';
		if ($v_next = $this->_field($sql, 'id', 0))
		{
			sleep(1);
			$nucleo->redirect($nucleo->link('conv', array('v' => $v_next)));
		}
		else
		{
			die('no_next');
		}
		
		$this->e('.');
		
		return;
	}
Esempio n. 20
0
 /**
  * Read ID3 tags from a file.
  *
  * @return array Result of reading
  */
 public function readId3()
 {
     if ($this->file != null) {
         require_once $_SERVER['DOCUMENT_ROOT'] . '/server/lib/vendor/getid3/getid3/getid3.php';
         // Initialize getID3 engine
         $getID3 = new getID3();
         $getID3->setOption(array('encoding' => 'UTF-8'));
         $trackInfo = $getID3->analyze($this->file);
         getid3_lib::CopyTagsToComments($trackInfo);
         //return informations array
         return $trackInfo;
     }
     //return false to indicate ID3 was not read
     return false;
 }
Esempio n. 21
0
if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) {
    die('magic_quotes_gpc is enabled, getID3 will not run.');
}
if (!defined('ENT_SUBSTITUTE')) {
    // defined in PHP v5.4.0
    define('ENT_SUBSTITUTE', ENT_QUOTES);
}
/////////////////////////////////////////////////////////////////
$PageEncoding = 'UTF-8';
$writescriptfilename = 'demo.write.php';
require_once '../getid3/getid3.php';
// Needed for windows only. Leave commented-out to auto-detect, only define here if auto-detection does not work properly
//define('GETID3_HELPERAPPSDIR', 'C:\\helperapps\\');
// Initialize getID3 engine
$getID3 = new getID3();
$getID3->setOption(array('encoding' => $PageEncoding));
$getID3checkColor_Head = 'CCCCDD';
$getID3checkColor_DirectoryLight = 'FFCCCC';
$getID3checkColor_DirectoryDark = 'EEBBBB';
$getID3checkColor_FileLight = 'EEEEEE';
$getID3checkColor_FileDark = 'DDDDDD';
$getID3checkColor_UnknownLight = 'CCCCFF';
$getID3checkColor_UnknownDark = 'BBBBDD';
///////////////////////////////////////////////////////////////////////////////
header('Content-Type: text/html; charset=' . $PageEncoding);
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
echo '<html><head>';
echo '<title>getID3() - /demo/demo.browse.php (sample script)</title>';
echo '<link rel="stylesheet" href="getid3.css" type="text/css">';
echo '<meta http-equiv="Content-Type" content="text/html;charset=' . $PageEncoding . '" />';
echo '</head><body>';
Esempio n. 22
0
/// getID3() by James Heinrich <*****@*****.**>               //
//  available at http://getid3.sourceforge.net                 //
//            or http://www.getid3.org                         //
/////////////////////////////////////////////////////////////////
//                                                             //
// /demo/demo.simple.write.php - part of getID3()              //
// Sample script showing basic syntax for writing tags         //
// See readme.txt for more details                             //
//                                                            ///
/////////////////////////////////////////////////////////////////
die('Due to a security issue, this demo has been disabled. It can be enabled by removing line ' . __LINE__ . ' in ' . $_SERVER['PHP_SELF']);
$TaggingFormat = 'UTF-8';
require_once '../getid3/getid3.php';
// Initialize getID3 engine
$getID3 = new getID3();
$getID3->setOption(array('encoding' => $TaggingFormat));
require_once '../getid3/write.php';
// Initialize getID3 tag-writing module
$tagwriter = new GetId3\Write\Tags();
//$tagwriter->filename = '/path/to/file.mp3';
$tagwriter->filename = 'd:/file.mp3';
$tagwriter->filename = 'P:/webroot/_dev/getID3/testfiles/_writing/2011-02-02/test.mp3';
//$tagwriter->tagformats = array('id3v1', 'id3v2.3');
$tagwriter->tagformats = array('id3v2.3');
// set various options (optional)
$tagwriter->overwrite_tags = true;
$tagwriter->overwrite_tags = false;
$tagwriter->tag_encoding = $TaggingFormat;
$tagwriter->remove_other_tags = true;
// populate data array
$TagData = array('title' => array('My Song'), 'artist' => array('The Artist'), 'album' => array('Greatest Hits'), 'year' => array('2004'), 'genre' => array('Rock'), 'comment' => array('excellent!'), 'track' => array('04/16'));
Esempio n. 23
0
 public function tagWriter($file, $songdata)
 {
     $getID3 = new getID3();
     $TextEncoding = 'UTF-8';
     $getID3->setOption(array('encoding' => $TextEncoding));
     $tagwriter = new getid3_writetags();
     $tagwriter->filename = $file;
     //   print_r(base_url($file));
     $tagwriter->tagformats = array('id3v2.3');
     $tagwriter->overwrite_tags = true;
     $tagwriter->tag_encoding = $TextEncoding;
     //$tagwriter->remove_other_tags = true;
     $TagData = array('title' => array($songdata['titulo']), 'artist' => array($songdata['artista']), 'album' => array($songdata['album']), 'comment' => array('Tag creada por MusicBox'));
     $tagwriter->tag_data = $TagData;
     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);
     }
 }