diff --git a/config/ampache.cfg.php.dist b/config/ampache.cfg.php.dist index 4406e580b2..befd61f1ff 100644 --- a/config/ampache.cfg.php.dist +++ b/config/ampache.cfg.php.dist @@ -120,15 +120,15 @@ auth_methods = "mysql" ; This defines which file types Ampache will attempt to catalog ; You can specify any file extension you want in here separating them ; with a | -; 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" +; DEFAULT: mp3|mpc|m4p|m4a|aac|ogg|oga|wav|aif|aiff|rm|wma|asf|flac|spx|ra|ape|shn|wv +catalog_file_pattern = "mp3|mpc|m4p|m4a|aac|ogg|oga|wav|aif|aiff|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|flv|m4v|webm -catalog_video_pattern = "avi|mpg|flv|m4v|webm|mkv" +; DEAFULT: avi|mpg|mpeg|flv|m4v|mp4|webm|mkv|wmv|ogv|mov|divx|m2ts +catalog_video_pattern = "avi|mpg|mpeg|flv|m4v|mp4|webm|mkv|wmv|ogv|mov|divx|m2ts" ; Playlist Pattern ; This defines which playlist types Ampache will attempt to catalog @@ -271,10 +271,15 @@ metadata_order = "getID3,filename" ; This determines the order in which metadata sources are used (and in the ; case of plugins, checked) for video files ; POSSIBLE VALUES (builtins): filename and getID3 -; POSSIBLE VALUES (plugins): Tmdb, plus any others you've installed. +; POSSIBLE VALUES (plugins): Tmdb,Omdb plus any others you've installed. ; DEFAULT: filename getID3 metadata_order_video = "filename,getID3" +; This determines if a preview image should be retrieved from video files +; It requires encode_get_image transcode settings. +; DEFAULT: false +;generate_video_preview = "true" + ; Un comment if don't want ampache to follow symlinks ; DEFAULT: false ;no_symlinks = "false" @@ -645,17 +650,41 @@ refresh_limit = "60" ; (e.g. if you store everything in FLAC, but don't want to ever stream that.) ; transcode_TYPE = {allowed|required|false} ; DEFAULT: false +;;; Audio ;transcode_m4a = allowed ;transcode_flac = required ;transcode_mpc = required ;transcode_ogg = required +;transcode_oga = required ;transcode_wav = required +;transcode_wma = required +;transcode_aif = required +;transcode_aiff = required +;transcode_ape = required +;transcode_shn = required ;transcode_mp3 = allowed - -; Default output format +;;; Video +;transcode_avi = allowed +;transcode_mkv = allowed +;transcode_mpg = allowed +;transcode_mpeg = allowed +;transcode_m4v = allowed +;transcode_mp4 = allowed +;transcode_mov = allowed +;transcode_wmv = allowed +;transcode_ogv = allowed +;transcode_divx = allowed +;transcode_m2ts = allowed +;transcode_webm = allowed + +; Default audio output format ; DEFAULT: none ;encode_target = mp3 +; Default video output format +; DEFAULT: none +;encode_video_target = flv + ; Override the default output format on a per-type basis ; encode_target_TYPE = TYPE ; DEFAULT: none @@ -697,6 +726,11 @@ transcode_player_customize = true ;encode_args_ogg = "-vn -b:a %SAMPLE%K -c:a libvorbis -f ogg pipe:1" ;encode_args_m4a = "-vn -b:a %SAMPLE%K -c:a libfdk_aac -f adts pipe:1" ;encode_args_wav = "-vn -b:a %SAMPLE%K -c:a pcm_s16le -f wav pipe:1" +;encode_args_flv = "-b:a %SAMPLE%K -ar 44100 -ac 2 -v 0 -f flv -c:v libx264 -preset superfast -threads 0 pipe:1" + +; Encoding arguments to retrieve an image from a single frame +; DEFAULT: none +;encode_get_image = "-ss %TIME% -f image2 -vframes 1 pipe:1" ;###################################################### ; these options allow you to configure your rss-feed diff --git a/image.php b/image.php index 7c7f626285..26e39bc5ab 100644 --- a/image.php +++ b/image.php @@ -52,6 +52,7 @@ /* Decide what size this image is */ $size = Art::get_thumb_size($_GET['thumb']); +$kind = isset($_GET['kind']) ? $_GET['kind'] : 'default'; $image = ''; $mime = ''; @@ -78,7 +79,7 @@ $item = new $type($_GET['object_id']); $filename = $item->name ?: $item->title; - $art = new Art($item->id, $type); + $art = new Art($item->id, $type, $kind); $art->get_db(); $etag = $art->id; diff --git a/lib/class/album.class.php b/lib/class/album.class.php index 349ae816ad..27155a88fb 100644 --- a/lib/class/album.class.php +++ b/lib/class/album.class.php @@ -484,7 +484,7 @@ public function get_fullname() public function get_parent() { if ($album->artist_count == 1) { - return array('artist', $album->artist_id); + return array('type' => 'artist', 'id' => $album->artist_id); } return null; @@ -500,6 +500,11 @@ public function get_user_owner() return null; } + public function get_default_art_kind() + { + return 'default'; + } + /** * get_random_songs * gets a random number, and a random assortment of songs from this album diff --git a/lib/class/art.class.php b/lib/class/art.class.php index d8752dd4fd..2e0372a8aa 100644 --- a/lib/class/art.class.php +++ b/lib/class/art.class.php @@ -37,6 +37,7 @@ class Art extends database_object public $uid; // UID of the object not ID because it's not the ART.ID public $raw; // Raw art data public $raw_mime; + public $kind; public $thumb; public $thumb_mime; @@ -48,12 +49,13 @@ class Art extends database_object * Art constructor, takes the UID of the object and the * object type. */ - public function __construct($uid, $type = 'album') + public function __construct($uid, $type = 'album', $kind = 'default') { if (!Catalog::is_library_item($type)) return false; $this->type = $type; $this->uid = $uid; + $this->kind = $kind; } // constructor @@ -196,8 +198,8 @@ public function get($raw=false) */ public function get_db() { - $sql = "SELECT `id`, `image`, `mime`, `size` FROM `image` WHERE `object_type` = ? AND `object_id` = ?"; - $db_results = Dba::read($sql, array($this->type, $this->uid)); + $sql = "SELECT `id`, `image`, `mime`, `size` FROM `image` WHERE `object_type` = ? AND `object_id` = ? AND `kind` = ?"; + $db_results = Dba::read($sql, array($this->type, $this->uid, $this->kind)); while ($results = Dba::fetch_assoc($db_results)) { if ($results['size'] == 'original') { @@ -230,10 +232,10 @@ public function get_db() } // get_db - public static function has_db($object_id, $object_type) + public static function has_db($object_id, $object_type, $kind = 'default') { - $sql = "SELECT COUNT(`id`) AS `nb_img` FROM `image` WHERE `object_type` = ? AND `object_id` = ?"; - $db_results = Dba::read($sql, array($object_type, $object_id)); + $sql = "SELECT COUNT(`id`) AS `nb_img` FROM `image` WHERE `object_type` = ? AND `object_id` = ? AND `kind` = ?"; + $db_results = Dba::read($sql, array($object_type, $object_id, $kind)); $nb_img = 0; if ($results = Dba::fetch_assoc($db_results)) { $nb_img = $results['nb_img']; @@ -269,18 +271,12 @@ public function insert($source, $mime) // Default to image/jpeg if they don't pass anything $mime = $mime ? $mime : 'image/jpeg'; - - $image = Dba::escape($source); - $mime = Dba::escape($mime); - $uid = Dba::escape($this->uid); - $type = Dba::escape($this->type); - // Blow it away! $this->reset(); // Insert it! - $sql = "INSERT INTO `image` (`image`, `mime`, `size`, `object_type`, `object_id`) VALUES('$image', '$mime', 'original', '$type', '$uid')"; - Dba::write($sql); + $sql = "INSERT INTO `image` (`image`, `mime`, `size`, `object_type`, `object_id`, `kind`) VALUES(?, ?, 'original', ?, ?, ?)"; + Dba::write($sql, array($source, $mime, $this->type, $this->uid, $this->kind)); return true; @@ -292,8 +288,8 @@ public function insert($source, $mime) */ public function reset() { - $sql = "DELETE FROM `image` WHERE `object_id` = ? AND `object_type` = ?"; - Dba::write($sql, array($this->uid, $this->type)); + $sql = "DELETE FROM `image` WHERE `object_id` = ? AND `object_type` = ? AND `kind` = ?"; + Dba::write($sql, array($this->uid, $this->type, $this->kind)); } // reset /** @@ -308,17 +304,11 @@ public function save_thumb($source, $mime, $size) return false; } - $source = Dba::escape($source); - $mime = Dba::escape($mime); - $size = Dba::escape($size); - $uid = Dba::escape($this->uid); - $type = Dba::escape($this->type); - - $sql = "DELETE FROM `image` WHERE `object_id`='$uid' AND `object_type`='$type' AND `size`='$size'"; - Dba::write($sql); + $sql = "DELETE FROM `image` WHERE `object_id` = ? AND `object_type` = ? AND `size` = ? AND `kind` = ?"; + Dba::write($sql, array($this->uid, $this->type, $size, $this->kind)); - $sql = "INSERT INTO `image` (`image`, `mime`, `size`, `object_type`, `object_id`) VALUES('$source', '$mime', '$size', '$type', '$uid')"; - Dba::write($sql); + $sql = "INSERT INTO `image` (`image`, `mime`, `size`, `object_type`, `object_id`, `kind`) VALUES(?, ?, ?, ?, ?, ?)"; + Dba::write($sql, array($source, $mime, $size, $this->type, $this->uid, $this->kind)); } // save_thumb /** @@ -329,12 +319,8 @@ public function save_thumb($source, $mime, $size) public function get_thumb($size) { $sizetext = $size['width'] . 'x' . $size['height']; - $sizetext = Dba::escape($sizetext); - $type = Dba::escape($this->type); - $uid = Dba::escape($this->uid); - - $sql = "SELECT `image`, `mime` FROM `image` WHERE `size`='$sizetext' AND `object_type`='$type' AND `object_id`='$uid'"; - $db_results = Dba::read($sql); + $sql = "SELECT `image`, `mime` FROM `image` WHERE `size` = ? AND `object_type` = ? AND `object_id` = ? AND `kind` = ?"; + $db_results = Dba::read($sql, array($sizetext, $this->type, $this->uid, $this->kind)); $results = Dba::fetch_assoc($db_results); if (count($results)) { @@ -469,8 +455,8 @@ public static function get_from_source($data, $type = 'album') $uid = Dba::escape($data['db']); $type = Dba::escape($type); - $sql = "SELECT * FROM `image` WHERE `object_type`='$type' AND `object_id`='$uid' AND `size`='original'"; - $db_results = Dba::read($sql); + $sql = "SELECT * FROM `image` WHERE `object_type` = ? AND `object_id` =? AND `size`='original'"; + $db_results = Dba::read($sql, array($type, $data['db'])); $row = Dba::fetch_assoc($db_results); return $row['art']; } // came from the db @@ -600,58 +586,19 @@ public static function gc() * gather * This tries to get the art in question */ - public function gather($options = array(), $limit = false) + public function gather($options = array(), $limit = false, $gather_parent = false) { // Define vars $results = array(); + $type = $this->type; + if (isset($options['type'])) { + $type = $options['type']; + } if (count($options) == 0) { - switch ($this->type) { - case 'album': - $album = new Album($this->uid); - $album->format(); - $options['artist'] = $album->f_artist; - $options['album'] = $album->f_name; - $options['keyword'] = $options['artist'] . ' ' . $options['album']; - break; - case 'artist': - $artist = new Artist($this->uid); - $artist->format(); - $options['artist'] = $album->f_artist; - $options['keyword'] = $options['artist']; - break; - case 'tvshow': - $tvshow = new TVShow($this->uid); - $tvshow->format(); - $options['tvshow'] = $tvshow->f_name; - $options['keyword'] = $options['tvshow']; - break; - case 'tvshow_season': - $season = new TVShow_Season($this->uid); - $season->format(); - $options['tvshow'] = $season->f_tvshow; - $options['tvshow_season'] = $season->f_name; - $options['keyword'] = $options['tvshow']; - break; - case 'tvshow_episode': - $video = new TVShow_Episode($this->uid); - $video->format(); - $options['tvshow'] = $video->f_tvshow; - $options['tvshow_season'] = $video->f_tvshow_season; - $options['tvshow_episode'] = $video->episode_number; - $options['keyword'] = $options['tvshow'] . " " . $video->f_title; - break; - case 'video': - case 'clip': - case 'movie': - case 'personal_video': - $video = new Video($this->uid); - $video->format(); - $options['keyword'] = $video->f_title; - break; - } + debug_event('Art', 'No options for art search, skipped.', 3); + return array(); } - $config = AmpConfig::get('art_order'); $methods = get_class_methods('Art'); @@ -676,7 +623,7 @@ public function gather($options = array(), $limit = false) $installed_version = Plugin::get_plugin_version($plugin->_plugin->name); if ($installed_version) { if ($plugin->load($GLOBALS['user'])) { - $data = $plugin->_plugin->gather_arts($this->type, $options, $limit); + $data = $plugin->_plugin->gather_arts($type, $options, $limit); } } } else if (in_array($method_name, $methods)) { @@ -1246,6 +1193,11 @@ public static function get_thumb_size($thumb) $size['height'] = 300; $size['width'] = 200; break; + case '8': + /* Video preview size */ + $size['height'] = 200; + $size['width'] = 470; + break; default: $size['height'] = '275'; $size['width'] = '275'; @@ -1260,12 +1212,21 @@ public static function display_item($item, $thumb, $link = null) return self::display($item->type, $item->id, $item->get_fullname(), $thumb, $link); } - public static function display($object_type, $object_id, $name, $thumb, $link = null) + public static function display($object_type, $object_id, $name, $thumb, $link = null, $show_default = true, $kind = 'default') { + if (!$show_default) { + // Don't show any image if not available + if (!self::has_db($object_id, $object_type, $kind)) { + return false; + } + } $size = self::get_thumb_size($thumb); $prettyPhoto = ($link == null); if ($link == null) { $link = AmpConfig::get('web_path') . "/image.php?object_id=" . $object_id . "&object_type=" . $object_type . "&auth=" . session_id(); + if ($kind != 'default') { + $link .= '&kind=' . $kind; + } } echo "