Permalink
Browse files

Read title and desc from id3

  • Loading branch information...
1 parent 8f82279 commit f51b463b995e0f8fc6cdf61835bb0a83054c867a @tomnomnom committed Feb 29, 2012
Showing with 35,062 additions and 7 deletions.
  1. 0 Hooks/Postupload/write-hash.php
  2. 0 Hooks/Preupload/read-hash.php
  3. +211 −0 Library/GetID3/extension.cache.dbm.php
  4. +173 −0 Library/GetID3/extension.cache.mysql.php
  5. +1,317 −0 Library/GetID3/getid3.lib.php
  6. +1,744 −0 Library/GetID3/getid3.php
  7. +280 −0 Library/GetID3/module.archive.gzip.php
  8. +53 −0 Library/GetID3/module.archive.rar.php
  9. +96 −0 Library/GetID3/module.archive.szip.php
  10. +178 −0 Library/GetID3/module.archive.tar.php
  11. +424 −0 Library/GetID3/module.archive.zip.php
  12. +2,021 −0 Library/GetID3/module.audio-video.asf.php
  13. +73 −0 Library/GetID3/module.audio-video.bink.php
  14. +731 −0 Library/GetID3/module.audio-video.flv.php
  15. +1,706 −0 Library/GetID3/module.audio-video.matroska.php
  16. +299 −0 Library/GetID3/module.audio-video.mpeg.php
  17. +226 −0 Library/GetID3/module.audio-video.nsv.php
  18. +2,134 −0 Library/GetID3/module.audio-video.quicktime.php
  19. +530 −0 Library/GetID3/module.audio-video.real.php
  20. +2,409 −0 Library/GetID3/module.audio-video.riff.php
  21. +142 −0 Library/GetID3/module.audio-video.swf.php
  22. +59 −0 Library/GetID3/module.audio.aa.php
  23. +515 −0 Library/GetID3/module.audio.aac.php
  24. +473 −0 Library/GetID3/module.audio.ac3.php
  25. +165 −0 Library/GetID3/module.audio.au.php
  26. +127 −0 Library/GetID3/module.audio.avr.php
  27. +230 −0 Library/GetID3/module.audio.bonk.php
  28. +75 −0 Library/GetID3/module.audio.dss.php
  29. +246 −0 Library/GetID3/module.audio.dts.php
  30. +480 −0 Library/GetID3/module.audio.flac.php
  31. +229 −0 Library/GetID3/module.audio.la.php
  32. +130 −0 Library/GetID3/module.audio.lpac.php
  33. +526 −0 Library/GetID3/module.audio.midi.php
  34. +101 −0 Library/GetID3/module.audio.mod.php
  35. +205 −0 Library/GetID3/module.audio.monkey.php
  36. +2,011 −0 Library/GetID3/module.audio.mp3.php
  37. +509 −0 Library/GetID3/module.audio.mpc.php
  38. +705 −0 Library/GetID3/module.audio.ogg.php
  39. +429 −0 Library/GetID3/module.audio.optimfrog.php
  40. +94 −0 Library/GetID3/module.audio.rkau.php
  41. +183 −0 Library/GetID3/module.audio.shorten.php
  42. +109 −0 Library/GetID3/module.audio.tta.php
  43. +207 −0 Library/GetID3/module.audio.voc.php
  44. +162 −0 Library/GetID3/module.audio.vqf.php
  45. +400 −0 Library/GetID3/module.audio.wavpack.php
  46. +690 −0 Library/GetID3/module.graphic.bmp.php
  47. +53 −0 Library/GetID3/module.graphic.efax.php
  48. +184 −0 Library/GetID3/module.graphic.gif.php
  49. +338 −0 Library/GetID3/module.graphic.jpg.php
  50. +134 −0 Library/GetID3/module.graphic.pcd.php
  51. +520 −0 Library/GetID3/module.graphic.png.php
  52. +104 −0 Library/GetID3/module.graphic.svg.php
  53. +227 −0 Library/GetID3/module.graphic.tiff.php
  54. +312 −0 Library/GetID3/module.misc.cue.php
  55. +61 −0 Library/GetID3/module.misc.exe.php
  56. +389 −0 Library/GetID3/module.misc.iso.php
  57. +40 −0 Library/GetID3/module.misc.msoffice.php
  58. +33 −0 Library/GetID3/module.misc.par2.php
  59. +33 −0 Library/GetID3/module.misc.pdf.php
  60. +372 −0 Library/GetID3/module.tag.apetag.php
  61. +362 −0 Library/GetID3/module.tag.id3v1.php
  62. +3,327 −0 Library/GetID3/module.tag.id3v2.php
  63. +297 −0 Library/GetID3/module.tag.lyrics3.php
  64. +766 −0 Library/GetID3/module.tag.xmp.php
  65. +225 −0 Library/GetID3/write.apetag.php
  66. +138 −0 Library/GetID3/write.id3v1.php
  67. +2,050 −0 Library/GetID3/write.id3v2.php
  68. +73 −0 Library/GetID3/write.lyrics3.php
  69. +163 −0 Library/GetID3/write.metaflac.php
  70. +615 −0 Library/GetID3/write.php
  71. +275 −0 Library/GetID3/write.real.php
  72. +121 −0 Library/GetID3/write.vorbiscomment.php
  73. +33 −5 Library/VideoFile.php
  74. +5 −2 README.md
  75. +5 −0 Scripts/UploadSingle.php
