Skip to content

Commit

Permalink
Better Video integration in Ampache features
Browse files Browse the repository at this point in the history
  • Loading branch information
Afterster committed Jul 8, 2014
1 parent 7258fdc commit 0254be9
Show file tree
Hide file tree
Showing 92 changed files with 1,253 additions and 636 deletions.
92 changes: 34 additions & 58 deletions batch.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,64 +38,40 @@
$default_name = "Unknown.zip";
$name = $default_name;

switch ($_REQUEST['action']) {
case 'tmp_playlist':
$media_ids = $GLOBALS['user']->playlist->get_items();
$name = $GLOBALS['user']->username . ' - Playlist';
break;
case 'playlist':
$playlist = new Playlist($_REQUEST['id']);
$media_ids = $playlist->get_songs();
$name = $playlist->name;
break;
case 'smartplaylist':
$search = new Search($_REQUEST['id'], 'song');
$items = $search->get_items();
foreach ($items as $item) {
$media_ids[] = $item['object_id'];
}
$name = $search->name;
break;
case 'album':
foreach ($_REQUEST['id'] as $a) {
$album = new Album($a);
if ($name == $default_name) {
$name = $album->name;
}
$asongs = $album->get_songs();
foreach ($asongs as $song_id) {
$media_ids[] = $song_id;
}
}
break;
case 'artist':
$artist = new Artist($_REQUEST['id']);
$media_ids = $artist->get_songs();
$name = $artist->name;
break;
case 'browse':
$id = scrub_in($_REQUEST['browse_id']);
$browse = new Browse($id);
$browse_media_ids = $browse->get_saved();
foreach ($browse_media_ids as $media_id) {
switch ($_REQUEST['type']) {
case 'album':
$album = new Album($media_id);
$media_ids = array_merge($media_ids, $album->get_songs());
break;
case 'song':
$media_ids[] = $media_id;
break;
case 'video':
$media_ids[] = array('Video', $media_id);
break;
} // switch on type
} // foreach media_id
$name = 'Batch-' . date("dmY",time());
default:
// Rien a faire
break;
} // action switch
if (Core::is_playable_item($_REQUEST['action'])) {
$libitem = new $_REQUEST['action']($_REQUEST['id']);
$name = $libitem->get_fullname();
$media_ids = $libitem->get_medias();
} else {
switch ($_REQUEST['action']) {
case 'tmp_playlist':
$media_ids = $GLOBALS['user']->playlist->get_items();
$name = $GLOBALS['user']->username . ' - Playlist';
break;
case 'browse':
$id = scrub_in($_REQUEST['browse_id']);
$browse = new Browse($id);
$browse_media_ids = $browse->get_saved();
foreach ($browse_media_ids as $media_id) {
switch ($_REQUEST['type']) {
case 'album':
$album = new Album($media_id);
$media_ids = array_merge($media_ids, $album->get_songs());
break;
case 'song':
$media_ids[] = $media_id;
break;
case 'video':
$media_ids[] = array('Video', $media_id);
break;
} // switch on type
} // foreach media_id
$name = 'Batch-' . date("dmY",time());
default:
// Rien a faire
break;
} // action switch
}

// Take whatever we've got and send the zip
$song_files = get_song_files($media_ids);
Expand Down
3 changes: 2 additions & 1 deletion docs/PLUGINS
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ should be implemented as a public method:
get_metadata(Array $metadata)
The passed array contains the best metadata we've got.
save_rating(Rating $rating, int $new_value)
save_songplay(Song $song)
save_mediaplay(Media $media)
get_lyrics(Song $song)
process_wanted(Wanted $wanted)
shortener(string $url)
get_photos(string $search)
gather_arts(string $type, array $options, int $limit)

2 changes: 1 addition & 1 deletion image.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
}

$type = $_GET['object_type'];
if (!Catalog::is_library_item($type))
if (!Core::is_library_item($type))
exit;

