summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2009-02-01 02:45:39 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2009-02-01 02:45:39 +0000
commit4aefc1fadc228ad5625462574cd1b341775f7125 (patch)
tree5d8de69efbb3c56638aa91d961e89261e098ef91
parentb9a2603025483deefbf7636de3f6c0786e95d293 (diff)
downloadampache-4aefc1fadc228ad5625462574cd1b341775f7125.tar.gz
ampache-4aefc1fadc228ad5625462574cd1b341775f7125.tar.bz2
ampache-4aefc1fadc228ad5625462574cd1b341775f7125.zip
incomplete changes, commiting because I need a coding break
-rw-r--r--config/ampache.cfg.php.dist7
-rw-r--r--lib/class/catalog.class.php49
-rw-r--r--lib/class/update.class.php23
-rw-r--r--lib/class/vainfo.class.php39
-rw-r--r--lib/general.lib.php102
5 files changed, 98 insertions, 122 deletions
diff --git a/config/ampache.cfg.php.dist b/config/ampache.cfg.php.dist
index ff7a2fea..4be6251e 100644
--- a/config/ampache.cfg.php.dist
+++ b/config/ampache.cfg.php.dist
@@ -93,6 +93,13 @@ auth_methods = "mysql"
; DEFAULT: mp3|mpc|m4p|m4a|mp4|aac|ogg|rm|wma|asf|flac|spx|ra|ape|shn|wv
catalog_file_pattern = "mp3|mpc|m4p|m4a|mp4|aac|ogg|rm|wma|asf|flac|spx|ra|ape|shn|wv"
+; Video Pattern
+; This defines which video file types Ampache will attempt to catalog
+; You can specify any file extension you want in here seperating them with
+; a | but ampache may not be able to parse them
+; DEAFULT: avi|mpg
+catalog_video_pattern = "avi|mpg"
+
; Prefix Pattern
; This defines which prefix Ampache will ignore when importing tags from
; your music. You may add any prefix you want seperating them with a |
diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php
index 2cd132ac..f0de8f34 100644
--- a/lib/class/catalog.class.php
+++ b/lib/class/catalog.class.php
@@ -499,9 +499,17 @@ class Catalog {
else {
$pattern .= ")$/i";
}
+
+ $is_audio_file = preg_match($pattern,$file);
+ // Define the Video file pattern
+ if (!$is_audio_file AND Config::get('catalog_video_pattern')) {
+ $video_pattern = "/\.(" . Config::get('catalog_video_pattern') . "$/i";
+ $is_video_file = preg_match($video_pattern,$file);
+ }
+
/* see if this is a valid audio file or playlist file */
- if (preg_match($pattern ,$file)) {
+ if ($is_audio_file OR $is_video_file) {
/* Now that we're sure its a file get filesize */
$file_size = filesize($full_file);
@@ -527,12 +535,13 @@ class Catalog {
}
} // end if iconv
- if (substr($file,-3,3) == 'm3u' AND $parse_m3u > 0) {
+ if ($options['parse_m3u'] AND substr($file,-3,3) == 'm3u') {
$this->_playlists[] = $full_file;
} // if it's an m3u
else {
- $this->insert_local_song($full_file,$file_size);
+ if ($is_audio_file) { $this->insert_local_song($full_file,$file_size); }
+ else { $this->insert_local_video($full_file,$file_size); }
/* Stupid little cutesie thing */
$this->count++;
@@ -1097,10 +1106,10 @@ class Catalog {
$vainfo->get_info();
/* Find the correct key */
- $key = get_tag_type($vainfo->tags);
+ $key = vainfo::get_tag_type($vainfo->tags);
/* Clean up the tags */
- $results = clean_tag_info($vainfo->tags,$key,$song->file);
+ $results = vainfo::clean_tag_info($vainfo->tags,$key,$song->file);
/* Setup the vars */
$new_song = new Song();
@@ -2099,10 +2108,10 @@ class Catalog {
$vainfo = new vainfo($file,'','','',$this->sort_pattern,$this->rename_pattern);
$vainfo->get_info();
- $key = get_tag_type($vainfo->tags);
+ $key = vainfo::get_tag_type($vainfo->tags);
/* Clean Up the tags */
- $results = clean_tag_info($vainfo->tags,$key,$file);
+ $results = vainfo::clean_tag_info($vainfo->tags,$key,$file);
/* Set the vars here... so we don't have to do the '" . $blah['asd'] . "' */
$title = Dba::escape($results['title']);
@@ -2179,22 +2188,22 @@ class Catalog {
flush();
}
- /**
- * TODO this data is not beïng passed through
- *
- */
- /*
- $song_id = Dba::insert_id();
+ } // insert_remote_song
- self::check_tag($tag,$song_id);
+ /**
+ * insert_local_video
+ * This inserts a video file into the video file table the tag
+ * information we can get is super sketchy so it's kind of a crap shoot
+ * here
+ */
+ public function insert_local_video($file,$filesize) {
- // Add the EXT information
- $sql = "INSERT INTO `song_data` (`song_id`,`comment`,`lyrics`) " .
- " VALUES ('$song_id','$comment','$lyrics')";
- $db_results = Dba::query($sql);
- */
+ /* Create the vainfo object and get info */
+ $vainfo = new vainfo($file,'','','',$this->sort_pattern,$this->rename_pattern);
+ $vainfo->get_info();
- } // insert_remote_song
+
+ } // insert_local_video
/**
* check_remote_song
diff --git a/lib/class/update.class.php b/lib/class/update.class.php
index 367c07e9..a69dd470 100644
--- a/lib/class/update.class.php
+++ b/lib/class/update.class.php
@@ -1543,5 +1543,28 @@ class Update {
} // update_350004
+ /**
+ * update_350005
+ * This update adds the video table... *gasp* no you didn't <head shake>
+ */
+ public static function update_350005() {
+
+ $sql = " CREATE TABLE `ampache`.`video` (" .
+ "`id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ," .
+ "`file` VARCHAR( 255 ) NOT NULL , " .
+ "`catalog` INT( 11 ) UNSIGNED NOT NULL ," .
+ "`title` VARCHAR( 255 ) NOT NULL ," .
+ "`video_codec` VARCHAR( 255 ) NOT NULL ," .
+ "`audio_codec` VARCHAR( 255 ) NOT NULL ," .
+ "`resolution_x` MEDIUMINT UNSIGNED NOT NULL ," .
+ "`resolution_y` MEDIUMINT UNSIGNED NOT NULL ," .
+ "`time` INT( 11 ) UNSIGNED NOT NULL ," .
+ "`size` BIGINT UNSIGNED NOT NULL," .
+ "`mime` VARCHAR( 255 ) NOT NULL" .
+ ") ENGINE = MYISAM ";
+ $db_results = Dba::write($sql);
+
+ } // update_350005
+
} // end update class
?>
diff --git a/lib/class/vainfo.class.php b/lib/class/vainfo.class.php
index 80fed827..d892e8e4 100644
--- a/lib/class/vainfo.class.php
+++ b/lib/class/vainfo.class.php
@@ -158,6 +158,45 @@ class vainfo {
} // get_info
/**
+ * get_tag_type
+ * This takes the result set, and the the tag_order
+ * As defined by your config file and trys to figure out
+ * which tag type it should use, if your tag_order
+ * doesn't match anything then it just takes the first one
+ * it finds in the results.
+ */
+ public static function get_tag_type($results) {
+
+ /* Pull In the config option */
+ $order = Config::get('tag_order');
+
+ if (!is_array($order)) {
+ $order = array($order);
+ }
+
+ /* Foreach through the defined key order
+ * the first one we find is the first one we use
+ */
+ foreach($order as $key) {
+ if ($results[$key]) {
+ $returned_key = $key;
+ break;
+ }
+ }
+
+ /* If we didn't find anything then default it to the
+ * first in the results set
+ */
+ if (!isset($returned_key)) {
+ $keys = array_keys($results);
+ $returned_key = $keys['0'];
+ }
+
+ return $returned_key;
+
+ } // get_tag_type
+
+ /**
* _get_type
* This function takes the raw information and figures out
* what type of file we are dealing with for use by the tag
diff --git a/lib/general.lib.php b/lib/general.lib.php
index cbe53ab2..11002f66 100644
--- a/lib/general.lib.php
+++ b/lib/general.lib.php
@@ -85,93 +85,6 @@ function extend_session($sid) {
} // extend_session
-/**
- * get_tag_type
- * This takes the result set, and the the tag_order
- * As defined by your config file and trys to figure out
- * which tag type it should use, if your tag_order
- * doesn't match anything then it just takes the first one
- * it finds in the results.
- */
-function get_tag_type($results) {
-
- /* Pull In the config option */
- $order = Config::get('tag_order');
-
- if (!is_array($order)) {
- $order = array($order);
- }
-
- /* Foreach through the defined key order
- * the first one we find is the first one we use
- */
- foreach($order as $key) {
- if ($results[$key]) {
- $returned_key = $key;
- break;
- }
- }
-
- /* If we didn't find anything then default it to the
- * first in the results set
- */
- if (!isset($returned_key)) {
- $keys = array_keys($results);
- $returned_key = $keys['0'];
- }
-
- return $returned_key;
-
-} // get_tag_type
-
-
-/**
- * clean_tag_info
- * This function takes the array from vainfo along with the
- * key we've decided on and the filename and returns it in a
- * sanatized format that ampache can actually use
- */
-function clean_tag_info($results,$key,$filename) {
-
- $info = array();
-
- $clean_array = array("\n","\t","\r","\0");
- $wipe_array = array("","","","");
-
- $info['file'] = $filename;
- $info['title'] = stripslashes(trim($results[$key]['title']));
- $info['year'] = intval($results[$key]['year']);
- $info['track'] = intval($results[$key]['track']);
- $info['disk'] = intval($results[$key]['disk']);
- $info['comment'] = Dba::escape(str_replace($clean_array,$wipe_array,$results[$key]['comment']));
- $info['language'] = Dba::escape($results[$key]['language']);
- $info['lyrics'] = Dba::escape($results[$key]['lyricist']);
-
- /* This are pulled from the info array */
- $info['bitrate'] = intval($results['info']['bitrate']);
- $info['rate'] = intval($results['info']['sample_rate']);
- $info['mode'] = $results['info']['bitrate_mode'];
-
- // Convert special version of constant bitrate mode to cbr
- if($info['mode'] == 'con') {
- $info['mode'] = 'cbr';
- }
-
- $info['size'] = $results['info']['filesize'];
- $info['mime'] = $results['info']['mime'];
- $into['encoding'] = $results['info']['encoding'];
- $info['time'] = intval($results['info']['playing_time']);
- $info['channels'] = intval($results['info']['channels']);
-
- /* These are used to generate the correct ID's later */
- $info['artist'] = trim($results[$key]['artist']);
- $info['album'] = trim($results[$key]['album']);
- $info['genre'] = trim($results[$key]['genre']);
-
- return $info;
-
-} // clean_tag_info
-
/*!
@function scrub_in()
@discussion Run on inputs, stuff that might get stuck in our db
@@ -267,21 +180,6 @@ function get_global_popular($type) {
} // get_global_popular
-/*!
- @function get_file_extension
- @discussion returns all characters after the last "." in $filename
- Should I be using pathinfo() instead?
-*/
-function get_file_extension( $filename ) {
- $file_name_parts = explode( ".", $filename );
- $num_parts = count( $file_name_parts );
- if( $num_parts <= 1 ) {
- return;
- } else {
- return $file_name_parts[$num_parts - 1];
- }
-} // get_file_extension
-
/**
* generate_password
* This generates a random password, of the specified