View
0 Hooks/Postupload/write-hash.php 100644 → 100755
No changes.
View
0 Hooks/Preupload/read-hash.php 100644 → 100755
No changes.
@@ -0,0 +1,211 @@
+<?php
+/////////////////////////////////////////////////////////////////
+/// getID3() by James Heinrich <info@getid3.org> //
+// available at http://getid3.sourceforge.net //
+// or http://www.getid3.org //
+/////////////////////////////////////////////////////////////////
+// //
+// extension.cache.dbm.php - part of getID3() //
+// Please see readme.txt for more information //
+// ///
+/////////////////////////////////////////////////////////////////
+// //
+// This extension written by Allan Hansen <ahØartemis*dk> //
+// ///
+/////////////////////////////////////////////////////////////////
+
+
+/**
+* This is a caching extension for getID3(). It works the exact same
+* way as the getID3 class, but return cached information very fast
+*
+* Example:
+*
+* Normal getID3 usage (example):
+*
+* require_once 'getid3/getid3.php';
+* $getID3 = new getID3;
+* $getID3->encoding = 'UTF-8';
+* $info1 = $getID3->analyze('file1.flac');
+* $info2 = $getID3->analyze('file2.wv');
+*
+* getID3_cached usage:
+*
+* require_once 'getid3/getid3.php';
+* require_once 'getid3/getid3/extension.cache.dbm.php';
+* $getID3 = new getID3_cached('db3', '/tmp/getid3_cache.dbm',
+* '/tmp/getid3_cache.lock');
+* $getID3->encoding = 'UTF-8';
+* $info1 = $getID3->analyze('file1.flac');
+* $info2 = $getID3->analyze('file2.wv');
+*
+*
+* Supported Cache Types
+*
+* SQL Databases: (use extension.cache.mysql)
+*
+* cache_type cache_options
+* -------------------------------------------------------------------
+* mysql host, database, username, password
+*
+*
+* DBM-Style Databases: (this extension)
+*
+* cache_type cache_options
+* -------------------------------------------------------------------
+* gdbm dbm_filename, lock_filename
+* ndbm dbm_filename, lock_filename
+* db2 dbm_filename, lock_filename
+* db3 dbm_filename, lock_filename
+* db4 dbm_filename, lock_filename (PHP5 required)
+*
+* PHP must have write access to both dbm_filename and lock_filename.
+*
+*
+* Recommended Cache Types
+*
+* Infrequent updates, many reads any DBM
+* Frequent updates mysql
+*/
+
+
+class getID3_cached_dbm extends getID3
+{
+
+ // public: constructor - see top of this file for cache type and cache_options
+ function getID3_cached_dbm($cache_type, $dbm_filename, $lock_filename) {
+
+ // Check for dba extension
+ if (!extension_loaded('dba')) {
+ throw new Exception('PHP is not compiled with dba support, required to use DBM style cache.');
+ }
+
+ // Check for specific dba driver
+ if (!function_exists('dba_handlers') || !in_array($cache_type, dba_handlers())) {
+ throw new Exception('PHP is not compiled --with '.$cache_type.' support, required to use DBM style cache.');
+ }
+
+ // Create lock file if needed
+ if (!file_exists($lock_filename)) {
+ if (!touch($lock_filename)) {
+ throw new Exception('failed to create lock file: '.$lock_filename);
+ }
+ }
+
+ // Open lock file for writing
+ if (!is_writeable($lock_filename)) {
+ throw new Exception('lock file: '.$lock_filename.' is not writable');
+ }
+ $this->lock = fopen($lock_filename, 'w');
+
+ // Acquire exclusive write lock to lock file
+ flock($this->lock, LOCK_EX);
+
+ // Create dbm-file if needed
+ if (!file_exists($dbm_filename)) {
+ if (!touch($dbm_filename)) {
+ throw new Exception('failed to create dbm file: '.$dbm_filename);
+ }
+ }
+
+ // Try to open dbm file for writing
+ $this->dba = dba_open($dbm_filename, 'w', $cache_type);
+ if (!$this->dba) {
+
+ // Failed - create new dbm file
+ $this->dba = dba_open($dbm_filename, 'n', $cache_type);
+
+ if (!$this->dba) {
+ throw new Exception('failed to create dbm file: '.$dbm_filename);
+ }
+
+ // Insert getID3 version number
+ dba_insert(getID3::VERSION, getID3::VERSION, $this->dba);
+ }
+
+ // Init misc values
+ $this->cache_type = $cache_type;
+ $this->dbm_filename = $dbm_filename;
+
+ // Register destructor
+ register_shutdown_function(array($this, '__destruct'));
+
+ // Check version number and clear cache if changed
+ if (dba_fetch(getID3::VERSION, $this->dba) != getID3::VERSION) {
+ $this->clear_cache();
+ }
+
+ parent::getID3();
+ }
+
+
+
+ // public: destuctor
+ function __destruct() {
+
+ // Close dbm file
+ dba_close($this->dba);
+
+ // Release exclusive lock
+ flock($this->lock, LOCK_UN);
+
+ // Close lock file
+ fclose($this->lock);
+ }
+
+
+
+ // public: clear cache
+ function clear_cache() {
+
+ // Close dbm file
+ dba_close($this->dba);
+
+ // Create new dbm file
+ $this->dba = dba_open($this->dbm_filename, 'n', $this->cache_type);
+
+ if (!$this->dba) {
+ throw new Exception('failed to clear cache/recreate dbm file: '.$this->dbm_filename);
+ }
+
+ // Insert getID3 version number
+ dba_insert(getID3::VERSION, getID3::VERSION, $this->dba);
+
+ // Re-register shutdown function
+ register_shutdown_function(array($this, '__destruct'));
+ }
+
+
+
+ // public: analyze file
+ function analyze($filename) {
+
+ if (file_exists($filename)) {
+
+ // Calc key filename::mod_time::size - should be unique
+ $key = $filename.'::'.filemtime($filename).'::'.filesize($filename);
+
+ // Loopup key
+ $result = dba_fetch($key, $this->dba);
+
+ // Hit
+ if ($result !== false) {
+ return unserialize($result);
+ }
+ }
+
+ // Miss
+ $result = parent::analyze($filename);
+
+ // Save result
+ if (file_exists($filename)) {
+ dba_insert($key, serialize($result), $this->dba);
+ }
+
+ return $result;
+ }
+
+}
+
+
+?>
@@ -0,0 +1,173 @@
+<?php
+/////////////////////////////////////////////////////////////////
+/// getID3() by James Heinrich <info@getid3.org> //
+// available at http://getid3.sourceforge.net //
+// or http://www.getid3.org //
+/////////////////////////////////////////////////////////////////
+// //
+// extension.cache.mysql.php - part of getID3() //
+// Please see readme.txt for more information //
+// ///
+/////////////////////////////////////////////////////////////////
+// //
+// This extension written by Allan Hansen <ahØartemis*dk> //
+// Table name mod by Carlo Capocasa <calroØcarlocapocasa*com> //
+// ///
+/////////////////////////////////////////////////////////////////
+
+
+/**
+* This is a caching extension for getID3(). It works the exact same
+* way as the getID3 class, but return cached information very fast
+*
+* Example: (see also demo.cache.mysql.php in /demo/)
+*
+* Normal getID3 usage (example):
+*
+* require_once 'getid3/getid3.php';
+* $getID3 = new getID3;
+* $getID3->encoding = 'UTF-8';
+* $info1 = $getID3->analyze('file1.flac');
+* $info2 = $getID3->analyze('file2.wv');
+*
+* getID3_cached usage:
+*
+* require_once 'getid3/getid3.php';
+* require_once 'getid3/getid3/extension.cache.mysql.php';
+* // 5th parameter (tablename) is optional, default is 'getid3_cache'
+* $getID3 = new getID3_cached_mysql('localhost', 'database', 'username', 'password', 'tablename');
+* $getID3->encoding = 'UTF-8';
+* $info1 = $getID3->analyze('file1.flac');
+* $info2 = $getID3->analyze('file2.wv');
+*
+*
+* Supported Cache Types (this extension)
+*
+* SQL Databases:
+*
+* cache_type cache_options
+* -------------------------------------------------------------------
+* mysql host, database, username, password
+*
+*
+* DBM-Style Databases: (use extension.cache.dbm)
+*
+* cache_type cache_options
+* -------------------------------------------------------------------
+* gdbm dbm_filename, lock_filename
+* ndbm dbm_filename, lock_filename
+* db2 dbm_filename, lock_filename
+* db3 dbm_filename, lock_filename
+* db4 dbm_filename, lock_filename (PHP5 required)
+*
+* PHP must have write access to both dbm_filename and lock_filename.
+*
+*
+* Recommended Cache Types
+*
+* Infrequent updates, many reads any DBM
+* Frequent updates mysql
+*/
+
+
+class getID3_cached_mysql extends getID3
+{
+
+ // private vars
+ var $cursor;
+ var $connection;
+
+
+ // public: constructor - see top of this file for cache type and cache_options
+ function getID3_cached_mysql($host, $database, $username, $password, $table='getid3_cache') {
+
+ // Check for mysql support
+ if (!function_exists('mysql_pconnect')) {
+ throw new Exception('PHP not compiled with mysql support.');
+ }
+
+ // Connect to database
+ $this->connection = mysql_pconnect($host, $username, $password);
+ if (!$this->connection) {
+ throw new Exception('mysql_pconnect() failed - check permissions and spelling.');
+ }
+
+ // Select database
+ if (!mysql_select_db($database, $this->connection)) {
+ throw new Exception('Cannot use database '.$database);
+ }
+
+ // Set table
+ $this->table = $table;
+
+ // Create cache table if not exists
+ $this->create_table();
+
+ // Check version number and clear cache if changed
+ $version = '';
+ if ($this->cursor = mysql_query("SELECT `value` FROM `".mysql_real_escape_string($this->table)."` WHERE (`filename` = '".mysql_real_escape_string(getID3::VERSION)."') AND (`filesize` = '-1') AND (`filetime` = '-1') AND (`analyzetime` = '-1')", $this->connection)) {
+ list($version) = mysql_fetch_array($this->cursor);
+ }
+ if ($version != getID3::VERSION) {
+ $this->clear_cache();
+ }
+
+ parent::getID3();
+ }
+
+
+
+ // public: clear cache
+ function clear_cache() {
+
+ $this->cursor = mysql_query("DELETE FROM `".mysql_real_escape_string($this->table)."`", $this->connection);
+ $this->cursor = mysql_query("INSERT INTO `".mysql_real_escape_string($this->table)."` VALUES ('".getID3::VERSION."', -1, -1, -1, '".getID3::VERSION."')", $this->connection);
+ }
+
+
+
+ // public: analyze file
+ function analyze($filename) {
+
+ if (file_exists($filename)) {
+
+ // Short-hands
+ $filetime = filemtime($filename);
+ $filesize = filesize($filename);
+
+ // Lookup file
+ $this->cursor = mysql_query("SELECT `value` FROM `".mysql_real_escape_string($this->table)."` WHERE (`filename` = '".mysql_real_escape_string($filename)."') AND (`filesize` = '".mysql_real_escape_string($filesize)."') AND (`filetime` = '".mysql_real_escape_string($filetime)."')", $this->connection);
+ if (mysql_num_rows($this->cursor) > 0) {
+ // Hit
+ list($result) = mysql_fetch_array($this->cursor);
+ return unserialize(base64_decode($result));
+ }
+ }
+
+ // Miss
+ $analysis = parent::analyze($filename);
+
+ // Save result
+ if (file_exists($filename)) {
+ $this->cursor = mysql_query("INSERT INTO `".mysql_real_escape_string($this->table)."` (`filename`, `filesize`, `filetime`, `analyzetime`, `value`) VALUES ('".mysql_real_escape_string($filename)."', '".mysql_real_escape_string($filesize)."', '".mysql_real_escape_string($filetime)."', '".mysql_real_escape_string(time())."', '".mysql_real_escape_string(base64_encode(serialize($analysis)))."')", $this->connection);
+ }
+ return $analysis;
+ }
+
+
+
+ // private: (re)create sql table
+ function create_table($drop=false) {
+
+ $this->cursor = mysql_query("CREATE TABLE IF NOT EXISTS `".mysql_real_escape_string($this->table)."` (
+ `filename` VARCHAR(255) NOT NULL DEFAULT '',
+ `filesize` INT(11) NOT NULL DEFAULT '0',
+ `filetime` INT(11) NOT NULL DEFAULT '0',
+ `analyzetime` INT(11) NOT NULL DEFAULT '0',
+ `value` TEXT NOT NULL,
+ PRIMARY KEY (`filename`,`filesize`,`filetime`)) TYPE=MyISAM", $this->connection);
+ echo mysql_error($this->connection);
+ }
+}
+
+?>
Oops, something went wrong.

0 comments on commit f51b463

Please sign in to comment.