/* Decide what size this image is */
Expand Down
3 changes: 1 addition & 2 deletions lib/batch.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ function get_song_files($media_ids)
if ($media->enabled) {
$total_size += sprintf("%.2f",($media->size/1048576));
$media->format();
$dirname = $media->f_album_full;
//debug_event('batch.lib.php', 'Songs file {'.$media->file.'}...', '5');
$dirname = $media->get_fullname();
if (!array_key_exists($dirname, $media_files)) {
$media_files[$dirname] = array();
}
Expand Down
19 changes: 17 additions & 2 deletions lib/class/album.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -484,15 +484,30 @@ public function get_fullname()
public function get_parent()
{
if ($album->artist_count == 1) {
return array('type' => 'artist', 'id' => $album->artist_id);
return array('object_type' => 'artist', 'object_id' => $album->artist_id);
}

return null;
}

public function get_childrens()
{
return array('song' => $this->get_songs());
return $this->get_medias();
}

public function get_medias($filter_type = null)
{
$medias = array();
if (!$filter_type || $filter_type == 'song') {
$songs = $this->get_songs();
foreach ($songs as $song_id) {
$medias[] = array(
'object_type' => 'song',
'object_id' => $song_id
);
}
}
return $medias;
}

public function get_user_owner()
Expand Down
59 changes: 31 additions & 28 deletions lib/class/art.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Art extends database_object
*/
public function __construct($uid, $type = 'album', $kind = 'default')
{
if (!Catalog::is_library_item($type))
if (!Core::is_library_item($type))
return false;
$this->type = $type;
$this->uid = $uid;
Expand Down Expand Up @@ -519,7 +519,7 @@ public static function get_from_source($data, $type = 'album')
public static function url($uid,$type,$sid=false)
{
$sid = $sid ? scrub_out($sid) : scrub_out(session_id());
if (!Catalog::is_library_item($type))
if (!Core::is_library_item($type))
return null;

$key = $type . $uid;
Expand Down Expand Up @@ -1129,28 +1129,21 @@ public static function gather_metadata_plugin($plugin, $type, $options)

$meta = $plugin->get_metadata($gtypes, $media_info);
$images = array();
switch ($type) {
case 'tvshow':
if ($meta['tvshow_art']) {
$url = $meta['tvshow_art'];
$ures = pathinfo($url);
$images[] = array('url' => $url, 'mime' => 'image/' . $ures['extension'], 'title' => $plugin->name);
}
break;
case 'tvshow_season':
if ($meta['tvshow_season_art']) {
$url = $meta['tvshow_season_art'];
$ures = pathinfo($url);
$images[] = array('url' => $url, 'mime' => 'image/' . $ures['extension'], 'title' => $plugin->name);
}
break;
default:
if ($meta['art']) {
$url = $meta['art'];
$ures = pathinfo($url);
$images[] = array('url' => $url, 'mime' => 'image/' . $ures['extension'], 'title' => $plugin->name);
}
break;

if ($meta['art']) {
$url = $meta['art'];
$ures = pathinfo($url);
$images[] = array('url' => $url, 'mime' => 'image/' . $ures['extension'], 'title' => $plugin->name);
}
if ($meta['tvshow_season_art']) {
$url = $meta['tvshow_season_art'];
$ures = pathinfo($url);
$images[] = array('url' => $url, 'mime' => 'image/' . $ures['extension'], 'title' => $plugin->name);
}
if ($meta['tvshow_art']) {
$url = $meta['tvshow_art'];
$ures = pathinfo($url);
$images[] = array('url' => $url, 'mime' => 'image/' . $ures['extension'], 'title' => $plugin->name);
}

return $images;
Expand All @@ -1160,9 +1153,9 @@ public static function get_thumb_size($thumb)
{
switch ($thumb) {
case '1':
/* This is used by the now_playing stuff */
$size['height'] = '75';
$size['width'] = '75';
/* This is used by the now_playing / browse stuff */
$size['height'] = '100';
$size['width'] = '100';
break;
case '2':
$size['height'] = '128';
Expand Down Expand Up @@ -1198,6 +1191,11 @@ public static function get_thumb_size($thumb)
$size['height'] = 200;
$size['width'] = 470;
break;
case '9':
/* Video preview size */
$size['height'] = 100;
$size['width'] = 235;
break;
default:
$size['height'] = '275';
$size['width'] = '275';
Expand Down Expand Up @@ -1229,7 +1227,7 @@ public static function display($object_type, $object_id, $name, $thumb, $link =
}
}
echo "<div class=\"item_art\">";
echo "<a href=\"" . $link . "\" alt=\"" . $name . "\"";
echo "<a href=\"" . $link . "\" title=\"" . $name . "\"";
if ($prettyPhoto) {
echo " rel=\"prettyPhoto\"";
}
Expand All @@ -1240,6 +1238,11 @@ public static function display($object_type, $object_id, $name, $thumb, $link =
}
echo "<img src=\"" . $imgurl . "\" alt=\"" . $name . "\" height=\"" . $size['height'] . "\" width=\"" . $size['width'] . "\" />";
if ($prettyPhoto) {
if ($size['width'] >= 150) {
echo "<div class=\"item_art_play\">";
echo Ajax::text('?page=stream&action=directplay&object_type=' . $object_type . '&object_id=' . $object_id, '<span class="item_art_play_icon" title="' . T_('Play') . '" />', 'directplay_art_' . $object_type . '_' .$object_id);
echo "</div>";
}
echo "<div class=\"item_art_actions\">";
$burl = substr($_SERVER['REQUEST_URI'], strlen(AmpConfig::get('raw_web_path')) + 1);
$burl = rawurlencode($burl);
Expand Down
22 changes: 22 additions & 0 deletions lib/class/artist.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,30 @@ public function get_parent()

public function get_childrens()
{
$albums = $this->get_albums();
foreach ($albums as $album_id) {
$medias[] = array(
'object_type' => 'album',
'object_id' => $album_id
);
}
return array('album' => $this->get_albums());
}

public function get_medias($filter_type = null)
{
$medias = array();
if (!$filter_type || $filter_type == 'song') {
$songs = $this->get_songs();
foreach ($songs as $song_id) {
$medias[] = array(
'object_type' => 'song',
'object_id' => $song_id
);
}
}
return $medias;
}

public function get_user_owner()
{
Expand Down
13 changes: 13 additions & 0 deletions lib/class/broadcast.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,19 @@ public function get_childrens()
{
return array();
}

public function get_medias($filter_type = null)
{
// Not a media, shouldn't be that
$medias = array();
if (!$filter_type || $filter_type == 'broadcast') {
$medias[] = array(
'object_type' => 'broadcast',
'object_id' => $this->id
);
}
return $medias;
}

public function get_user_owner()
{
Expand Down
9 changes: 5 additions & 4 deletions lib/class/browse.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ public function show_objects($object_ids = null, $argument = null)
break;
case 'video':
Video::build_cache($object_ids);
$video_type = 'video';
$box_title = T_('Videos');
$box_req = AmpConfig::get('prefix') . '/templates/show_videos.inc.php';
break;
Expand Down Expand Up @@ -245,22 +246,22 @@ public function show_objects($object_ids = null, $argument = null)
break;
case 'tvshow_episode':
$box_title = T_('Episodes');
$video_type = 'TVShow_Episode';
$video_type = $type;
$box_req = AmpConfig::get('prefix') . '/templates/show_videos.inc.php';
break;
case 'movie':
$box_title = T_('Movies');
$video_type = 'Movie';
$video_type = $type;
$box_req = AmpConfig::get('prefix') . '/templates/show_videos.inc.php';
break;
case 'clip':
$box_title = T_('Clips');
$video_type = 'Clip';
$video_type = $type;
$box_req = AmpConfig::get('prefix') . '/templates/show_videos.inc.php';
break;
case 'personal_video':
$box_title = T_('Personal Videos');
$video_type = 'Personal_Video';
$video_type = $type;
$box_req = AmpConfig::get('prefix') . '/templates/show_videos.inc.php';
break;
default:
Expand Down
23 changes: 2 additions & 21 deletions lib/class/catalog.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -836,8 +836,8 @@ public function gather_art_item($type, $id)

$parent = $libitem->get_parent();
if ($parent != null) {
if (!Art::has_db($parent['id'], $parent['type'])) {
$this->gather_art_item($parent['type'], $parent['id']);
if (!Art::has_db($parent['object_id'], $parent['object_type'])) {
$this->gather_art_item($parent['object_type'], $parent['object_id']);
}
}
}
Expand Down Expand Up @@ -1676,23 +1676,4 @@ public static function export($type, $catalog_id = '')

} // export

private static function is_class_typeof($classname, $typeofname)
{
if (class_exists($classname)) {
return in_array($typeofname, array_map('strtolower', class_implements($classname)));
}

return false;
}

public static function is_library_item($classname)
{
return self::is_class_typeof($classname, 'library_item');
}

public static function is_media($classname)
{
return self::is_class_typeof($classname, 'media');
}

} // end of catalog class
Loading

0 comments on commit 0254be9

Please sign in to comment.