#1582 support for multiple playlist export added

This commit is contained in:
tomash 2006-03-09 02:08:33 +00:00
parent c590b92db0
commit c7ca61f5c3
5 changed files with 28 additions and 18 deletions

View file

@ -833,7 +833,8 @@ class BasicStor extends Alib{
* sub-playlists and media files (if desired) * sub-playlists and media files (if desired)
* *
* @param sessid - string, session ID * @param sessid - string, session ID
* @param plid - string, playlist global unique ID * @param plids - array of strings, playlist global unique IDs
* (one gunid is accepted too)
* @param type - string, playlist format, * @param type - string, playlist format,
* possible values: lspl | smil * possible values: lspl | smil
* @param standalone - boolean, if only playlist should be exported or * @param standalone - boolean, if only playlist should be exported or
@ -842,16 +843,21 @@ class BasicStor extends Alib{
* fname string: readable fname, * fname string: readable fname,
* token srring: access token * token srring: access token
*/ */
function bsExportPlaylistOpen($plid, $type='lspl', $standalone=FALSE) function bsExportPlaylistOpen($plids, $type='lspl', $standalone=FALSE)
{ {
require_once"Playlist.php"; require_once"Playlist.php";
$pl = $r = Playlist::recallByGunid($this, $plid); if(!is_array($plids)) $plids=array($plids);
if(PEAR::isError($r)) return $r; $gunids = array();
if($standalone){ foreach($plids as $plid){
$gunids = array(array('gunid'=>$plid, 'type'=>'playlist')); $pl = $r = Playlist::recallByGunid($this, $plid);
}else{
$gunids = $r = $pl->export();
if(PEAR::isError($r)) return $r; if(PEAR::isError($r)) return $r;
if($standalone){
$gunidsX = array(array('gunid'=>$plid, 'type'=>'playlist'));
}else{
$gunidsX = $r = $pl->export();
if(PEAR::isError($r)) return $r;
}
$gunids = array_merge($gunids, $gunidsX);
} }
$plExts = array('lspl'=>"lspl", 'smil'=>"smil", 'm3u'=>"m3u"); $plExts = array('lspl'=>"lspl", 'smil'=>"smil", 'm3u'=>"m3u");
$plExt = (isset($plExts[$type]) ? $plExts[$type] : "xml" ); $plExt = (isset($plExts[$type]) ? $plExts[$type] : "xml" );
@ -891,7 +897,9 @@ class BasicStor extends Alib{
copy($RADfname, "$tmpdc/{$it['gunid']}.$RADext"); copy($RADfname, "$tmpdc/{$it['gunid']}.$RADext");
} }
} }
copy("$tmpdp/$plid.$plExt", "$tmpd/exportedPlaylist.$plExt"); if(count($plids)==1){
copy("$tmpdp/$plid.$plExt", "$tmpd/exportedPlaylist.$plExt");
}
$res = `cd $tmpd; tar cf $tmpf * --remove-files`; $res = `cd $tmpd; tar cf $tmpf * --remove-files`;
@rmdir($tmpdc); @rmdir($tmpdp); @rmdir($tmpd); @rmdir($tmpdc); @rmdir($tmpdp); @rmdir($tmpd);
unlink($tmpn); unlink($tmpn);

View file

@ -669,7 +669,8 @@ class GreenBox extends BasicStor{
* sub-playlists and media files (if desired) * sub-playlists and media files (if desired)
* *
* @param sessid - string, session ID * @param sessid - string, session ID
* @param plid - string, playlist global unique ID * @param plids - array of strings, playlist global unique IDs
* (one gunid is accepted too)
* @param type - string, playlist format, values: lspl | smil | m3u * @param type - string, playlist format, values: lspl | smil | m3u
* @param standalone - boolean, if only playlist should be exported or * @param standalone - boolean, if only playlist should be exported or
* with all related files * with all related files
@ -677,9 +678,9 @@ class GreenBox extends BasicStor{
* fname string: readable fname, * fname string: readable fname,
* token srring: access token * token srring: access token
*/ */
function exportPlaylistOpen($sessid, $plid, $type='lspl', $standalone=FALSE) function exportPlaylistOpen($sessid, $plids, $type='lspl', $standalone=FALSE)
{ {
return $this->bsExportPlaylistOpen($plid, $type, $standalone); return $this->bsExportPlaylistOpen($plids, $type, $standalone);
} }
/** /**

View file

@ -673,7 +673,8 @@ class LocStor extends BasicStor{
* sub-playlists and media files (if desired) * sub-playlists and media files (if desired)
* *
* @param sessid - string, session ID * @param sessid - string, session ID
* @param plid - string, playlist global unique ID * @param plids - array of strings, playlist global unique IDs
* (one gunid is accepted too)
* @param type - string, playlist format, values: lspl | smil | m3u * @param type - string, playlist format, values: lspl | smil | m3u
* @param standalone - boolean, if only playlist should be exported or * @param standalone - boolean, if only playlist should be exported or
* with all related files * with all related files
@ -682,9 +683,9 @@ class LocStor extends BasicStor{
* token srring: access token * token srring: access token
* chsum string: md5 checksum, * chsum string: md5 checksum,
*/ */
function exportPlaylistOpen($sessid, $plid, $type='lspl', $standalone=FALSE) function exportPlaylistOpen($sessid, $plids, $type='lspl', $standalone=FALSE)
{ {
$res = $r =$this->bsExportPlaylistOpen($plid, $type, $standalone); $res = $r =$this->bsExportPlaylistOpen($plids, $type, $standalone);
if($this->dbc->isError($r)) return $r; if($this->dbc->isError($r)) return $r;
$url = $this->getUrlPart()."access/".basename($res['fname']); $url = $this->getUrlPart()."access/".basename($res['fname']);
$chsum = md5_file($res['fname']); $chsum = md5_file($res['fname']);

View file

@ -1170,7 +1170,7 @@ class XR_LocStor extends LocStor{
* fields: * fields:
* <ul> * <ul>
* <li> sessid : string - session id </li> * <li> sessid : string - session id </li>
* <li> plid : string - global unique id of Playlist</li> * <li> plids : array of strings - global unique IDs of Playlists</li>
* <li> type : string - playlist format, values: lspl | smil </li> * <li> type : string - playlist format, values: lspl | smil </li>
* <li> standalone : boolean - if only playlist should be exported or * <li> standalone : boolean - if only playlist should be exported or
* with all related files </li> * with all related files </li>
@ -1202,7 +1202,7 @@ class XR_LocStor extends LocStor{
if(!$ok) return $r; if(!$ok) return $r;
if(!isset($t['standalone'])) $r['standalone']=FALSE; if(!isset($t['standalone'])) $r['standalone']=FALSE;
$res = $this->exportPlaylistOpen( $res = $this->exportPlaylistOpen(
$r['sessid'], $r['plid'], $r['type'], $r['standalone'] $r['sessid'], $r['plids'], $r['type'], $r['standalone']
); );
if(PEAR::isError($res)){ if(PEAR::isError($res)){
return new XML_RPC_Response(0, 805, return new XML_RPC_Response(0, 805,

View file

@ -135,7 +135,7 @@ $infos = array(
'p'=>array('sessid', 'plid'), 'r'=>array('available', 'ownerid', 'ownerlogin')), 'p'=>array('sessid', 'plid'), 'r'=>array('available', 'ownerid', 'ownerlogin')),
"exportPlaylistOpen" => array('m'=>"locstor.exportPlaylistOpen", "exportPlaylistOpen" => array('m'=>"locstor.exportPlaylistOpen",
'p'=>array('sessid', 'plid', 'type'), 'p'=>array('sessid', 'plids', 'type'),
'r'=>array('url', 'token')), 'r'=>array('url', 'token')),
"exportPlaylistClose" => array('m'=>"locstor.exportPlaylistClose", "exportPlaylistClose" => array('m'=>"locstor.exportPlaylistClose",
'p'=>array('token'), 'r'=>array('status')), 'p'=>array('token'), 'r'=>array('status')),