Moved all file-related functions from BasicStor into StoredFile class.
Got rid of all the stuff related to GUNID hex-to-int conversion. Commented out lots of functions that are either not in use or will no longer work. Pypo: made things more generic and pluggable, added documentation. Added the PHP scripts to serve the right info back to pypo.
This commit is contained in:
parent
35dc3fd01f
commit
8a58df3093
|
@ -17,7 +17,7 @@ def api_client_factory(config):
|
|||
print 'API Client "'+config["api_client"]+'" not supported. Please check your config file.'
|
||||
print
|
||||
sys.exit()
|
||||
|
||||
|
||||
class ApiClientInterface:
|
||||
|
||||
# This is optional.
|
||||
|
@ -25,10 +25,16 @@ class ApiClientInterface:
|
|||
# 3rd party software.
|
||||
def check_version(self):
|
||||
nil
|
||||
|
||||
|
||||
# Required.
|
||||
# This is the main method you need to implement when creating a new API client.
|
||||
def get_schedule(self):
|
||||
return 0, []
|
||||
|
||||
# Required.
|
||||
# This downloads the media from the server.
|
||||
def get_media(self, src, dst):
|
||||
nil
|
||||
|
||||
# This is optional.
|
||||
# You dont actually have to implement this function for the liquidsoap playout to work.
|
||||
|
@ -76,7 +82,7 @@ class CampcasterApiClient(ApiClientInterface):
|
|||
try:
|
||||
if e[1] == 404:
|
||||
print '#####################################'
|
||||
print '# Unable to contact the OBP-API'
|
||||
print '# Unable to contact the Campcaster-API'
|
||||
print '# ' + url
|
||||
print '#####################################'
|
||||
sys.exit()
|
||||
|
@ -140,6 +146,18 @@ class CampcasterApiClient(ApiClientInterface):
|
|||
|
||||
return status, response
|
||||
|
||||
|
||||
def get_media(self, src, dst):
|
||||
logger = logging.getLogger("CampcasterApiClient.get_media")
|
||||
|
||||
try:
|
||||
src = src + "&api_key=" + self.config["api_key"]
|
||||
urllib.urlretrieve(src, dst, False)
|
||||
logger.info("downloaded %s to %s", src, dst)
|
||||
except Exception, e:
|
||||
logger.error("%s", e)
|
||||
|
||||
|
||||
def update_scheduled_item(self, item_id, value):
|
||||
logger = logging.getLogger("CampcasterApiClient.update_scheduled_item")
|
||||
|
||||
|
@ -160,20 +178,18 @@ class CampcasterApiClient(ApiClientInterface):
|
|||
|
||||
|
||||
def update_start_playing(self, playlist_type, export_source, media_id, playlist_id, transmission_id):
|
||||
return
|
||||
logger = logging.getLogger("ApiClient.update_scheduled_item")
|
||||
|
||||
url = self.api_url + 'schedule/update_start_playing.php' \
|
||||
+ '?playlist_type=' + str(playlist_type) \
|
||||
+ '&export_source=' + str(export_source) \
|
||||
+ '&media_id=' + str(media_id) \
|
||||
+ '&playlist_id=' + str(playlist_id) \
|
||||
+ '&transmission_id=' + str(transmission_id)
|
||||
|
||||
logger = logging.getLogger("CampcasterApiClient.update_scheduled_item")
|
||||
|
||||
url = self.config["base_url"] + self.config["api_base"] + self.config["update_start_playing_url"]
|
||||
url = url.replace("%%playlist_type%%", str(playlist_type))
|
||||
url = url.replace("%%export_source%%", str(export_source))
|
||||
url = url.replace("%%media_id%%", str(media_id))
|
||||
url = url.replace("%%playlist_id%%", str(playlist_id))
|
||||
url = url.replace("%%transmission_id%%", str(transmission_id))
|
||||
print url
|
||||
|
||||
try:
|
||||
response = urllib.urlopen(url, self.api_auth)
|
||||
response = urllib.urlopen(url)
|
||||
response = json.read(response.read())
|
||||
logger.info("API-Status %s", response['status'])
|
||||
logger.info("API-Message %s", response['message'])
|
||||
|
@ -188,7 +204,7 @@ class CampcasterApiClient(ApiClientInterface):
|
|||
|
||||
|
||||
def generate_range_dp(self):
|
||||
logger = logging.getLogger("ApiClient.generate_range_dp")
|
||||
logger = logging.getLogger("CampcasterApiClient.generate_range_dp")
|
||||
|
||||
url = self.api_url + 'schedule/generate_range_dp.php'
|
||||
|
||||
|
@ -208,6 +224,10 @@ class CampcasterApiClient(ApiClientInterface):
|
|||
|
||||
|
||||
################################################################################
|
||||
# OpenBroadcast API Client
|
||||
################################################################################
|
||||
# Also check out the php counterpart that handles the api requests:
|
||||
# https://lab.digris.ch/svn/elgg/trunk/unstable/mod/medialibrary/application/controllers/api/pypo.php
|
||||
|
||||
OBP_MIN_VERSION = 2010100101 # required obp version
|
||||
|
||||
|
@ -215,9 +235,8 @@ class ObpApiClient():
|
|||
|
||||
def __init__(self, config):
|
||||
self.config = config
|
||||
#self.api_url = api_url
|
||||
#self.api_auth = api_auth
|
||||
|
||||
self.api_auth = urllib.urlencode({'api_key': self.config["api_key"]})
|
||||
|
||||
def check_version(self):
|
||||
obp_version = self.get_obp_version()
|
||||
|
||||
|
@ -240,11 +259,12 @@ class ObpApiClient():
|
|||
print 'pypo is compatible with this version of OBP'
|
||||
print
|
||||
|
||||
|
||||
def get_obp_version(self):
|
||||
logger = logging.getLogger("ApiClient.get_obp_version")
|
||||
# lookup OBP version
|
||||
|
||||
url = self.api_url + 'api/pypo/status/json'
|
||||
logger = logging.getLogger("ObpApiClient.get_obp_version")
|
||||
|
||||
# lookup OBP version
|
||||
url = self.config["base_url"] + self.config["api_base"]+ self.config["version_url"]
|
||||
|
||||
try:
|
||||
logger.debug("Trying to contact %s", url)
|
||||
|
@ -258,7 +278,7 @@ class ObpApiClient():
|
|||
if e[1] == 401:
|
||||
print '#####################################'
|
||||
print '# YOUR API KEY SEEMS TO BE INVALID'
|
||||
print '# ' + self.api_auth
|
||||
print '# ' + self.config["api_auth"]
|
||||
print '#####################################'
|
||||
sys.exit()
|
||||
|
||||
|
@ -279,15 +299,26 @@ class ObpApiClient():
|
|||
obp_version = 0
|
||||
logger.error("Unable to detect OBP Version - %s", e)
|
||||
|
||||
|
||||
return obp_version
|
||||
|
||||
|
||||
|
||||
def get_media(self, src, dest):
|
||||
try:
|
||||
print '** urllib auth with: ',
|
||||
print self.api_auth
|
||||
urllib.urlretrieve(src, dst, False, self.api_auth)
|
||||
logger.info("downloaded %s to %s", src, dst)
|
||||
except Exception, e:
|
||||
logger.error("%s", e)
|
||||
|
||||
|
||||
def update_scheduled_item(self, item_id, value):
|
||||
logger = logging.getLogger("ApiClient.update_shedueled_item")
|
||||
logger = logging.getLogger("ObpApiClient.update_scheduled_item")
|
||||
# lookup OBP version
|
||||
|
||||
url = self.api_url + 'api/pypo/update_scheduled_item/' + str(item_id) + '?played=' + str(value)
|
||||
url = self.config["base_url"] + self.config["api_base"] + self.config["update_item_url"]
|
||||
url = url.replace("%%item_id%%", str(item_id))
|
||||
url = url.replace("%%played%%", str(value))
|
||||
|
||||
try:
|
||||
response = urllib.urlopen(url, self.api_auth)
|
||||
|
@ -300,22 +331,18 @@ class ObpApiClient():
|
|||
api_status = False
|
||||
logger.critical("Unable to connect to the OBP API - %s", e)
|
||||
|
||||
|
||||
return response
|
||||
|
||||
|
||||
def update_start_playing(self, playlist_type, export_source, media_id, playlist_id, transmission_id):
|
||||
|
||||
logger = logging.getLogger("ApiClient.update_shedueled_item")
|
||||
|
||||
url = self.api_url + 'api/pypo/update_start_playing/' \
|
||||
+ '?playlist_type=' + str(playlist_type) \
|
||||
+ '&export_source=' + str(export_source) \
|
||||
+ '&export_source=' + str(export_source) \
|
||||
+ '&media_id=' + str(media_id) \
|
||||
+ '&playlist_id=' + str(playlist_id) \
|
||||
+ '&transmission_id=' + str(transmission_id)
|
||||
logger = logging.getLogger("ApiClient.update_scheduled_item")
|
||||
|
||||
url = self.config["base_url"] + self.config["api_base"] + self.config["update_start_playing_url"]
|
||||
url = url.replace("%%playlist_type%%", str(playlist_type))
|
||||
url = url.replace("%%export_source%%", str(export_source))
|
||||
url = url.replace("%%media_id%%", str(media_id))
|
||||
url = url.replace("%%playlist_id%%", str(playlist_id))
|
||||
url = url.replace("%%transmission_id%%", str(transmission_id))
|
||||
print url
|
||||
|
||||
try:
|
||||
|
@ -330,14 +357,13 @@ class ObpApiClient():
|
|||
api_status = False
|
||||
logger.critical("Unable to connect to the OBP API - %s", e)
|
||||
|
||||
|
||||
return response
|
||||
|
||||
|
||||
def generate_range_dp(self):
|
||||
logger = logging.getLogger("ApiClient.generate_range_dp")
|
||||
logger = logging.getLogger("ObpApiClient.generate_range_dp")
|
||||
|
||||
url = self.api_url + 'api/pypo/generate_range_dp/'
|
||||
url = self.config["base_url"] + self.config["api_base"] + self.config["generate_range_url"]
|
||||
|
||||
try:
|
||||
response = urllib.urlopen(url, self.api_auth)
|
||||
|
|
|
@ -27,23 +27,40 @@ api_key = 'AAA'
|
|||
# Hostname
|
||||
base_url = 'http://localhost/'
|
||||
|
||||
################################################################################
|
||||
# Generic Config - if you are creating a new API client, define these values #
|
||||
################################################################################
|
||||
# Path to the base of the API
|
||||
api_base = ''
|
||||
|
||||
# URL to get the version number of the API
|
||||
version_url = ''
|
||||
|
||||
# Schedule export path.
|
||||
# %%from%% - starting date/time in the form YYYY-MM-DD-hh-mm
|
||||
# %%to%% - starting date/time in the form YYYY-MM-DD-hh-mm
|
||||
export_url = ''
|
||||
|
||||
# Update whether an item has been played.
|
||||
# %%item_id%%
|
||||
# %%played%%
|
||||
update_item_url = ''
|
||||
|
||||
# Update whether an item is currently playing.
|
||||
update_start_playing_url = ''
|
||||
|
||||
# ???
|
||||
generate_range_url = ''
|
||||
|
||||
|
||||
#####################
|
||||
# Campcaster Config #
|
||||
#####################
|
||||
# Path to the base of the API
|
||||
api_base = 'campcaster/'
|
||||
|
||||
# URL to get the version number of the API
|
||||
version_url = 'schedule/api_version.php?api_key=%%api_key%%'
|
||||
|
||||
# Schedule export path.
|
||||
# YYYY-MM-DD-hh-mm will be substituted for the tokens %%from%% and %%to%%
|
||||
export_url = 'schedule/schedule.php?from=%%from%%&to=%%to%%&api_key=%%api_key%%'
|
||||
|
||||
update_item_url = 'schedule/schedule.php?item_id=%%item_id%%&played=%%played%%'
|
||||
|
||||
update_start_playing_url = 'schedule/update_start_playing.php?playlist_type=%%playlist_type%%&export_source=%%export_source%%&media_id=%%media_id%%&playlist_id=%%playlist_id%%&transmission_id=%%transmission_id%%'
|
||||
|
||||
generate_range_url = 'schedule/generate_range_dp.php'
|
||||
|
||||
|
||||
|
@ -51,13 +68,11 @@ generate_range_url = 'schedule/generate_range_dp.php'
|
|||
# OBP config #
|
||||
##############
|
||||
#base_url = 'http://localhost/'
|
||||
#api_base = BASE_URL
|
||||
#version_url = api_base + 'api/pypo/status/json'
|
||||
#update_item_url = api_base + 'api/pypo/update_shedueled_item/$$item_id%%?played=%%played%%'
|
||||
|
||||
# prod config
|
||||
#base_url = ''
|
||||
#api_key = ''
|
||||
#api_base = ''
|
||||
#version_url = 'api/pypo/status/json'
|
||||
#update_item_url = 'api/pypo/update_shedueled_item/$$item_id%%?played=%%played%%'
|
||||
#update_start_playing_url = 'api/pypo/update_start_playing/?playlist_type=%%playlist_type%%&export_source=%%export_source%%&media_id=%%media_id%%&playlist_id=%%playlist_id%%&transmission_id=%%transmission_id%%'
|
||||
#generate_range_url = 'api/pypo/generate_range_dp/'
|
||||
|
||||
|
||||
############################################
|
||||
|
|
|
@ -8,8 +8,14 @@ Python part of radio playout (pypo)
|
|||
|
||||
The main functions are "fetch" (./pypo_cli.py -f) and "push" (./pypo_cli.py -p)
|
||||
|
||||
Also check out the php counterpart that handles the api requests:
|
||||
https://lab.digris.ch/svn/elgg/trunk/unstable/mod/medialibrary/application/controllers/api/pypo.php
|
||||
There are two layers: scheduler & daypart (fallback)
|
||||
|
||||
The daypart is a fallback-layer generated by the playlists daypart-settings
|
||||
(eg a playlist creator can say that the list is good for Monday and Tues,
|
||||
between 14:00 and 16:00). So if there is nothing in the schedule, pypo will
|
||||
still play something (instead of silence..) This layer is optional.
|
||||
It is there so that you dont have a fallback player which plays the same 100
|
||||
tracks over and over again.
|
||||
|
||||
Attention & ToDos
|
||||
- liquidsoap does not like mono files! So we have to make sure that only files with
|
||||
|
@ -290,7 +296,6 @@ class Playout:
|
|||
# TODO: maybe a bit more modular..
|
||||
silence_file = self.file_dir + 'basic/silence.mp3'
|
||||
|
||||
|
||||
if int(playlist['played']) == 1:
|
||||
logger.info("playlist %s already played / sent to liquidsoap, so will ignore it", pkey)
|
||||
|
||||
|
@ -311,14 +316,14 @@ class Playout:
|
|||
|
||||
else:
|
||||
print 'Could not find silence file!'
|
||||
print 'file is excpected to be at: ' + silence_file
|
||||
logger.critical('file is excpected to be at: %s', silence_file)
|
||||
print 'File is expected to be at: ' + silence_file
|
||||
logger.critical('File is expected to be at: %s', silence_file)
|
||||
sys.exit()
|
||||
|
||||
elif int(playlist['subtype']) == 6:
|
||||
"""
|
||||
This is a live-cast session
|
||||
create a silence list. (could eg also be a falback list..)
|
||||
Create a silence list. (could eg also be a fallback list..)
|
||||
"""
|
||||
logger.debug("found %s seconds of live-cast session at %s", pkey, playlist['duration'])
|
||||
|
||||
|
@ -330,8 +335,8 @@ class Playout:
|
|||
|
||||
else:
|
||||
print 'Could not find silence file!'
|
||||
print 'file is excpected to be at: ' + silence_file
|
||||
logger.critical('file is excpected to be at: %s', silence_file)
|
||||
print 'File is expected to be at: ' + silence_file
|
||||
logger.critical('File is expected to be at: %s', silence_file)
|
||||
sys.exit()
|
||||
|
||||
|
||||
|
@ -361,18 +366,16 @@ class Playout:
|
|||
|
||||
else:
|
||||
logger.debug("try to download %s", src)
|
||||
try:
|
||||
print '** urllib auth with: ',
|
||||
print self.api_auth
|
||||
urllib.urlretrieve (src, dst, False, self.api_auth)
|
||||
logger.info("downloaded %s to %s", src, dst)
|
||||
except Exception, e:
|
||||
logger.error("%s", e)
|
||||
api_client.get_media(src, dst)
|
||||
#try:
|
||||
# print '** urllib auth with: ',
|
||||
# print self.api_auth
|
||||
# urllib.urlretrieve (src, dst, False, self.api_auth)
|
||||
# logger.info("downloaded %s to %s", src, dst)
|
||||
#except Exception, e:
|
||||
# logger.error("%s", e)
|
||||
|
||||
elif src[0:4] == 'http' and do_cue == True:
|
||||
|
||||
|
||||
|
||||
if os.path.isfile(dst):
|
||||
logger.debug("file already in cache: %s", dst)
|
||||
print 'cached'
|
||||
|
@ -384,15 +387,15 @@ class Playout:
|
|||
dst_tmp = self.tmp_dir + "".join([random.choice(string.letters) for i in xrange(10)]) + '.mp3'
|
||||
print dst_tmp
|
||||
print '***'
|
||||
|
||||
try:
|
||||
print '** urllib auth with: ',
|
||||
print self.api_auth
|
||||
urllib.urlretrieve (src, dst_tmp, False, self.api_auth)
|
||||
logger.info("downloaded %s to %s", src, dst_tmp)
|
||||
except Exception, e:
|
||||
logger.error("%s", e)
|
||||
|
||||
api_client.get_media(src, dst_tmp)
|
||||
#try:
|
||||
# print '** urllib auth with: ',
|
||||
# print self.api_auth
|
||||
# urllib.urlretrieve (src, dst_tmp, False, self.api_auth)
|
||||
# logger.info("downloaded %s to %s", src, dst_tmp)
|
||||
#except Exception, e:
|
||||
# logger.error("%s", e)
|
||||
#
|
||||
|
||||
# cue
|
||||
print "STARTIONG CUE"
|
||||
|
@ -447,9 +450,6 @@ class Playout:
|
|||
except Exception, e:
|
||||
logger.error("%s", e)
|
||||
|
||||
|
||||
|
||||
|
||||
if do_cue == True:
|
||||
|
||||
if os.path.isfile(dst):
|
||||
|
@ -494,9 +494,6 @@ class Playout:
|
|||
except Exception, e:
|
||||
logger.error("%s", e)
|
||||
|
||||
|
||||
|
||||
|
||||
if True == os.access(dst, os.R_OK):
|
||||
# check filesize (avoid zero-byte files)
|
||||
#print 'waiting: ' + dst
|
||||
|
@ -513,7 +510,6 @@ class Playout:
|
|||
|
||||
print pl_entry
|
||||
|
||||
|
||||
"""
|
||||
Tracks are only added to the playlist if they are accessible
|
||||
on the file system and larger than 0 bytes.
|
||||
|
@ -523,7 +519,6 @@ class Playout:
|
|||
ls_playlist += pl_entry + "\n"
|
||||
|
||||
logger.debug("everything ok, adding %s to playlist", pl_entry)
|
||||
|
||||
else:
|
||||
print 'zero-file: ' + dst + ' from ' + src
|
||||
logger.warning("zero-size file - skiping %s. will not add it to playlist", dst)
|
||||
|
@ -531,8 +526,6 @@ class Playout:
|
|||
else:
|
||||
logger.warning("something went wrong. file %s not available. will not add it to playlist", dst)
|
||||
|
||||
|
||||
|
||||
except Exception, e: logger.info("%s", e)
|
||||
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ from configobj import ConfigObj
|
|||
|
||||
# custom imports
|
||||
from util import *
|
||||
from obp import *
|
||||
from api_clients import *
|
||||
from dls import *
|
||||
|
||||
PYPO_VERSION = '0.9'
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
require_once('../conf.php');
|
||||
require_once('DB.php');
|
||||
require_once('../backend/StoredFile.php');
|
||||
|
||||
$api_key = $_GET['api_key'];
|
||||
if(!in_array($api_key, $CC_CONFIG["apiKey"]))
|
||||
|
@ -19,20 +20,35 @@ if (PEAR::isError($CC_DBC)) {
|
|||
}
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
$file_id = $_GET[""]
|
||||
if(!is_file($src))
|
||||
{
|
||||
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
|
||||
//print 'Ressource in database, but not in storage. Sorry.';
|
||||
exit;
|
||||
$file_id = $_GET["file_id"];
|
||||
if (ctype_alnum($file_id) && strlen($file_id) == 32) {
|
||||
$media = StoredFile::RecallByGunid($file_id);
|
||||
if ($media != null && !PEAR::isError($media)) {
|
||||
//var_dump($media);
|
||||
$filepath = $media->getRealFileName();
|
||||
if(!is_file($filepath))
|
||||
{
|
||||
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
|
||||
//print 'Ressource in database, but not in storage. Sorry.';
|
||||
exit;
|
||||
}
|
||||
|
||||
// !! binary mode !!
|
||||
$fp = fopen($filepath, 'rb');
|
||||
|
||||
header("Content-Type: audio/mpeg");
|
||||
header("Content-Length: " . filesize($filepath));
|
||||
|
||||
fpassthru($fp);
|
||||
}
|
||||
else {
|
||||
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
|
||||
exit;
|
||||
}
|
||||
|
||||
// !! binary mode !!
|
||||
$fp = fopen($src, 'rb');
|
||||
|
||||
header("Content-Type: audio/mpeg");
|
||||
header("Content-Length: " . filesize($src));
|
||||
|
||||
fpassthru($fp);
|
||||
exit;
|
||||
|
||||
?>
|
|
@ -288,42 +288,42 @@ class Backup
|
|||
*/
|
||||
private function setFilenames()
|
||||
{
|
||||
if ($this->loglevel=='debug') {
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." setFilenames\n");
|
||||
}
|
||||
if (is_array($this->ids)) {
|
||||
foreach ($this->ids as $i => $item) {
|
||||
$gunid = $item['gunid'];
|
||||
// get a stored file object of this gunid
|
||||
$sf = StoredFile::RecallByGunid($gunid);
|
||||
if (is_null($sf) || PEAR::isError($sf)) {
|
||||
return $sf;
|
||||
}
|
||||
$lid = BasicStor::IdFromGunid($gunid);
|
||||
if (($res = BasicStor::Authorize('read', $lid, $this->sessid)) !== TRUE) {
|
||||
$this->addLogItem("-E- ".date("Ymd-H:i:s")." setFilenames - authorize gunid:$gunid\n");
|
||||
return PEAR::raiseError('Backup::setFilenames : Authorize ... error.');
|
||||
}
|
||||
// if the file is a playlist then it has only a meta file
|
||||
if (strtolower($sf->md->format) != 'playlist') {
|
||||
$this->filenames[] = array(
|
||||
'filename' => $sf->getRealFileName(),
|
||||
'format' => $sf->md->format
|
||||
);
|
||||
}
|
||||
$this->filenames[] = array(
|
||||
'filename' => $sf->getRealMetadataFileName(),
|
||||
'format' => $sf->md->format
|
||||
);
|
||||
if ($this->loglevel=='debug') {
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." setFilenames - add file: {$sf->md->format}|".$sf->getRealMetadataFileName()."\n");
|
||||
}
|
||||
}
|
||||
return $this->filenames;
|
||||
} else {
|
||||
$this->addLogItem("-E- ".date("Ymd-H:i:s")." setFilenames - The IDs variable isn't array.\n");
|
||||
return PEAR::raiseError('Backup::setFilenames : The IDs variable isn\'t array.');
|
||||
}
|
||||
// if ($this->loglevel=='debug') {
|
||||
// $this->addLogItem("-I- ".date("Ymd-H:i:s")." setFilenames\n");
|
||||
// }
|
||||
// if (is_array($this->ids)) {
|
||||
// foreach ($this->ids as $i => $item) {
|
||||
// $gunid = $item['gunid'];
|
||||
// // get a stored file object of this gunid
|
||||
// $sf = StoredFile::RecallByGunid($gunid);
|
||||
// if (is_null($sf) || PEAR::isError($sf)) {
|
||||
// return $sf;
|
||||
// }
|
||||
// $lid = BasicStor::IdFromGunid($gunid);
|
||||
// if (($res = BasicStor::Authorize('read', $lid, $this->sessid)) !== TRUE) {
|
||||
// $this->addLogItem("-E- ".date("Ymd-H:i:s")." setFilenames - authorize gunid:$gunid\n");
|
||||
// return PEAR::raiseError('Backup::setFilenames : Authorize ... error.');
|
||||
// }
|
||||
// // if the file is a playlist then it has only a meta file
|
||||
// if (strtolower($sf->md->format) != 'playlist') {
|
||||
// $this->filenames[] = array(
|
||||
// 'filename' => $sf->getRealFileName(),
|
||||
// 'format' => $sf->md->format
|
||||
// );
|
||||
// }
|
||||
// $this->filenames[] = array(
|
||||
// 'filename' => $sf->getRealMetadataFileName(),
|
||||
// 'format' => $sf->md->format
|
||||
// );
|
||||
// if ($this->loglevel=='debug') {
|
||||
// $this->addLogItem("-I- ".date("Ymd-H:i:s")." setFilenames - add file: {$sf->md->format}|".$sf->getRealMetadataFileName()."\n");
|
||||
// }
|
||||
// }
|
||||
// return $this->filenames;
|
||||
// } else {
|
||||
// $this->addLogItem("-E- ".date("Ymd-H:i:s")." setFilenames - The IDs variable isn't array.\n");
|
||||
// return PEAR::raiseError('Backup::setFilenames : The IDs variable isn\'t array.');
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,12 +1,11 @@
|
|||
<?php
|
||||
if (isset($WHITE_SCREEN_OF_DEATH) && $WHITE_SCREEN_OF_DEATH) {
|
||||
echo __FILE__.':line '.__LINE__.": Greenbox begin<br>";
|
||||
}
|
||||
require_once("BasicStor.php");
|
||||
if (isset($WHITE_SCREEN_OF_DEATH) && $WHITE_SCREEN_OF_DEATH) {
|
||||
echo __FILE__.':line '.__LINE__.": Loaded BasicStor<br>";
|
||||
}
|
||||
require_once("LocStor.php");
|
||||
if (isset($WHITE_SCREEN_OF_DEATH) && $WHITE_SCREEN_OF_DEATH) {
|
||||
echo __FILE__.':line '.__LINE__.": Loaded LocStor<br>";
|
||||
}
|
||||
require_once("Playlist.php");
|
||||
require_once("Renderer.php");
|
||||
require_once('Prefs.php');
|
||||
|
@ -51,7 +50,7 @@ class GreenBox extends BasicStor {
|
|||
if (($res = BasicStor::Authorize('write', null, $p_sessionId)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
$storedFile = $this->bsPutFile($p_values);
|
||||
$storedFile = StoredFile::Insert($p_values);
|
||||
return $storedFile;
|
||||
} // fn putFile
|
||||
|
||||
|
@ -87,12 +86,11 @@ class GreenBox extends BasicStor {
|
|||
"gunid" => $gunid,
|
||||
"filetype" => "webstream"
|
||||
);
|
||||
$storedFile = $this->bsPutFile($values);
|
||||
$storedFile = StoredFile::Insert($values);
|
||||
if (PEAR::isError($storedFile)) {
|
||||
return $storedFile;
|
||||
}
|
||||
$oid = $storedFile->getId();
|
||||
$r = $this->bsSetMetadataValue($oid, 'ls:url', $url);
|
||||
$r = $storedFile->setMetadataValue('ls:url', $url);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
|
@ -152,13 +150,13 @@ class GreenBox extends BasicStor {
|
|||
* Session id
|
||||
* @return array
|
||||
*/
|
||||
public function analyzeFile($id, $sessid='')
|
||||
{
|
||||
if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return $this->bsAnalyzeFile($id);
|
||||
} // fn analyzeFile
|
||||
// public function analyzeFile($id, $sessid='')
|
||||
// {
|
||||
// if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
|
||||
// return $res;
|
||||
// }
|
||||
// return $this->bsAnalyzeFile($id);
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
|
@ -171,13 +169,13 @@ class GreenBox extends BasicStor {
|
|||
* Session id
|
||||
* @return boolean|PEAR_Error
|
||||
*/
|
||||
public function renameFile($id, $newName, $sessid='')
|
||||
{
|
||||
if (($res = BasicStor::Authorize('write', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return $this->bsRenameFile($id, $newName);
|
||||
} // fn renameFile
|
||||
// public function renameFile($id, $newName, $sessid='')
|
||||
// {
|
||||
// if (($res = BasicStor::Authorize('write', $id, $sessid)) !== TRUE) {
|
||||
// return $res;
|
||||
// }
|
||||
// return $this->bsRenameFile($id, $newName);
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
|
@ -193,23 +191,23 @@ class GreenBox extends BasicStor {
|
|||
* session id
|
||||
* @return TRUE|PEAR_Error
|
||||
*/
|
||||
public function replaceFile($id, $mediaFileLP, $mdataFileLP, $sessid='')
|
||||
{
|
||||
if (($res = BasicStor::Authorize('write', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return $this->bsReplaceFile($id, $mediaFileLP, $mdataFileLP);
|
||||
} // fn replaceFile
|
||||
// public function replaceFile($id, $mediaFileLP, $mdataFileLP, $sessid='')
|
||||
// {
|
||||
// if (($res = BasicStor::Authorize('write', $id, $sessid)) !== TRUE) {
|
||||
// return $res;
|
||||
// }
|
||||
// return $this->bsReplaceFile($id, $mediaFileLP, $mdataFileLP);
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* Delete file
|
||||
*
|
||||
* @param int $id
|
||||
* virt.file's local id
|
||||
* local id
|
||||
* @param int $sessid
|
||||
* @param boolean $forced
|
||||
* if true don't use trash
|
||||
* if true don't use trash -- now ignored
|
||||
* @return true|PEAR_Error
|
||||
*/
|
||||
public function deleteFile($id, $sessid='', $forced=FALSE)
|
||||
|
@ -217,8 +215,9 @@ class GreenBox extends BasicStor {
|
|||
if (($res = BasicStor::Authorize('write', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return $this->bsDeleteFile($id, $forced);
|
||||
} // fn deleteFile
|
||||
$f = StoredFile::Recall($id);
|
||||
return $f->delete(true);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------- metadata */
|
||||
|
@ -260,7 +259,8 @@ class GreenBox extends BasicStor {
|
|||
if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return $this->bsGetMetadata($id);
|
||||
$f = StoredFile::Recall($id);
|
||||
return $f->getMetadata();
|
||||
}
|
||||
|
||||
|
||||
|
@ -345,8 +345,9 @@ class GreenBox extends BasicStor {
|
|||
if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return $this->bsGetMetadataValue($id, $category);
|
||||
} // fn getMetadataValue
|
||||
$f = StoredFile::Recall($id);
|
||||
return $f->getMetadataValue($category);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -367,7 +368,8 @@ class GreenBox extends BasicStor {
|
|||
if (($res = BasicStor::Authorize('write', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return $this->bsSetMetadataValue($id, $category, $value);
|
||||
$f = StoredFile::Recall($id);
|
||||
return $f->setMetadataValue($category, $value);
|
||||
} // fn setMetadataValue
|
||||
|
||||
|
||||
|
@ -560,7 +562,7 @@ class GreenBox extends BasicStor {
|
|||
return;
|
||||
|
||||
$res = $pl->lock($sessid);
|
||||
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
@ -743,10 +745,6 @@ class GreenBox extends BasicStor {
|
|||
* current playtime (hh:mm:ss.ssssss)
|
||||
* @param int $distance
|
||||
* 0=current clip; 1=next clip ...
|
||||
* @param string $lang
|
||||
* xml:lang value for select language version
|
||||
* @param string $deflang
|
||||
* xml:lang for default language
|
||||
* @return array of matching clip info:
|
||||
* <ul>
|
||||
* <li>gunid string, global unique id of clip</li>
|
||||
|
@ -755,10 +753,9 @@ class GreenBox extends BasicStor {
|
|||
* <li>duration string, total playlength of clip </li>
|
||||
* </ul>
|
||||
*/
|
||||
public function displayPlaylistClipAtOffset($sessid, $plid, $offset, $distance=0,
|
||||
$lang=NULL, $deflang=NULL)
|
||||
public function displayPlaylistClipAtOffset($sessid, $plid, $offset, $distance=0)
|
||||
{
|
||||
$pl = StoredFile::RecallByGunid($plid);
|
||||
$pl = Playlist::Recall($plid);
|
||||
if (is_null($pl) || PEAR::isError($pl)) {
|
||||
return $pl;
|
||||
}
|
||||
|
@ -767,23 +764,17 @@ class GreenBox extends BasicStor {
|
|||
return $res;
|
||||
}
|
||||
$res['title'] = NULL;
|
||||
$id = BasicStor::IdFromGunid($res['gunid']);
|
||||
if (PEAR::isError($id)) {
|
||||
return $id;
|
||||
}
|
||||
if (!is_null($id)) {
|
||||
$res['title'] = $this->bsGetMetadataValue($id, "dc:title");
|
||||
$f = StoredFile::RecallByGunid($res['gunid']);
|
||||
if (PEAR::isError($f)) {
|
||||
return $f;
|
||||
}
|
||||
$res['title'] = $f->getMetadataValue("dc:title");
|
||||
$res['playlist_title'] = NULL;
|
||||
$id = BasicStor::IdFromGunid($plid);
|
||||
if (PEAR::isError($id)) {
|
||||
return $id;
|
||||
}
|
||||
if (!is_null($id)) {
|
||||
$res['playlist'] = $this->bsGetMetadataValue($id, "dc:title");
|
||||
}
|
||||
$pl = Playlist::Recall($plid);
|
||||
$res['playlist'] = $pl->getName();
|
||||
|
||||
return $res;
|
||||
} // fn displayPlaylistClipAtOffset
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -1100,7 +1091,7 @@ class GreenBox extends BasicStor {
|
|||
$fakeFile = $CC_CONFIG['accessDir']."/$token.rss";
|
||||
if ($token != '123456789abcdeff' || !file_exists($fakeFile)){
|
||||
return PEAR::raiseError(
|
||||
"LocStor::renderPlaylistToRSSCheck: invalid token ($token)"
|
||||
"renderPlaylistToRSSCheck: invalid token ($token)"
|
||||
);
|
||||
}
|
||||
return array(
|
||||
|
@ -1592,20 +1583,6 @@ class GreenBox extends BasicStor {
|
|||
|
||||
|
||||
/* ========================================================= info methods */
|
||||
/**
|
||||
* Get type of stored file (by local id)
|
||||
*
|
||||
* @param int $id
|
||||
* local id
|
||||
* @return string|PEAR_Error
|
||||
*/
|
||||
public static function getFileType($id)
|
||||
{
|
||||
$type = BasicStor::GetObjType($id);
|
||||
return $type;
|
||||
} // fn getFileType
|
||||
|
||||
|
||||
/**
|
||||
* Check if file gunid exists in the storage and
|
||||
* user have permission to read it
|
||||
|
@ -1619,12 +1596,11 @@ class GreenBox extends BasicStor {
|
|||
*/
|
||||
public function existsFile($sessid, $gunid, $ftype=NULL)
|
||||
{
|
||||
$id = BasicStor::IdFromGunid($gunid);
|
||||
$ex = $this->bsExistsFile($id, $ftype);
|
||||
if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
return $ex;
|
||||
if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
$f = StoredFile::RecallByGunid($gunid);
|
||||
return $f->existsFile();
|
||||
} // fn existsFile
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
if (isset($WHITE_SCREEN_OF_DEATH) && $WHITE_SCREEN_OF_DEATH) {
|
||||
echo __FILE__.':line '.__LINE__.": LocStor loading<br>";
|
||||
}
|
||||
require_once("BasicStor.php");
|
||||
if (isset($WHITE_SCREEN_OF_DEATH) && $WHITE_SCREEN_OF_DEATH) {
|
||||
echo __FILE__.':line '.__LINE__.": Loaded BasicStor<br>";
|
||||
|
@ -107,10 +110,7 @@ class LocStor extends BasicStor {
|
|||
if ($fname == '') {
|
||||
$fname = "newFile";
|
||||
}
|
||||
$res = $this->bsRenameFile($storedFile->id, $fname);
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$storedFile->setName($fname);
|
||||
return $this->bsOpenPut($chsum, $storedFile->gunid);
|
||||
}
|
||||
|
||||
|
@ -194,8 +194,7 @@ class LocStor extends BasicStor {
|
|||
if (is_null($storedFile) || PEAR::isError($storedFile)) {
|
||||
return $storedFile;
|
||||
}
|
||||
$oid = $storedFile->getId();
|
||||
$r = $this-> bsSetMetadataValue($oid, 'ls:url', $url);
|
||||
$r = $storedFile->setMetadataValue('ls:url', $url);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
|
@ -263,7 +262,8 @@ class LocStor extends BasicStor {
|
|||
if (PEAR::isError($ex)) {
|
||||
return $ex;
|
||||
}
|
||||
$id = BasicStor::IdFromGunid($gunid);
|
||||
$media = StoredFile::RecallByGunid($gunid);
|
||||
$id = $media->getId();
|
||||
if (is_null($id) || !$ex) {
|
||||
return PEAR::raiseError(
|
||||
"LocStor::downloadRawAudioDataOpen: gunid not found ($gunid)",
|
||||
|
@ -306,7 +306,8 @@ class LocStor extends BasicStor {
|
|||
{
|
||||
// $res = $this->existsAudioClip($sessid, $gunid);
|
||||
// if(PEAR::isError($res)) return $res;
|
||||
$id = BasicStor::IdFromGunid($gunid);
|
||||
$media = StoredFile::RecallByGunid($gunid)
|
||||
$id = $media->getGunid();
|
||||
if (is_null($id)) {
|
||||
return PEAR::raiseError(
|
||||
"LocStor::downloadMetadataOpen: gunid not found ($gunid)"
|
||||
|
@ -351,7 +352,7 @@ class LocStor extends BasicStor {
|
|||
if (($res = BasicStor::Authorize('read', $storedFile->getId(), $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
$md = $this->bsGetMetadata($storedFile->getId());
|
||||
$md = $storedFile->getMetadata();
|
||||
if (PEAR::isError($md)) {
|
||||
return $md;
|
||||
}
|
||||
|
@ -504,15 +505,14 @@ class LocStor extends BasicStor {
|
|||
*/
|
||||
protected function existsFile($sessid, $gunid, $ftype=NULL)
|
||||
{
|
||||
$id = BasicStor::IdFromGunid($gunid);
|
||||
if (is_null($id)) {
|
||||
return FALSE;
|
||||
}
|
||||
if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
$ex = $this->bsExistsFile($id, $ftype);
|
||||
return $ex;
|
||||
$f = StoredFile::RecallByGunid($gunid);
|
||||
if (PEAR::isError($f)) {
|
||||
return FALSE;
|
||||
}
|
||||
return $f->existsFile();
|
||||
}
|
||||
|
||||
|
||||
|
@ -540,7 +540,7 @@ class LocStor extends BasicStor {
|
|||
if (($res = BasicStor::Authorize('write', $storedFile->getId(), $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
$res = $this->bsDeleteFile($storedFile->getId(), $forced);
|
||||
$res = $storedFile->delete();
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
|
@ -602,26 +602,14 @@ class LocStor extends BasicStor {
|
|||
"metadata" => dirname(__FILE__).'/emptyPlaylist.xml',
|
||||
"gunid" => $playlistId,
|
||||
"filetype" => "playlist");
|
||||
// This is all wrong now.
|
||||
$storedFile = StoredFile::Insert($values);
|
||||
if (PEAR::isError($storedFile)) {
|
||||
$res = BasicStor::RemoveObj($oid);
|
||||
return $storedFile;
|
||||
}
|
||||
if ($fname == '') {
|
||||
$fname = "newFile.xml";
|
||||
}
|
||||
$res = $this->bsRenameFile($oid, $fname);
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$res = $storedFile->setState('ready');
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$res = $storedFile->setMime('application/smil');
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$storedFile->setName($fname);
|
||||
$storedFile->setState('ready');
|
||||
$storedFile->setMime('application/smil');
|
||||
return $storedFile->gunid;
|
||||
}
|
||||
|
||||
|
@ -775,7 +763,7 @@ class LocStor extends BasicStor {
|
|||
if (($res = BasicStor::Authorize('write', $storedFile->getId(), $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
$res = $this->bsDeleteFile($storedFile->getId(), $forced);
|
||||
$res = $storedFile->delete();
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
|
@ -803,32 +791,32 @@ class LocStor extends BasicStor {
|
|||
* }
|
||||
*/
|
||||
public function accessPlaylist($sessid, $playlistId, $recursive=FALSE, $parent='0')
|
||||
{
|
||||
if ($recursive) {
|
||||
require_once("AccessRecur.php");
|
||||
$r = AccessRecur::accessPlaylist($this, $sessid, $playlistId);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
$ex = $this->existsPlaylist($sessid, $playlistId);
|
||||
if (PEAR::isError($ex)) {
|
||||
return $ex;
|
||||
}
|
||||
if (!$ex) {
|
||||
return PEAR::raiseError(
|
||||
"LocStor::accessPlaylist: playlist not found ($playlistId)",
|
||||
GBERR_NOTF
|
||||
);
|
||||
}
|
||||
$id = BasicStor::IdFromGunid($playlistId);
|
||||
if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
|
||||
return $res;
|
||||
}
|
||||
$res = $this->bsOpenDownload($id, 'metadata', $parent);
|
||||
#unset($res['filename']);
|
||||
return $res;
|
||||
// {
|
||||
// if ($recursive) {
|
||||
// require_once("AccessRecur.php");
|
||||
// $r = AccessRecur::accessPlaylist($this, $sessid, $playlistId);
|
||||
// if (PEAR::isError($r)) {
|
||||
// return $r;
|
||||
// }
|
||||
// return $r;
|
||||
// }
|
||||
// $ex = $this->existsPlaylist($sessid, $playlistId);
|
||||
// if (PEAR::isError($ex)) {
|
||||
// return $ex;
|
||||
// }
|
||||
// if (!$ex) {
|
||||
// return PEAR::raiseError(
|
||||
// "LocStor::accessPlaylist: playlist not found ($playlistId)",
|
||||
// GBERR_NOTF
|
||||
// );
|
||||
// }
|
||||
// $id = BasicStor::IdFromGunid($playlistId);
|
||||
// if (($res = BasicStor::Authorize('read', $id, $sessid)) !== TRUE) {
|
||||
// return $res;
|
||||
// }
|
||||
// $res = $this->bsOpenDownload($id, 'metadata', $parent);
|
||||
// #unset($res['filename']);
|
||||
// return $res;
|
||||
}
|
||||
|
||||
|
||||
|
@ -953,7 +941,8 @@ class LocStor extends BasicStor {
|
|||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
return BasicStor::GunidFromId($res);
|
||||
$media = StoredFile::Recall($id);
|
||||
return $media->getGunId();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1444,7 +1433,7 @@ class LocStor extends BasicStor {
|
|||
"gunid" => $pars['gunid'],
|
||||
"filetype" => "audioclip"
|
||||
);
|
||||
$storedFile = $this->bsPutFile($values);
|
||||
$storedFile = StoredFile::Insert($values);
|
||||
if (PEAR::isError($storedFile)) {
|
||||
return $storedFile;
|
||||
}
|
||||
|
@ -1462,7 +1451,7 @@ class LocStor extends BasicStor {
|
|||
"gunid" => $pars['gunid'],
|
||||
"filetype" => "playlist"
|
||||
);
|
||||
$storedFile = $this->bsPutFile($values);
|
||||
$storedFile = StoredFile::Insert($values);
|
||||
if (PEAR::isError($storedFile)) {
|
||||
return $storedFile;
|
||||
}
|
||||
|
@ -1534,97 +1523,99 @@ class LocStor extends BasicStor {
|
|||
*/
|
||||
function downloadOpen($sessid, $trtype, $pars=array())
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
switch ($trtype) {
|
||||
case "unknown":
|
||||
case "audioclip":
|
||||
case "metadata":
|
||||
case "playlist":
|
||||
case "playlistPkg":
|
||||
if (!isset($pars['gunid'])) {
|
||||
return PEAR::raiseError("Archive::downloadOpen: gunid not set");
|
||||
}
|
||||
break;
|
||||
}
|
||||
$gunid = $pars['gunid'];
|
||||
// resolve trtype by object type:
|
||||
if ( ($trtype == 'unknown') || ($trtype == 'playlistPkg') ) {
|
||||
$trtype2 = BasicStor::GetType($gunid);
|
||||
if (PEAR::isError($trtype2)) {
|
||||
return $trtype2;
|
||||
}
|
||||
// required with content:
|
||||
$trtype = ( ($trtype2 == 'playlist') && ($trtype == 'playlistPkg') ?
|
||||
'playlistPkg' : $trtype2);
|
||||
//return PEAR::raiseError("Archive::downloadOpen: TT=$trtype TT2=$trtype2 G=$gunid");
|
||||
}
|
||||
switch ($trtype) {
|
||||
case "audioclip":
|
||||
$res = $this->downloadRawAudioDataOpen($sessid, $gunid);
|
||||
break;
|
||||
case "metadata":
|
||||
$res = $this->downloadMetadataOpen($sessid, $gunid);
|
||||
break;
|
||||
case "playlist":
|
||||
$res = $this->accessPlaylist($sessid, $gunid);
|
||||
break;
|
||||
case "playlistPkg":
|
||||
$res = $this->bsExportPlaylistOpen($gunid);
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$tmpn = tempnam($CC_CONFIG['transDir'], 'plExport_');
|
||||
$plfpath = "$tmpn.lspl";
|
||||
copy($res['fname'], $plfpath);
|
||||
$res = $this->bsExportPlaylistClose($res['token']);
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
$fname = "transported_playlist.lspl";
|
||||
$id = BasicStor::IdFromGunid($gunid);
|
||||
$acc = BasicStor::bsAccess($plfpath, 'lspl', NULL, 'download');
|
||||
if (PEAR::isError($acc)) {
|
||||
return $acc;
|
||||
}
|
||||
$url = BasicStor::GetUrlPart()."access/".basename($acc['fname']);
|
||||
$chsum = md5_file($plfpath);
|
||||
$size = filesize($plfpath);
|
||||
$res = array(
|
||||
'url'=>$url, 'token'=>$acc['token'],
|
||||
'chsum'=>$chsum, 'size'=>$size,
|
||||
'filename'=>$fname
|
||||
);
|
||||
break;
|
||||
case "searchjob":
|
||||
$res = $pars;
|
||||
break;
|
||||
case "file":
|
||||
$res = array();
|
||||
break;
|
||||
default:
|
||||
return PEAR::raiseError("Archive::downloadOpen: NotImpl ($trtype)");
|
||||
}
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
switch ($trtype) {
|
||||
case "audioclip":
|
||||
case "metadata":
|
||||
case "playlist":
|
||||
case "playlistPkg":
|
||||
$title = $this->bsGetTitle(NULL, $gunid);
|
||||
break;
|
||||
case "searchjob":
|
||||
$title = 'searchjob';
|
||||
break;
|
||||
case "file":
|
||||
$title = 'regular file';
|
||||
break;
|
||||
default:
|
||||
}
|
||||
$res['title'] = $title;
|
||||
$res['trtype'] = $trtype;
|
||||
return $res;
|
||||
// global $CC_CONFIG;
|
||||
// switch ($trtype) {
|
||||
// case "unknown":
|
||||
// case "audioclip":
|
||||
// case "metadata":
|
||||
// case "playlist":
|
||||
// case "playlistPkg":
|
||||
// if (!isset($pars['gunid'])) {
|
||||
// return PEAR::raiseError("Archive::downloadOpen: gunid not set");
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// $gunid = $pars['gunid'];
|
||||
// // resolve trtype by object type:
|
||||
// if ( ($trtype == 'unknown') || ($trtype == 'playlistPkg') ) {
|
||||
// $media = StoredFile::RecallByGunid($gunid);
|
||||
// $trtype2 = $media->getType();
|
||||
// if (PEAR::isError($trtype2)) {
|
||||
// return $trtype2;
|
||||
// }
|
||||
// // required with content:
|
||||
// $trtype = ( ($trtype2 == 'playlist') && ($trtype == 'playlistPkg') ?
|
||||
// 'playlistPkg' : $trtype2);
|
||||
// //return PEAR::raiseError("Archive::downloadOpen: TT=$trtype TT2=$trtype2 G=$gunid");
|
||||
// }
|
||||
// switch ($trtype) {
|
||||
// case "audioclip":
|
||||
// $res = $this->downloadRawAudioDataOpen($sessid, $gunid);
|
||||
// break;
|
||||
// case "metadata":
|
||||
// $res = $this->downloadMetadataOpen($sessid, $gunid);
|
||||
// break;
|
||||
// case "playlist":
|
||||
// $res = $this->accessPlaylist($sessid, $gunid);
|
||||
// break;
|
||||
// case "playlistPkg":
|
||||
// $res = $this->bsExportPlaylistOpen($gunid);
|
||||
// if (PEAR::isError($res)) {
|
||||
// return $res;
|
||||
// }
|
||||
// $tmpn = tempnam($CC_CONFIG['transDir'], 'plExport_');
|
||||
// $plfpath = "$tmpn.lspl";
|
||||
// copy($res['fname'], $plfpath);
|
||||
// $res = $this->bsExportPlaylistClose($res['token']);
|
||||
// if (PEAR::isError($res)) {
|
||||
// return $res;
|
||||
// }
|
||||
// $fname = "transported_playlist.lspl";
|
||||
// $id = BasicStor::IdFromGunid($gunid);
|
||||
// $acc = BasicStor::bsAccess($plfpath, 'lspl', NULL, 'download');
|
||||
// if (PEAR::isError($acc)) {
|
||||
// return $acc;
|
||||
// }
|
||||
// $url = BasicStor::GetUrlPart()."access/".basename($acc['fname']);
|
||||
// $chsum = md5_file($plfpath);
|
||||
// $size = filesize($plfpath);
|
||||
// $res = array(
|
||||
// 'url'=>$url, 'token'=>$acc['token'],
|
||||
// 'chsum'=>$chsum, 'size'=>$size,
|
||||
// 'filename'=>$fname
|
||||
// );
|
||||
// break;
|
||||
// case "searchjob":
|
||||
// $res = $pars;
|
||||
// break;
|
||||
// case "file":
|
||||
// $res = array();
|
||||
// break;
|
||||
// default:
|
||||
// return PEAR::raiseError("Archive::downloadOpen: NotImpl ($trtype)");
|
||||
// }
|
||||
// if (PEAR::isError($res)) {
|
||||
// return $res;
|
||||
// }
|
||||
// switch ($trtype) {
|
||||
// case "audioclip":
|
||||
// case "metadata":
|
||||
// case "playlist":
|
||||
// case "playlistPkg":
|
||||
// $f = StoredFile::RecallByGunid($gunid);
|
||||
// $title = $f->getTitle();
|
||||
// break;
|
||||
// case "searchjob":
|
||||
// $title = 'searchjob';
|
||||
// break;
|
||||
// case "file":
|
||||
// $title = 'regular file';
|
||||
// break;
|
||||
// default:
|
||||
// }
|
||||
// $res['title'] = $title;
|
||||
// $res['trtype'] = $trtype;
|
||||
// return $res;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -73,65 +73,65 @@ class M3uPlaylist {
|
|||
*/
|
||||
function import(&$gb, $aPath, $rPath, &$gunids, $plid, $subjid=NULL)
|
||||
{
|
||||
$path = realpath("$aPath/$rPath");
|
||||
if (FALSE === $path) {
|
||||
return PEAR::raiseError(
|
||||
"M3uPlaylist::import: file doesn't exist ($aPath/$rPath)"
|
||||
);
|
||||
}
|
||||
$arr = M3uPlaylist::parse($path);
|
||||
if (PEAR::isError($arr)) {
|
||||
return $arr;
|
||||
}
|
||||
require_once("Playlist.php");
|
||||
$pl =& Playlist::create($gb, $plid, "imported_M3U");
|
||||
if (PEAR::isError($pl)) {
|
||||
return $pl;
|
||||
}
|
||||
$r = $pl->lock($gb, $subjid);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
foreach ($arr as $i => $it) {
|
||||
list($md, $uri) = preg_split("|\n|", $it);
|
||||
list($length, $title) = preg_split("|, *|", $md);
|
||||
// $gunid = StoredFile::CreateGunid();
|
||||
$gunid = ( isset($gunids[basename($uri)]) ? $gunids[basename($uri)] : NULL);
|
||||
$acId = BasicStor::IdFromGunid($gunid);
|
||||
if (PEAR::isError($acId)) {
|
||||
return $acId;
|
||||
}
|
||||
$length = Playlist::secondsToPlaylistTime($length);
|
||||
$offset = '???';
|
||||
if (preg_match("|\.([a-zA-Z0-9]+)$|", $uri, $va)) {
|
||||
switch (strtolower($ext = $va[1])) {
|
||||
case "lspl":
|
||||
case "xml":
|
||||
case "smil":
|
||||
case "m3u":
|
||||
$acId = $gb->bsImportPlaylistRaw($gunid,
|
||||
$aPath, $uri, $ext, $gunids, $subjid);
|
||||
if (PEAR::isError($acId)) {
|
||||
break;
|
||||
}
|
||||
//no break!
|
||||
default:
|
||||
if (is_null($gunid)) {
|
||||
return PEAR::raiseError(
|
||||
"M3uPlaylist::import: no gunid");
|
||||
}
|
||||
$r = $pl->addAudioClip($acId);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$r = $pl->unlock($gb);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
return $pl;
|
||||
// $path = realpath("$aPath/$rPath");
|
||||
// if (FALSE === $path) {
|
||||
// return PEAR::raiseError(
|
||||
// "M3uPlaylist::import: file doesn't exist ($aPath/$rPath)"
|
||||
// );
|
||||
// }
|
||||
// $arr = M3uPlaylist::parse($path);
|
||||
// if (PEAR::isError($arr)) {
|
||||
// return $arr;
|
||||
// }
|
||||
// require_once("Playlist.php");
|
||||
// $pl =& Playlist::create($gb, $plid, "imported_M3U");
|
||||
// if (PEAR::isError($pl)) {
|
||||
// return $pl;
|
||||
// }
|
||||
// $r = $pl->lock($gb, $subjid);
|
||||
// if (PEAR::isError($r)) {
|
||||
// return $r;
|
||||
// }
|
||||
// foreach ($arr as $i => $it) {
|
||||
// list($md, $uri) = preg_split("|\n|", $it);
|
||||
// list($length, $title) = preg_split("|, *|", $md);
|
||||
// // $gunid = StoredFile::CreateGunid();
|
||||
// $gunid = ( isset($gunids[basename($uri)]) ? $gunids[basename($uri)] : NULL);
|
||||
// $acId = BasicStor::IdFromGunid($gunid);
|
||||
// if (PEAR::isError($acId)) {
|
||||
// return $acId;
|
||||
// }
|
||||
// $length = Playlist::secondsToPlaylistTime($length);
|
||||
// $offset = '???';
|
||||
// if (preg_match("|\.([a-zA-Z0-9]+)$|", $uri, $va)) {
|
||||
// switch (strtolower($ext = $va[1])) {
|
||||
// case "lspl":
|
||||
// case "xml":
|
||||
// case "smil":
|
||||
// case "m3u":
|
||||
// $acId = $gb->bsImportPlaylistRaw($gunid,
|
||||
// $aPath, $uri, $ext, $gunids, $subjid);
|
||||
// if (PEAR::isError($acId)) {
|
||||
// break;
|
||||
// }
|
||||
// //no break!
|
||||
// default:
|
||||
// if (is_null($gunid)) {
|
||||
// return PEAR::raiseError(
|
||||
// "M3uPlaylist::import: no gunid");
|
||||
// }
|
||||
// $r = $pl->addAudioClip($acId);
|
||||
// if (PEAR::isError($r)) {
|
||||
// return $r;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// $r = $pl->unlock($gb);
|
||||
// if (PEAR::isError($r)) {
|
||||
// return $r;
|
||||
// }
|
||||
// return $pl;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -68,7 +68,7 @@ class Playlist {
|
|||
$storedPlaylist = new Playlist();
|
||||
$storedPlaylist->name = isset($p_values['filename']) ? $p_values['filename'] : date("H:i:s");
|
||||
$storedPlaylist->mtime = new DateTime("now");
|
||||
|
||||
|
||||
$pl = new CcPlaylist();
|
||||
$pl->setDbName($storedPlaylist->name);
|
||||
$pl->setDbState("incomplete");
|
||||
|
@ -79,20 +79,30 @@ class Playlist {
|
|||
$storedPlaylist->setState('ready');
|
||||
|
||||
return $storedPlaylist->id;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static function Delete($id) {
|
||||
$pl = CcPlaylistQuery::create()->findPK($id);
|
||||
$pl = CcPlaylistQuery::create()->findPK($id);
|
||||
if($pl === NULL)
|
||||
return FALSE;
|
||||
|
||||
$pl->delete();
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
$pl->delete();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Delete the file from all playlists.
|
||||
* @param string $p_fileId
|
||||
*/
|
||||
public static function DeleteFileFromAllPlaylists($p_fileId)
|
||||
{
|
||||
CcPlaylistcontentsQuery::create()->filterByDbFileId($p_fileId)->delete();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch instance of Playlist object.<br>
|
||||
*
|
||||
* @param string $id
|
||||
|
@ -126,10 +136,10 @@ class Playlist {
|
|||
public function setName($p_newname)
|
||||
{
|
||||
$pl = CcPlaylistQuery::create()->findPK($this->id);
|
||||
|
||||
|
||||
if($pl === NULL)
|
||||
return FALSE;
|
||||
|
||||
|
||||
$pl->setDbName($p_newname);
|
||||
$pl->setDbMtime(new DateTime("now"));
|
||||
$pl->save();
|
||||
|
@ -153,7 +163,7 @@ class Playlist {
|
|||
$pl = CcPlaylistQuery::create()->findPK($id);
|
||||
if($pl === NULL)
|
||||
return FALSE;
|
||||
|
||||
|
||||
return $pl->getDbName();
|
||||
}
|
||||
|
||||
|
@ -169,18 +179,18 @@ class Playlist {
|
|||
public function setState($p_state, $p_editedby=NULL)
|
||||
{
|
||||
$pl = CcPlaylistQuery::create()->findPK($this->id);
|
||||
|
||||
|
||||
if($pl === NULL)
|
||||
return FALSE;
|
||||
|
||||
return FALSE;
|
||||
|
||||
$pl->setDbState($p_state);
|
||||
$pl->setDbMtime(new DateTime("now"));
|
||||
|
||||
|
||||
$eb = (!is_null($p_editedby) ? $p_editedby : NULL);
|
||||
$pl->setDbEditedby($eb);
|
||||
|
||||
|
||||
$pl->save();
|
||||
|
||||
|
||||
$this->state = $p_state;
|
||||
$this->editedby = $p_editedby;
|
||||
return TRUE;
|
||||
|
@ -199,11 +209,11 @@ class Playlist {
|
|||
if (is_null($id)) {
|
||||
return $this->state;
|
||||
}
|
||||
|
||||
$pl = CcPlaylistQuery::create()->findPK($id);
|
||||
|
||||
$pl = CcPlaylistQuery::create()->findPK($id);
|
||||
if($pl === NULL)
|
||||
return FALSE;
|
||||
|
||||
|
||||
return $pl->getDbState();
|
||||
}
|
||||
|
||||
|
@ -237,15 +247,15 @@ class Playlist {
|
|||
if (is_null($id)) {
|
||||
return ($this->currentlyaccessing > 0);
|
||||
}
|
||||
|
||||
$pl = CcPlaylistQuery::create()->findPK($id);
|
||||
|
||||
$pl = CcPlaylistQuery::create()->findPK($id);
|
||||
if (is_null($pl)) {
|
||||
return PEAR::raiseError(
|
||||
"StoredPlaylist::isAccessed: invalid id ($id)",
|
||||
GBERR_FOBJNEX
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return ($pl->getDbCurrentlyaccessing() > 0);
|
||||
}
|
||||
|
||||
|
@ -309,7 +319,7 @@ class Playlist {
|
|||
}
|
||||
|
||||
private function getNextPos() {
|
||||
|
||||
|
||||
$res = CcPlaylistQuery::create()
|
||||
->findPK($this->id)
|
||||
->computeLastPosition();
|
||||
|
@ -325,24 +335,21 @@ class Playlist {
|
|||
* @return array
|
||||
*/
|
||||
public function getContents() {
|
||||
|
||||
$files;
|
||||
|
||||
$files = array();
|
||||
$rows = CcPlaylistcontentsQuery::create()
|
||||
->joinWith('CcFiles')
|
||||
->orderByDbPosition()
|
||||
->filterByDbPlaylistId($this->id)
|
||||
->find();
|
||||
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$files[] = $row->toArray(BasePeer::TYPE_PHPNAME, true, true);
|
||||
$files[] = $row->toArray(BasePeer::TYPE_PHPNAME, true, true);
|
||||
}
|
||||
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
public function getLength() {
|
||||
|
||||
$res = CcPlaylistQuery::create()
|
||||
->findPK($this->id)
|
||||
->computeLength();
|
||||
|
@ -429,9 +436,8 @@ class Playlist {
|
|||
*/
|
||||
public function addAudioClip($ac_id, $p_position=NULL, $p_fadeIn=NULL, $p_fadeOut=NULL, $p_clipLength=NULL, $p_cuein=NULL, $p_cueout=NULL)
|
||||
{
|
||||
|
||||
$_SESSION['debug'] = "in add";
|
||||
|
||||
|
||||
//get audio clip.
|
||||
$ac = StoredFile::Recall($ac_id);
|
||||
if (is_null($ac) || PEAR::isError($ac)) {
|
||||
|
@ -454,7 +460,7 @@ class Playlist {
|
|||
return $p_position;
|
||||
}
|
||||
|
||||
// insert default values if parameter was empty
|
||||
// insert default values if parameter was empty
|
||||
$p_cuein = !is_null($p_cuein) ? $p_cuein : '00:00:00.000000';
|
||||
$p_cueout = !is_null($p_cueout) ? $p_cueout : $acLen;
|
||||
|
||||
|
@ -466,7 +472,7 @@ class Playlist {
|
|||
$clipLengthS = $clipLengthS - ($acLengthS - self::playlistTimeToSeconds($p_cueout));
|
||||
}
|
||||
$p_clipLength = self::secondsToPlaylistTime($clipLengthS);
|
||||
|
||||
|
||||
$res = $this->insertPlaylistElement($this->id, $ac_id, $p_position, $p_clipLength, $p_cuein, $p_cueout, $p_fadeIn, $p_fadeOut);
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
|
@ -486,12 +492,12 @@ class Playlist {
|
|||
{
|
||||
if($pos < 0 || $pos >= $this->getNextPos())
|
||||
return FALSE;
|
||||
|
||||
|
||||
$row = CcPlaylistcontentsQuery::create()
|
||||
->filterByDbPlaylistId($this->id)
|
||||
->filterByDbPosition($pos)
|
||||
->findOne();
|
||||
|
||||
|
||||
if(is_null($row))
|
||||
return FALSE;
|
||||
|
||||
|
@ -539,21 +545,21 @@ class Playlist {
|
|||
public function changeFadeInfo($pos, $fadeIn, $fadeOut)
|
||||
{
|
||||
$errArray= array();
|
||||
|
||||
|
||||
if(is_null($pos) || $pos < 0 || $pos >= $this->getNextPos()) {
|
||||
$errArray["error"]="Invalid position.";
|
||||
return $errArray;
|
||||
}
|
||||
|
||||
|
||||
$row = CcPlaylistcontentsQuery::create()
|
||||
->filterByDbPlaylistId($this->id)
|
||||
->filterByDbPosition($pos)
|
||||
->findOne();
|
||||
|
||||
|
||||
$clipLength = $row->getDbCliplength();
|
||||
|
||||
|
||||
if(!is_null($fadeIn) && !is_null($fadeOut)) {
|
||||
|
||||
|
||||
if(Playlist::playlistTimeToSeconds($fadeIn) > Playlist::playlistTimeToSeconds($clipLength)) {
|
||||
$errArray["error"]="Fade In can't be larger than overall playlength.";
|
||||
return $errArray;
|
||||
|
@ -562,29 +568,29 @@ class Playlist {
|
|||
$errArray["error"]="Fade Out can't be larger than overall playlength.";
|
||||
return $errArray;
|
||||
}
|
||||
|
||||
|
||||
$row->setDbFadein($fadeIn);
|
||||
$row->setDbFadeout($fadeOut);
|
||||
}
|
||||
else if(!is_null($fadeIn)) {
|
||||
|
||||
|
||||
if(Playlist::playlistTimeToSeconds($fadeIn) > Playlist::playlistTimeToSeconds($clipLength)) {
|
||||
$errArray["error"]="Fade In can't be larger than overall playlength.";
|
||||
return $errArray;
|
||||
}
|
||||
|
||||
|
||||
$row->setDbFadein($fadeIn);
|
||||
}
|
||||
else if(!is_null($fadeOut)){
|
||||
|
||||
|
||||
if(Playlist::playlistTimeToSeconds($fadeOut) > Playlist::playlistTimeToSeconds($clipLength)) {
|
||||
$errArray["error"]="Fade Out can't be larger than overall playlength.";
|
||||
return $errArray;
|
||||
}
|
||||
|
||||
|
||||
$row->setDbFadeout($fadeOut);
|
||||
}
|
||||
|
||||
|
||||
$row->save();
|
||||
|
||||
return array("fadeIn"=>$fadeIn, "fadeOut"=>$fadeOut);
|
||||
|
@ -604,34 +610,34 @@ class Playlist {
|
|||
public function changeClipLength($pos, $cueIn, $cueOut)
|
||||
{
|
||||
$errArray= array();
|
||||
|
||||
|
||||
if(is_null($cueIn) && is_null($cueOut)) {
|
||||
$errArray["error"]="Cue in and cue out are null.";
|
||||
return $errArray;
|
||||
}
|
||||
|
||||
|
||||
if(is_null($pos) || $pos < 0 || $pos >= $this->getNextPos()) {
|
||||
$errArray["error"]="Invalid position.";
|
||||
return $errArray;
|
||||
}
|
||||
|
||||
|
||||
$row = CcPlaylistcontentsQuery::create()
|
||||
->joinWith(CcFiles)
|
||||
->filterByDbPlaylistId($this->id)
|
||||
->filterByDbPosition($pos)
|
||||
->findOne();
|
||||
|
||||
|
||||
$oldCueIn = $row->getDBCuein();
|
||||
$oldCueOut = $row->getDbCueout();
|
||||
$fadeIn = $row->getDbFadein();
|
||||
$fadeOut = $row->getDbFadeout();
|
||||
|
||||
|
||||
$file = $row->getCcFiles();
|
||||
$origLength = $file->getDbLength();
|
||||
|
||||
|
||||
|
||||
|
||||
if(!is_null($cueIn) && !is_null($cueOut)){
|
||||
|
||||
|
||||
if($cueOut === ""){
|
||||
$cueOut = $origLength;
|
||||
}
|
||||
|
@ -643,58 +649,58 @@ class Playlist {
|
|||
$errArray["error"] = "Can't set cue out to be greater than file length.";
|
||||
return $errArray;
|
||||
}
|
||||
|
||||
|
||||
$row->setDbCuein($cueIn);
|
||||
$row->setDbCueout($cueOut);
|
||||
$row->setDBCliplength(Playlist::secondsToPlaylistTime(Playlist::playlistTimeToSeconds($cueOut)
|
||||
$row->setDBCliplength(Playlist::secondsToPlaylistTime(Playlist::playlistTimeToSeconds($cueOut)
|
||||
- Playlist::playlistTimeToSeconds($cueIn)));
|
||||
|
||||
|
||||
}
|
||||
else if(!is_null($cueIn)) {
|
||||
|
||||
|
||||
if(Playlist::playlistTimeToSeconds($cueIn) > Playlist::playlistTimeToSeconds($oldCueOut)) {
|
||||
$errArray["error"] = "Can't set cue in to be larger than cue out.";
|
||||
return $errArray;
|
||||
}
|
||||
|
||||
|
||||
$row->setDbCuein($cueIn);
|
||||
$row->setDBCliplength(Playlist::secondsToPlaylistTime(Playlist::playlistTimeToSeconds($oldCueOut)
|
||||
$row->setDBCliplength(Playlist::secondsToPlaylistTime(Playlist::playlistTimeToSeconds($oldCueOut)
|
||||
- Playlist::playlistTimeToSeconds($cueIn)));
|
||||
}
|
||||
else if(!is_null($cueOut)) {
|
||||
|
||||
|
||||
if($cueOut === ""){
|
||||
$cueOut = $origLength;
|
||||
}
|
||||
|
||||
|
||||
if(Playlist::playlistTimeToSeconds($cueOut) < Playlist::playlistTimeToSeconds($oldCueIn)) {
|
||||
$errArray["error"] ="Can't set cue out to be smaller than cue in.";
|
||||
return $errArray;
|
||||
}
|
||||
|
||||
|
||||
if(Playlist::playlistTimeToSeconds($cueOut) > Playlist::playlistTimeToSeconds($origLength)){
|
||||
$errArray["error"] ="Can't set cue out to be greater than file length.";
|
||||
return $errArray;
|
||||
}
|
||||
|
||||
|
||||
$row->setDbCueout($cueOut);
|
||||
$row->setDBCliplength(Playlist::secondsToPlaylistTime(Playlist::playlistTimeToSeconds($cueOut)
|
||||
$row->setDBCliplength(Playlist::secondsToPlaylistTime(Playlist::playlistTimeToSeconds($cueOut)
|
||||
- Playlist::playlistTimeToSeconds($oldCueIn)));
|
||||
}
|
||||
|
||||
$cliplength = $row->getDbCliplength();
|
||||
|
||||
|
||||
if(Playlist::playlistTimeToSeconds($fadeIn) > Playlist::playlistTimeToSeconds($cliplength)){
|
||||
$fadeIn = $cliplength;
|
||||
|
||||
|
||||
$row->setDbFadein($fadeIn);
|
||||
}
|
||||
if(Playlist::playlistTimeToSeconds($fadeOut) > Playlist::playlistTimeToSeconds($cliplength)){
|
||||
$fadeOut = $cliplength;
|
||||
|
||||
|
||||
$row->setDbFadein($fadeOut);
|
||||
}
|
||||
|
||||
|
||||
$row->save();
|
||||
|
||||
return array("cliplength"=>$cliplength, "cueIn"=>$cueIn, "cueOut"=>$cueOut, "length"=>$this->getLength(),
|
||||
|
@ -724,12 +730,12 @@ class Playlist {
|
|||
public function getPLMetaData($category)
|
||||
{
|
||||
$cat = $this->categories[$category];
|
||||
|
||||
|
||||
if($cat === 'length') {
|
||||
return $this->getLength();
|
||||
}
|
||||
|
||||
$row = CcPlaylistQuery::create()->findPK($this->id);
|
||||
|
||||
$row = CcPlaylistQuery::create()->findPK($this->id);
|
||||
$method = 'get' . $cat;
|
||||
return $row->$method();
|
||||
}
|
||||
|
@ -738,7 +744,7 @@ class Playlist {
|
|||
{
|
||||
$cat = $this->categories[$category];
|
||||
|
||||
$row = CcPlaylistQuery::create()->findPK($this->id);
|
||||
$row = CcPlaylistQuery::create()->findPK($this->id);
|
||||
$method = 'set' . $cat;
|
||||
$row->$method($value);
|
||||
$row->save();
|
||||
|
@ -756,7 +762,7 @@ class Playlist {
|
|||
*/
|
||||
public function export()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -812,7 +818,7 @@ class Playlist {
|
|||
*/
|
||||
public function outputToSmil($toString=TRUE)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -827,7 +833,7 @@ class Playlist {
|
|||
*/
|
||||
public function outputToM3u($toString=TRUE)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -842,15 +848,15 @@ class Playlist {
|
|||
*/
|
||||
public function outputToRss($toString=TRUE)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get audioClip length and title
|
||||
*
|
||||
* @param int $acId
|
||||
* local id of audioClip inserted to playlist
|
||||
* @param StoredFile $p_media
|
||||
*
|
||||
* @return array with fields:
|
||||
* <ul>
|
||||
* <li>acGunid, string - audioClip gunid</li>
|
||||
|
@ -859,24 +865,24 @@ class Playlist {
|
|||
* <li>elType string - audioClip | playlist</li>
|
||||
* </ul>
|
||||
*/
|
||||
private function getAudioClipInfo($ac)
|
||||
private function getAudioClipInfo($p_media)
|
||||
{
|
||||
$ac_id = BasicStor::IdFromGunid($ac->gunid);
|
||||
$ac_id = $p_media->getId();
|
||||
|
||||
$r = $ac->md['dcterms:extent'];
|
||||
$r = $p_media->getMetadataValue('dcterms:extent');
|
||||
if (isset($r)) {
|
||||
$acLen = $r;
|
||||
} else {
|
||||
$acLen = '00:00:00.000000';
|
||||
}
|
||||
|
||||
$r = $ac->md['dc:title'];
|
||||
$r = $p_media->getMetadataValue('dc:title');
|
||||
if (isset($r)) {
|
||||
$acTit = $r;
|
||||
} else {
|
||||
$acTit = $acGunid;
|
||||
}
|
||||
$elType = BasicStor::GetObjType($ac_id);
|
||||
$elType = $p_media->getType();
|
||||
$trTbl = array('audioclip'=>'audioClip', 'webstream'=>'audioClip','playlist'=>'playlist');
|
||||
$elType = $trTbl[$elType];
|
||||
|
||||
|
@ -924,7 +930,7 @@ class Playlist {
|
|||
$fadeIn = '00:00:00.000';
|
||||
if(is_null($fadeOut))
|
||||
$fadeOut = '00:00:00.000';
|
||||
|
||||
|
||||
$row = new CcPlaylistcontents();
|
||||
$row->setDbPlaylistId($plId);
|
||||
$row->setDbFileId($fileId);
|
||||
|
@ -1385,21 +1391,21 @@ class PlaylistAudioClipExport
|
|||
|
||||
public static function OutputToRss(&$pl, $plac, $ind='')
|
||||
{
|
||||
$gunid = $plac['attrs']['id'];
|
||||
$ac = StoredFile::RecallByGunid($gunid);
|
||||
if (is_null($ac) || PEAR::isError($ac)) {
|
||||
return $ac;
|
||||
$id = $plac['attrs']['id'];
|
||||
$playlist = Playlist::Recall($id);
|
||||
if (is_null($playlist) || PEAR::isError($playlist)) {
|
||||
return $playlist;
|
||||
}
|
||||
$RADext = $ac->getFileExtension();
|
||||
$RADext = $playlist->getFileExtension();
|
||||
if (PEAR::isError($RADext)) {
|
||||
return $RADext;
|
||||
}
|
||||
$title = $pl->gb->bsGetMetadataValue($ac->getId(), 'dc:title');
|
||||
$desc = $pl->gb->bsGetMetadataValue($ac->getId(), 'dc:description');
|
||||
$title = $playlist->getName();
|
||||
$desc = $playlist->getPLMetaData("dc:description");
|
||||
return array(
|
||||
'type' => 'audioclip',
|
||||
'gunid' => $gunid,
|
||||
'src' => "http://XXX/YY/$gunid.$RADext",
|
||||
'gunid' => $id,
|
||||
'src' => "http://XXX/YY/$id.$RADext",
|
||||
'playlength' => $plac['attrs']['playlength'],
|
||||
'title' => $title,
|
||||
'desc' => $desc,
|
||||
|
|
|
@ -205,36 +205,36 @@ class Renderer
|
|||
*/
|
||||
function rnRender2StorageCore(&$gb, $token)
|
||||
{
|
||||
$r = BasicStor::bsRelease($token, 'render');
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
$realOgg = $r['realFname'];
|
||||
$owner = $r['owner'];
|
||||
$gunid = $r['gunid'];
|
||||
$fileName = 'rendered_playlist';
|
||||
$id = BasicStor::IdFromGunid($gunid);
|
||||
if (PEAR::isError($id)) {
|
||||
return $id;
|
||||
}
|
||||
$mdata = '';
|
||||
foreach (array('dc:title', 'dcterms:extent', 'dc:creator', 'dc:description') as $item) {
|
||||
$val = $gb->bsGetMetadataValue($id, $item);
|
||||
$mdata .= " <$item>$val</$item>\n";
|
||||
}
|
||||
$mdata = "<audioClip>\n <metadata>\n$mdata </metadata>\n</audioClip>\n";
|
||||
//$mdata = "<audioClip>\n <metadata>\n$mdata<dcterms:extent>0</dcterms:extent>\n</metadata>\n</audioClip>\n";
|
||||
$values = array(
|
||||
"filename" => $fileName,
|
||||
"filepath" => $realOgg,
|
||||
"metadata" => $mdata,
|
||||
"filetype" => "audioclip"
|
||||
);
|
||||
$storedFile = $gb->bsPutFile($values);
|
||||
if (PEAR::isError($storedFile)) {
|
||||
return $storedFile;
|
||||
}
|
||||
return array('gunid' => $storedFile->getGunid());
|
||||
// $r = BasicStor::bsRelease($token, 'render');
|
||||
// if (PEAR::isError($r)) {
|
||||
// return $r;
|
||||
// }
|
||||
// $realOgg = $r['realFname'];
|
||||
// $owner = $r['owner'];
|
||||
// $gunid = $r['gunid'];
|
||||
// $fileName = 'rendered_playlist';
|
||||
// $id = BasicStor::IdFromGunid($gunid);
|
||||
// if (PEAR::isError($id)) {
|
||||
// return $id;
|
||||
// }
|
||||
// $mdata = '';
|
||||
// foreach (array('dc:title', 'dcterms:extent', 'dc:creator', 'dc:description') as $item) {
|
||||
// $val = $gb->bsGetMetadataValue($id, $item);
|
||||
// $mdata .= " <$item>$val</$item>\n";
|
||||
// }
|
||||
// $mdata = "<audioClip>\n <metadata>\n$mdata </metadata>\n</audioClip>\n";
|
||||
// //$mdata = "<audioClip>\n <metadata>\n$mdata<dcterms:extent>0</dcterms:extent>\n</metadata>\n</audioClip>\n";
|
||||
// $values = array(
|
||||
// "filename" => $fileName,
|
||||
// "filepath" => $realOgg,
|
||||
// "metadata" => $mdata,
|
||||
// "filetype" => "audioclip"
|
||||
// );
|
||||
// $storedFile = $gb->bsPutFile($values);
|
||||
// if (PEAR::isError($storedFile)) {
|
||||
// return $storedFile;
|
||||
// }
|
||||
// return array('gunid' => $storedFile->getGunid());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -265,83 +265,83 @@ class Restore {
|
|||
* @return mixed
|
||||
* true if success or PEAR_error
|
||||
*/
|
||||
function addFileToStorage($file,$type,$gunid)
|
||||
{
|
||||
if ($this->loglevel=='debug') {
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." addFileToStorage - file:$file | type:$type | id:$gunid\n");
|
||||
}
|
||||
require_once("XmlParser.php");
|
||||
$tree = XmlParser::parse($file);
|
||||
$mediaFileLP = str_replace('.xml','',$file);
|
||||
$mediaFileLP = ($type=='audioClip' && is_file($mediaFileLP))?$mediaFileLP:'';
|
||||
$ex = $this->gb->existsFile($this->sessid,$gunid);
|
||||
if (PEAR::isError($ex)) {
|
||||
$this->addLogItem("-E- ".date("Ymd-H:i:s").
|
||||
" addFileToStorage - existsFile($gunid) ".
|
||||
"(".$ex->getMessage()."/".$ex->getUserInfo().")\n"
|
||||
);
|
||||
}
|
||||
if (!PEAR::isError($ex) && $ex) { // file is exists in storage server
|
||||
//replace it
|
||||
$id = BasicStor::IdFromGunid($gunid);
|
||||
$replace = $this->gb->replaceFile(
|
||||
$id, # id int, virt.file's local id
|
||||
$mediaFileLP, # mediaFileLP string, local path of media file
|
||||
$file, # mdataFileLP string, local path of metadata file
|
||||
$this->sessid); # sessid string, session id
|
||||
if (PEAR::isError($replace)) {
|
||||
$this->addLogItem("-E- ".date("Ymd-H:i:s").
|
||||
" addFileToStorage - replaceFile Error ".
|
||||
"(".$replace->getMessage()."/".$replace->getUserInfo().")\n"
|
||||
);
|
||||
file_put_contents($this->statusFile, 'fault|'.$replace->getMessage()."/".$replace->getUserInfo());
|
||||
return $replace;
|
||||
}
|
||||
#$this->addLogItem("replace it \n");
|
||||
} else {
|
||||
// add as new
|
||||
$name = $tree->children[0]->children[0]->content;
|
||||
if (empty($name)) {
|
||||
$name = $tree->attrs['title']->val;
|
||||
}
|
||||
if (empty($name)) {
|
||||
$name = '???';
|
||||
}
|
||||
if ($this->loglevel=='debug') {
|
||||
$this->addLogItem("-I- ".date("Ymd-H:i:s")." putFile\n".
|
||||
"$name, $mediaFileLP, $file, {$this->sessid}, $gunid, $type \n"
|
||||
);
|
||||
}
|
||||
$values = array(
|
||||
"filename" => $name,
|
||||
"filepath" => $mediaFileLP,
|
||||
"metadata" => $file,
|
||||
"gunid" => $gunid,
|
||||
"filetype" => $type
|
||||
);
|
||||
$put = $this->gb->putFile($values, $this->sessid);
|
||||
//$this->addLogItem("add as new \n");
|
||||
if (PEAR::isError($put)) {
|
||||
$this->addLogItem("-E- ".date("Ymd-H:i:s").
|
||||
" addFileToStorage - putFile Error ".
|
||||
"(".$put->getMessage()."/".$put->getUserInfo().")\n"
|
||||
."\n---\n".file_get_contents($file)."\n---\n"
|
||||
);
|
||||
file_put_contents($this->statusFile, 'fault|'.$put->getMessage()."/".$put->getUserInfo());
|
||||
//$this->addLogItem("Error Object: ".print_r($put,true)."\n");
|
||||
return $put;
|
||||
}
|
||||
}
|
||||
$ac = StoredFile::RecallByGunid($gunid);
|
||||
if (is_null($ac) || PEAR::isError($ac)) {
|
||||
return $ac;
|
||||
}
|
||||
$res = $ac->setState('ready');
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// function addFileToStorage($file,$type,$gunid)
|
||||
// {
|
||||
// if ($this->loglevel=='debug') {
|
||||
// $this->addLogItem("-I- ".date("Ymd-H:i:s")." addFileToStorage - file:$file | type:$type | id:$gunid\n");
|
||||
// }
|
||||
// require_once("XmlParser.php");
|
||||
// $tree = XmlParser::parse($file);
|
||||
// $mediaFileLP = str_replace('.xml','',$file);
|
||||
// $mediaFileLP = ($type=='audioClip' && is_file($mediaFileLP))?$mediaFileLP:'';
|
||||
// $ex = $this->gb->existsFile($this->sessid,$gunid);
|
||||
// if (PEAR::isError($ex)) {
|
||||
// $this->addLogItem("-E- ".date("Ymd-H:i:s").
|
||||
// " addFileToStorage - existsFile($gunid) ".
|
||||
// "(".$ex->getMessage()."/".$ex->getUserInfo().")\n"
|
||||
// );
|
||||
// }
|
||||
// if (!PEAR::isError($ex) && $ex) { // file is exists in storage server
|
||||
// //replace it
|
||||
// $id = BasicStor::IdFromGunid($gunid);
|
||||
// $replace = $this->gb->replaceFile(
|
||||
// $id, # id int, virt.file's local id
|
||||
// $mediaFileLP, # mediaFileLP string, local path of media file
|
||||
// $file, # mdataFileLP string, local path of metadata file
|
||||
// $this->sessid); # sessid string, session id
|
||||
// if (PEAR::isError($replace)) {
|
||||
// $this->addLogItem("-E- ".date("Ymd-H:i:s").
|
||||
// " addFileToStorage - replaceFile Error ".
|
||||
// "(".$replace->getMessage()."/".$replace->getUserInfo().")\n"
|
||||
// );
|
||||
// file_put_contents($this->statusFile, 'fault|'.$replace->getMessage()."/".$replace->getUserInfo());
|
||||
// return $replace;
|
||||
// }
|
||||
// #$this->addLogItem("replace it \n");
|
||||
// } else {
|
||||
// // add as new
|
||||
// $name = $tree->children[0]->children[0]->content;
|
||||
// if (empty($name)) {
|
||||
// $name = $tree->attrs['title']->val;
|
||||
// }
|
||||
// if (empty($name)) {
|
||||
// $name = '???';
|
||||
// }
|
||||
// if ($this->loglevel=='debug') {
|
||||
// $this->addLogItem("-I- ".date("Ymd-H:i:s")." putFile\n".
|
||||
// "$name, $mediaFileLP, $file, {$this->sessid}, $gunid, $type \n"
|
||||
// );
|
||||
// }
|
||||
// $values = array(
|
||||
// "filename" => $name,
|
||||
// "filepath" => $mediaFileLP,
|
||||
// "metadata" => $file,
|
||||
// "gunid" => $gunid,
|
||||
// "filetype" => $type
|
||||
// );
|
||||
// $put = $this->gb->putFile($values, $this->sessid);
|
||||
// //$this->addLogItem("add as new \n");
|
||||
// if (PEAR::isError($put)) {
|
||||
// $this->addLogItem("-E- ".date("Ymd-H:i:s").
|
||||
// " addFileToStorage - putFile Error ".
|
||||
// "(".$put->getMessage()."/".$put->getUserInfo().")\n"
|
||||
// ."\n---\n".file_get_contents($file)."\n---\n"
|
||||
// );
|
||||
// file_put_contents($this->statusFile, 'fault|'.$put->getMessage()."/".$put->getUserInfo());
|
||||
// //$this->addLogItem("Error Object: ".print_r($put,true)."\n");
|
||||
// return $put;
|
||||
// }
|
||||
// }
|
||||
// $ac = StoredFile::RecallByGunid($gunid);
|
||||
// if (is_null($ac) || PEAR::isError($ac)) {
|
||||
// return $ac;
|
||||
// }
|
||||
// $res = $ac->setState('ready');
|
||||
// if (PEAR::isError($res)) {
|
||||
// return $res;
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -170,7 +170,7 @@ class ScheduleGroup {
|
|||
}
|
||||
$sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"]
|
||||
." WHERE group_id = ".$this->groupId;
|
||||
|
||||
|
||||
return $CC_DBC->query($sql);
|
||||
}
|
||||
|
||||
|
@ -230,13 +230,32 @@ class Schedule {
|
|||
return ($count == '0');
|
||||
}
|
||||
|
||||
public function onAddTrackToPlaylist($playlistId, $audioTrackId) {
|
||||
// public function onAddTrackToPlaylist($playlistId, $audioTrackId) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public function onRemoveTrackFromPlaylist($playlistId, $audioTrackId) {
|
||||
//
|
||||
// }
|
||||
|
||||
/**
|
||||
* Return TRUE if file is going to be played in the future.
|
||||
*
|
||||
* @param string $p_fileId
|
||||
*/
|
||||
public function IsFileScheduledInTheFuture($p_fileId)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT COUNT(*) FROM ".$CC_CONFIG["scheduleTable"]
|
||||
." WHERE file_id = {$p_fileId} AND starts > NOW()";
|
||||
$count = $CC_DBC->GetOne($sql);
|
||||
if (is_numeric($count) && ($count != '0')) {
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
public function onRemoveTrackFromPlaylist($playlistId, $audioTrackId) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns array indexed numberically of:
|
||||
|
@ -326,7 +345,7 @@ class Schedule {
|
|||
$t = explode("-", $p_time);
|
||||
return $t[0]."-".$t[1]."-".$t[2]." ".$t[3].":".$t[4].":00";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Export the schedule in json formatted for pypo (the liquidsoap scheduler)
|
||||
*
|
||||
|
@ -337,29 +356,29 @@ class Schedule {
|
|||
*/
|
||||
public static function ExportRangeAsJson($p_fromDateTime, $p_toDateTime)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$range_start = Schedule::PypoTimeToCcTime($p_fromDateTime);
|
||||
$range_end = Schedule::PypoTimeToCcTime($p_toDateTime);
|
||||
$range_dt = array('start' => $range_start, 'end' => $range_end);
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$range_start = Schedule::PypoTimeToCcTime($p_fromDateTime);
|
||||
$range_end = Schedule::PypoTimeToCcTime($p_toDateTime);
|
||||
$range_dt = array('start' => $range_start, 'end' => $range_end);
|
||||
//var_dump($range_dt);
|
||||
|
||||
|
||||
// Scheduler wants everything in a playlist
|
||||
$data = Schedule::GetItems($range_start, $range_end, true);
|
||||
//echo "<pre>";var_dump($data);
|
||||
$playlists = array();
|
||||
$playlists = array();
|
||||
|
||||
if (is_array($data) && count($data) > 0)
|
||||
{
|
||||
foreach ($data as $dx)
|
||||
{
|
||||
// Is this the first item in the playlist?
|
||||
// Is this the first item in the playlist?
|
||||
$start = $dx['start'];
|
||||
// chop off subseconds
|
||||
$start = substr($start, 0, 19);
|
||||
|
||||
// Start time is the array key, needs to be in the format "YYYY-MM-DD-HH-mm-ss"
|
||||
$pkey = Schedule::CcTimeToPypoTime($start);
|
||||
$timestamp = strtotime($start);
|
||||
$start = substr($start, 0, 19);
|
||||
|
||||
// Start time is the array key, needs to be in the format "YYYY-MM-DD-HH-mm-ss"
|
||||
$pkey = Schedule::CcTimeToPypoTime($start);
|
||||
$timestamp = strtotime($start);
|
||||
$playlists[$pkey]['source'] = "PLAYLIST";
|
||||
$playlists[$pkey]['x_ident'] = $dx["playlist_id"];
|
||||
$playlists[$pkey]['subtype'] = '1'; // Just needs to be between 1 and 4 inclusive
|
||||
|
@ -372,16 +391,16 @@ class Schedule {
|
|||
|
||||
foreach ($playlists as &$playlist)
|
||||
{
|
||||
$scheduleGroup = new ScheduleGroup($playlist["schedule_id"]);
|
||||
$items = $scheduleGroup->getItems();
|
||||
$scheduleGroup = new ScheduleGroup($playlist["schedule_id"]);
|
||||
$items = $scheduleGroup->getItems();
|
||||
$medias = array();
|
||||
$playlist['subtype'] = '1';
|
||||
foreach ($items as $item)
|
||||
{
|
||||
$storedFile = StoredFile::Recall($item["file_id"]);
|
||||
$uri = $storedFile->getFileUrl();
|
||||
$storedFile = StoredFile::Recall($item["file_id"]);
|
||||
$uri = $storedFile->getFileUrl();
|
||||
$medias[] = array(
|
||||
'id' => $item["file_id"],
|
||||
'id' => $storedFile->getGunid(), //$item["file_id"],
|
||||
'uri' => $uri,
|
||||
'fade_in' => $item["fade_in"],
|
||||
'fade_out' => $item["fade_out"],
|
||||
|
|
|
@ -2,6 +2,53 @@
|
|||
require_once("Playlist.php");
|
||||
require_once(dirname(__FILE__)."/../3rd_party/getid3/var/getid3.php");
|
||||
require_once("BasicStor.php");
|
||||
require_once("Schedule.php");
|
||||
|
||||
$g_metadata_xml_to_db_mapping = array(
|
||||
"dc:format" => "format",
|
||||
"ls:bitrate" => "bit_rate",
|
||||
"ls:samplerate" => "sample_rate",
|
||||
"dcterms:extent" => "length",
|
||||
"dc:title" => "track_title",
|
||||
"dc:description" => "comments",
|
||||
"dc:type" => "genre",
|
||||
"dc:creator" => "artist_name",
|
||||
"dc:source" => "album_title",
|
||||
"ls:channels" => "channels",
|
||||
"ls:filename" => "name",
|
||||
"ls:year" => "year",
|
||||
"ls:url" => "url",
|
||||
"ls:track_num" => "track_number",
|
||||
"ls:mood" => "mood",
|
||||
"ls:bpm" => "bpm",
|
||||
"ls:disc_num" => "disc_number",
|
||||
"ls:rating" => "rating",
|
||||
"ls:encoded_by" => "encoded_by",
|
||||
"dc:publisher" => "label",
|
||||
"ls:composer" => "composer",
|
||||
"ls:encoder" => "encoder",
|
||||
"ls:crc" => "checksum",
|
||||
"ls:lyrics" => "lyrics",
|
||||
"ls:orchestra" => "orchestra",
|
||||
"ls:conductor" => "conductor",
|
||||
"ls:lyricist" => "lyricist",
|
||||
"ls:originallyricist" => "original_lyricist",
|
||||
"ls:radiostationname" => "radio_station_name",
|
||||
"ls:audiofileinfourl" => "info_url",
|
||||
"ls:artisturl" => "artist_url",
|
||||
"ls:audiosourceurl" => "audio_source_url",
|
||||
"ls:radiostationurl" => "radio_station_url",
|
||||
"ls:buycdurl" => "buy_this_url",
|
||||
"ls:isrcnumber" => "isrc_number",
|
||||
"ls:catalognumber" => "catalog_number",
|
||||
"ls:originalartist" => "original_artist",
|
||||
"dc:rights" => "copyright",
|
||||
"dcterms:temporal" => "report_datetime",
|
||||
"dcterms:spatial" => "report_location",
|
||||
"dcterms:entity" => "report_organization",
|
||||
"dc:subject" => "subject",
|
||||
"dc:contributor" => "contributor",
|
||||
"dc:language" => "language");
|
||||
|
||||
/**
|
||||
* Track numbers in metadata tags can come in many formats:
|
||||
|
@ -279,7 +326,7 @@ function camp_get_audio_metadata($p_filename, $p_testonly = false)
|
|||
*/
|
||||
class StoredFile {
|
||||
|
||||
// *** Variable stored in the database ***
|
||||
// *** Variables stored in the database ***
|
||||
|
||||
/**
|
||||
* @var int
|
||||
|
@ -314,7 +361,7 @@ class StoredFile {
|
|||
private $mime;
|
||||
|
||||
/**
|
||||
* Can be 'playlist' or 'audioclip'.
|
||||
* Can be 'audioclip'...others might be coming, like webstream.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
|
@ -381,18 +428,49 @@ class StoredFile {
|
|||
*/
|
||||
public function __construct($p_gunid=NULL)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
global $CC_DBC;
|
||||
$this->gunid = $p_gunid;
|
||||
if (empty($this->gunid)) {
|
||||
$this->gunid = StoredFile::generateGunid();
|
||||
}
|
||||
//$this->resDir = $this->_getResDir($this->gunid);
|
||||
//$this->filepath = "{$this->resDir}/{$this->gunid}";
|
||||
$this->exists = is_file($this->filepath) && is_readable($this->filepath);
|
||||
$this->md = $this->loadMetadata();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert XML name to database column name. Used for backwards compatibility
|
||||
* with old code.
|
||||
*
|
||||
* @param string $p_category
|
||||
* @return string|null
|
||||
*/
|
||||
public static function xmlCategoryToDbColumn($p_category)
|
||||
{
|
||||
global $g_metadata_xml_to_db_mapping;
|
||||
if (array_key_exists($p_category, $g_metadata_xml_to_db_mapping)) {
|
||||
return $g_metadata_xml_to_db_mapping[$p_category];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert database column name to XML name.
|
||||
*
|
||||
* @param string $p_dbColumn
|
||||
* @return string|null
|
||||
*/
|
||||
public static function dbColumnToXmlCatagory($p_dbColumn)
|
||||
{
|
||||
global $g_metadata_xml_to_db_mapping;
|
||||
$str = array_search($p_dbColumn, $g_metadata_xml_to_db_mapping);
|
||||
// make return value consistent with xmlCategoryToDbColumn()
|
||||
if ($str === FALSE) {
|
||||
$str = null;
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GUNID needs to be set before you call this function.
|
||||
*
|
||||
|
@ -417,7 +495,7 @@ class StoredFile {
|
|||
}
|
||||
$compatibilityData = array();
|
||||
foreach ($this->md as $key => $value) {
|
||||
if ($xmlName = BasicStor::dbColumnToXmlCatagory($key)) {
|
||||
if ($xmlName = StoredFile::dbColumnToXmlCatagory($key)) {
|
||||
$compatibilityData[$xmlName] = $value;
|
||||
}
|
||||
}
|
||||
|
@ -435,7 +513,7 @@ class StoredFile {
|
|||
global $CC_CONFIG, $CC_DBC;
|
||||
foreach ($p_values as $category => $value) {
|
||||
$escapedValue = pg_escape_string($value);
|
||||
$columnName = BasicStor::xmlCategoryToDbColumn($category);
|
||||
$columnName = StoredFile::xmlCategoryToDbColumn($category);
|
||||
if (!is_null($columnName)) {
|
||||
$sql = "UPDATE ".$CC_CONFIG["filesTable"]
|
||||
." SET $columnName='$escapedValue'"
|
||||
|
@ -529,7 +607,6 @@ class StoredFile {
|
|||
// Insert record into the database
|
||||
$escapedName = pg_escape_string($storedFile->name);
|
||||
$escapedFtype = pg_escape_string($storedFile->ftype);
|
||||
$CC_DBC->query("BEGIN");
|
||||
$sql = "INSERT INTO ".$CC_CONFIG['filesTable']
|
||||
."(id, name, gunid, mime, state, ftype, mtime, md5)"
|
||||
."VALUES ({$sqlId}, '{$escapedName}', "
|
||||
|
@ -537,6 +614,7 @@ class StoredFile {
|
|||
." '{$storedFile->mime}', 'incomplete', '$escapedFtype',"
|
||||
." now(), '{$storedFile->md5}')";
|
||||
//$_SESSION["debug"] .= "sql: ".$sql."<br>";
|
||||
//echo $sql."\n";
|
||||
$res = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($res)) {
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
|
@ -548,16 +626,15 @@ class StoredFile {
|
|||
$sql = "SELECT currval('".$CC_CONFIG["filesSequence"]."_seq')";
|
||||
$storedFile->id = $CC_DBC->getOne($sql);
|
||||
}
|
||||
BasicStor::bsSetMetadataBatch($storedFile->id, $metadata);
|
||||
$storedFile->setMetadataBatch($metadata);
|
||||
|
||||
// Save media file
|
||||
$res = $storedFile->addFile($p_values['filepath'], $p_copyMedia);
|
||||
|
||||
if (PEAR::isError($res)) {
|
||||
echo "StoredFile::Insert: ERROR adding file: '".$res->getMessage()."'\n";
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
echo "StoredFile::Insert -- addFile(): '".$res->getMessage()."'\n";
|
||||
return $res;
|
||||
}
|
||||
|
||||
if (empty($storedFile->mime)) {
|
||||
//echo "StoredFile::Insert: WARNING: Having to recalculate MIME value\n";
|
||||
$storedFile->setMime($storedFile->getMime());
|
||||
|
@ -566,13 +643,6 @@ class StoredFile {
|
|||
// Save state
|
||||
$storedFile->setState('ready');
|
||||
|
||||
// Commit changes
|
||||
$res = $CC_DBC->query("COMMIT");
|
||||
if (PEAR::isError($res)) {
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
return $res;
|
||||
}
|
||||
|
||||
// Recall the object to get all the proper values
|
||||
$storedFile = StoredFile::RecallByGunid($storedFile->gunid);
|
||||
return $storedFile;
|
||||
|
@ -583,21 +653,21 @@ class StoredFile {
|
|||
* Should be supplied with only ONE parameter, all the rest should
|
||||
* be NULL.
|
||||
*
|
||||
* @param int $p_oid
|
||||
* local object id in the tree
|
||||
* @param int $p_id
|
||||
* local id
|
||||
* @param string $p_gunid
|
||||
* global unique id of file
|
||||
* @param string $p_md5sum
|
||||
* MD5 sum of the file
|
||||
* MD5 sum of the file
|
||||
* @return StoredFile|Playlist|NULL
|
||||
* Return NULL if the object doesnt exist in the DB.
|
||||
* Return NULL if the object doesnt exist in the DB.
|
||||
*/
|
||||
public static function Recall($p_oid=null, $p_gunid=null, $p_md5sum=null)
|
||||
public static function Recall($p_id=null, $p_gunid=null, $p_md5sum=null)
|
||||
{
|
||||
global $CC_DBC;
|
||||
global $CC_CONFIG;
|
||||
if (!is_null($p_oid)) {
|
||||
$cond = "id='".intval($p_oid)."'";
|
||||
if (!is_null($p_id)) {
|
||||
$cond = "id='".intval($p_id)."'";
|
||||
} elseif (!is_null($p_gunid)) {
|
||||
$cond = "gunid='$p_gunid'";
|
||||
} elseif (!is_null($p_md5sum)) {
|
||||
|
@ -605,31 +675,16 @@ class StoredFile {
|
|||
} else {
|
||||
return null;
|
||||
}
|
||||
$sql = "SELECT id, gunid,"
|
||||
." name, mime, ftype, state, currentlyaccessing, editedby, "
|
||||
." mtime, md5"
|
||||
$sql = "SELECT *"
|
||||
." FROM ".$CC_CONFIG['filesTable']
|
||||
." WHERE $cond";
|
||||
//echo $sql;
|
||||
$row = $CC_DBC->getRow($sql);
|
||||
if (PEAR::isError($row)) {
|
||||
if (PEAR::isError($row) || is_null($row)) {
|
||||
return $row;
|
||||
}
|
||||
if (is_null($row)) {
|
||||
return null;
|
||||
}
|
||||
$gunid = $row['gunid'];
|
||||
if ($row['ftype'] == 'audioclip') {
|
||||
$storedFile = new StoredFile($gunid);
|
||||
} elseif ($row['ftype'] == 'playlist') {
|
||||
$storedFile = new Playlist($gunid);
|
||||
} else { // fallback
|
||||
$storedFile = new StoredFile($gunid);
|
||||
}
|
||||
$storedFile->loadMetadata();
|
||||
//$storedFile->gunidBigint = $row['gunid_bigint'];
|
||||
//$storedFile->md->gunidBigint = $row['gunid_bigint'];
|
||||
$storedFile->md["gunid"] = $row['gunid'];
|
||||
$storedFile = new StoredFile($gunid);
|
||||
$storedFile->id = $row['id'];
|
||||
$storedFile->name = $row['name'];
|
||||
$storedFile->mime = $row['mime'];
|
||||
|
@ -639,6 +694,7 @@ class StoredFile {
|
|||
$storedFile->editedby = $row['editedby'];
|
||||
$storedFile->mtime = $row['mtime'];
|
||||
$storedFile->md5 = $row['md5'];
|
||||
$storedFile->filepath = $row['filepath'];
|
||||
$storedFile->exists = TRUE;
|
||||
$storedFile->setFormat($row['ftype']);
|
||||
return $storedFile;
|
||||
|
@ -757,6 +813,7 @@ class StoredFile {
|
|||
$sql = "UPDATE ".$CC_CONFIG["filesTable"]
|
||||
." SET filepath='{$sqlPath}'"
|
||||
." WHERE id={$this->id}";
|
||||
//echo $sql."\n";
|
||||
$res = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
|
@ -803,25 +860,52 @@ class StoredFile {
|
|||
|
||||
|
||||
/**
|
||||
* Delete media file from filesystem
|
||||
* Delete media file from filesystem.
|
||||
* You cant delete a file if it is being accessed.
|
||||
* You cant delete a file if it is scheduled to be played in the future.
|
||||
* The file will be removed from all playlists it is a part of.
|
||||
*
|
||||
* @return boolean|PEAR_Error
|
||||
*/
|
||||
public function deleteFile()
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
if (!$this->exists) {
|
||||
return FALSE;
|
||||
}
|
||||
if (!file_exists($this->filepath) || @unlink($this->filepath)) {
|
||||
$this->exists = FALSE;
|
||||
return TRUE;
|
||||
} else {
|
||||
return PEAR::raiseError(
|
||||
"StoredFile::deleteFile: unlink failed ({$this->filepath})",
|
||||
GBERR_FILEIO
|
||||
if ($this->isAccessed()) {
|
||||
return PEAR::raiseError(
|
||||
'Cannot delete a file that is currently accessed.'
|
||||
);
|
||||
}
|
||||
return $this->exists;
|
||||
|
||||
// Check if the file is scheduled to be played in the future
|
||||
if (Schedule::IsFileScheduledInTheFuture($this->id)) {
|
||||
return PEAR::raiseError(
|
||||
'Cannot delete a file that is scheduled in the future.'
|
||||
);
|
||||
}
|
||||
|
||||
// Delete it from all playlists
|
||||
//Playlist::DeleteFileFromAllPlaylists($this->id);
|
||||
|
||||
// Only delete the file from filesystem if it has been copied to the
|
||||
// storage directory. (i.e. dont delete linked files)
|
||||
if (substr($this->filepath, 0, strlen($CC_CONFIG["storageDir"])) == $CC_CONFIG["storageDir"]) {
|
||||
// Delete the file
|
||||
if (!file_exists($this->filepath) || @unlink($this->filepath)) {
|
||||
$this->exists = FALSE;
|
||||
return TRUE;
|
||||
} else {
|
||||
return PEAR::raiseError(
|
||||
"StoredFile::deleteFile: unlink failed ({$this->filepath})",
|
||||
GBERR_FILEIO
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$this->exists = FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -858,7 +942,7 @@ class StoredFile {
|
|||
"id" => $p_nid,
|
||||
"filename" => $p_src->name,
|
||||
"filepath" => $p_src->getRealFileName(),
|
||||
"filetype" => BasicStor::GetType($p_src->gunid)
|
||||
"filetype" => $p_src->getType()
|
||||
);
|
||||
$storedFile = StoredFile::Insert($values);
|
||||
if (PEAR::isError($storedFile)) {
|
||||
|
@ -884,42 +968,42 @@ class StoredFile {
|
|||
* 'file'|'string'
|
||||
* @return TRUE|PEAR_Error
|
||||
*/
|
||||
public function replace($p_oid, $p_name, $p_localFilePath='', $p_metadata='',
|
||||
$p_mdataLoc='file')
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$CC_DBC->query("BEGIN");
|
||||
$res = $this->setName($p_name);
|
||||
if (PEAR::isError($res)) {
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
return $res;
|
||||
}
|
||||
if ($p_localFilePath != '') {
|
||||
$res = $this->setRawMediaData($p_localFilePath);
|
||||
} else {
|
||||
$res = $this->deleteFile();
|
||||
}
|
||||
if (PEAR::isError($res)) {
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
return $res;
|
||||
}
|
||||
if ($p_metadata != '') {
|
||||
$res = $this->setMetadata($p_metadata, $p_mdataLoc);
|
||||
} else {
|
||||
// $res = $this->md->delete();
|
||||
$res = $this->clearMetadata();
|
||||
}
|
||||
if (PEAR::isError($res)) {
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
return $res;
|
||||
}
|
||||
$res = $CC_DBC->query("COMMIT");
|
||||
if (PEAR::isError($res)) {
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
return $res;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
// public function replace($p_oid, $p_name, $p_localFilePath='', $p_metadata='',
|
||||
// $p_mdataLoc='file')
|
||||
// {
|
||||
// global $CC_CONFIG, $CC_DBC;
|
||||
// $CC_DBC->query("BEGIN");
|
||||
// $res = $this->setName($p_name);
|
||||
// if (PEAR::isError($res)) {
|
||||
// $CC_DBC->query("ROLLBACK");
|
||||
// return $res;
|
||||
// }
|
||||
// if ($p_localFilePath != '') {
|
||||
// $res = $this->setRawMediaData($p_localFilePath);
|
||||
// } else {
|
||||
// $res = $this->deleteFile();
|
||||
// }
|
||||
// if (PEAR::isError($res)) {
|
||||
// $CC_DBC->query("ROLLBACK");
|
||||
// return $res;
|
||||
// }
|
||||
// if ($p_metadata != '') {
|
||||
// $res = $this->setMetadata($p_metadata, $p_mdataLoc);
|
||||
// } else {
|
||||
//// $res = $this->md->delete();
|
||||
// $res = $this->clearMetadata();
|
||||
// }
|
||||
// if (PEAR::isError($res)) {
|
||||
// $CC_DBC->query("ROLLBACK");
|
||||
// return $res;
|
||||
// }
|
||||
// $res = $CC_DBC->query("COMMIT");
|
||||
// if (PEAR::isError($res)) {
|
||||
// $CC_DBC->query("ROLLBACK");
|
||||
// return $res;
|
||||
// }
|
||||
// return TRUE;
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
|
@ -989,6 +1073,17 @@ class StoredFile {
|
|||
}
|
||||
|
||||
|
||||
private static function NormalizeExtent($v)
|
||||
{
|
||||
if (!preg_match("|^\d{2}:\d{2}:\d{2}.\d{6}$|", $v)) {
|
||||
$s = Playlist::playlistTimeToSeconds($v);
|
||||
$t = Playlist::secondsToPlaylistTime($s);
|
||||
return $t;
|
||||
}
|
||||
return $v;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Replace metadata with new XML file
|
||||
*
|
||||
|
@ -1002,25 +1097,110 @@ class StoredFile {
|
|||
* (NULL = no validation)
|
||||
* @return boolean
|
||||
*/
|
||||
public function setMetadata($p_metadata, $p_mdataLoc='file', $p_format=NULL)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$CC_DBC->query("BEGIN");
|
||||
$res = $this->md->replace($p_metadata, $p_mdataLoc, $p_format);
|
||||
if (PEAR::isError($res)) {
|
||||
$CC_DBC->query("ROLLBACK");
|
||||
return $res;
|
||||
}
|
||||
// $r = $this->md->regenerateXmlFile();
|
||||
// if (PEAR::isError($r)) {
|
||||
// public function setMetadata($p_metadata, $p_mdataLoc='file', $p_format=NULL)
|
||||
// {
|
||||
// global $CC_CONFIG, $CC_DBC;
|
||||
// $CC_DBC->query("BEGIN");
|
||||
// $res = $this->md->replace($p_metadata, $p_mdataLoc, $p_format);
|
||||
// if (PEAR::isError($res)) {
|
||||
// $CC_DBC->query("ROLLBACK");
|
||||
// return $r;
|
||||
// return $res;
|
||||
// }
|
||||
$res = $CC_DBC->query("COMMIT");
|
||||
// $res = $CC_DBC->query("COMMIT");
|
||||
// if (PEAR::isError($res)) {
|
||||
// return $res;
|
||||
// }
|
||||
// return TRUE;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Set metadata element value
|
||||
*
|
||||
* @param string $category
|
||||
* Metadata element identification (e.g. dc:title)
|
||||
* @param string $value
|
||||
* value to store, if NULL then delete record
|
||||
* @return boolean
|
||||
*/
|
||||
public function setMetadataValue($p_category, $p_value)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if (!is_string($p_category) || is_array($p_value)) {
|
||||
return FALSE;
|
||||
}
|
||||
if ($p_category == 'dcterms:extent') {
|
||||
$p_value = StoredFile::NormalizeExtent($p_value);
|
||||
}
|
||||
$columnName = StoredFile::xmlCategoryToDbColumn($p_category); // Get column name
|
||||
|
||||
if (!is_null($columnName)) {
|
||||
$escapedValue = pg_escape_string($p_value);
|
||||
$sql = "UPDATE ".$CC_CONFIG["filesTable"]
|
||||
." SET $columnName='$escapedValue'"
|
||||
." WHERE id=$p_id";
|
||||
//var_dump($sql);
|
||||
$res = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($res)) {
|
||||
return $res;
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set metadata values in 'batch' mode
|
||||
*
|
||||
* @param array $values
|
||||
* array of key/value pairs
|
||||
* (e.g. 'dc:title'=>'New title')
|
||||
* @return boolean
|
||||
*/
|
||||
public function setMetadataBatch($values)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if (!is_array($values)) {
|
||||
$values = array($values);
|
||||
}
|
||||
if (count($values) == 0) {
|
||||
return true;
|
||||
}
|
||||
foreach ($values as $category => $oneValue) {
|
||||
$columnName = StoredFile::xmlCategoryToDbColumn($category);
|
||||
if (!is_null($columnName)) {
|
||||
if ($category == 'dcterms:extent') {
|
||||
$oneValue = StoredFile::NormalizeExtent($oneValue);
|
||||
}
|
||||
// Since track_number is an integer, you cannot set
|
||||
// it to be the empty string, so we NULL it instead.
|
||||
if ($columnName == 'track_number' && empty($oneValue)) {
|
||||
$sqlPart = "$columnName = NULL";
|
||||
} elseif (($columnName == 'length') && (strlen($oneValue) > 8)) {
|
||||
// Postgres doesnt like it if you try to store really large hour
|
||||
// values. TODO: We need to fix the underlying problem of getting the
|
||||
// right values.
|
||||
$parts = explode(':', $oneValue);
|
||||
$hour = intval($parts[0]);
|
||||
if ($hour > 24) {
|
||||
continue;
|
||||
} else {
|
||||
$sqlPart = "$columnName = '$oneValue'";
|
||||
}
|
||||
} else {
|
||||
$escapedValue = pg_escape_string($oneValue);
|
||||
$sqlPart = "$columnName = '$escapedValue'";
|
||||
}
|
||||
$sqlValues[] = $sqlPart;
|
||||
}
|
||||
}
|
||||
if (count($sqlValues)==0) {
|
||||
return TRUE;
|
||||
}
|
||||
$sql = "UPDATE ".$CC_CONFIG["filesTable"]
|
||||
." SET ".join(",", $sqlValues)
|
||||
." WHERE id=$id";
|
||||
$CC_DBC->query($sql);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1034,6 +1214,20 @@ class StoredFile {
|
|||
return $this->md;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get one metadata value.
|
||||
*
|
||||
* @param string $p_name
|
||||
* @return string
|
||||
*/
|
||||
public function getMetadataValue($p_name)
|
||||
{
|
||||
if (isset($this->md[$p_name])){
|
||||
return $this->md[$p_name];
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename stored virtual file
|
||||
|
@ -1135,7 +1329,7 @@ class StoredFile {
|
|||
* Delete stored virtual file
|
||||
*
|
||||
* @param boolean $p_deleteFile
|
||||
* @see MetaData
|
||||
*
|
||||
* @return TRUE|PEAR_Error
|
||||
*/
|
||||
public function delete($p_deleteFile = true)
|
||||
|
@ -1147,10 +1341,6 @@ class StoredFile {
|
|||
return $res;
|
||||
}
|
||||
}
|
||||
// $res = $this->md->delete();
|
||||
// if (PEAR::isError($res)) {
|
||||
// return $res;
|
||||
// }
|
||||
$sql = "SELECT to_hex(token)as token, ext "
|
||||
." FROM ".$CC_CONFIG['accessTable']
|
||||
." WHERE gunid='{$this->gunid}'";
|
||||
|
@ -1178,27 +1368,25 @@ class StoredFile {
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns gunIds of the playlists the stored file is in.
|
||||
* TODO update this to work with new tables.
|
||||
*/
|
||||
|
||||
/*
|
||||
/**
|
||||
* Returns an array of playlist objects that this file is a part of.
|
||||
* @return array
|
||||
*/
|
||||
public function getPlaylists() {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
|
||||
$_SESSION['delete'] = "gunid: " . $this->gunid;
|
||||
|
||||
$sql = "SELECT gunid "
|
||||
." FROM ".$CC_CONFIG['mdataTable']
|
||||
." WHERE object='{$this->gunid}'";
|
||||
|
||||
$_SESSION['delete'] = $sql;
|
||||
$playlists = $CC_DBC->getAll($sql);
|
||||
|
||||
$sql = "SELECT playlist_id "
|
||||
." FROM ".$CC_CONFIG['playistTable']
|
||||
." WHERE file_id='{$this->id}'";
|
||||
$ids = $CC_DBC->getAll($sql);
|
||||
$playlists = array();
|
||||
if (is_array($ids) && count($ids) > 0) {
|
||||
foreach ($ids as $id) {
|
||||
$playlists[] = Playlist::Recall($id);
|
||||
}
|
||||
}
|
||||
return $playlists;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
|
@ -1314,7 +1502,7 @@ class StoredFile {
|
|||
if (is_null($indb)) {
|
||||
return FALSE;
|
||||
}
|
||||
if (BasicStor::GetType($this->gunid) == 'audioclip') {
|
||||
if ($this->ftype == 'audioclip') {
|
||||
return $this->existsFile();
|
||||
}
|
||||
return TRUE;
|
||||
|
@ -1394,7 +1582,7 @@ class StoredFile {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
function getMime()
|
||||
public function getMime()
|
||||
{
|
||||
$a = $this->analyzeFile();
|
||||
if (PEAR::isError($a)) {
|
||||
|
@ -1407,6 +1595,20 @@ class StoredFile {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convenience function.
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->md["title"];
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return $this->ftype;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get storage-internal file state
|
||||
*
|
||||
|
@ -1482,8 +1684,8 @@ class StoredFile {
|
|||
public function getFileUrl()
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
return "http://".$CC_CONFIG["storageUrlHost"].$CC_CONFIG["storageUrlPath"]
|
||||
."/stor/".substr($this->gunid, 0, 3)."/{$this->gunid}";
|
||||
return "http://".$CC_CONFIG["storageUrlHost"]
|
||||
."api/get_media.php?file_id={$this->gunid}";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1417,7 +1417,7 @@ class Transport
|
|||
"gunid" => $row['gunid'],
|
||||
"filetype" => "audioclip"
|
||||
);
|
||||
$storedFile = $this->gb->bsPutFile($values);
|
||||
$storedFile = StoredFile::Insert($values);
|
||||
if (PEAR::isError($storedFile)) {
|
||||
$mdtrec->setLock(FALSE);
|
||||
return $storedFile;
|
||||
|
@ -1473,7 +1473,7 @@ class Transport
|
|||
"gunid" => $row['gunid'],
|
||||
"filetype" => "playlist"
|
||||
);
|
||||
$storedFile = $this->gb->bsPutFile($values);
|
||||
$storedFile = StoredFile::Insert($values);
|
||||
if (PEAR::isError($storedFile)) {
|
||||
return $storedFile;
|
||||
}
|
||||
|
|
|
@ -1,23 +1,25 @@
|
|||
<?php
|
||||
$path = dirname(__FILE__).'/../../3rd_party/php/pear';
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
|
||||
$WHITE_SCREEN_OF_DEATH = true;
|
||||
|
||||
require_once(dirname(__FILE__).'/../../conf.php');
|
||||
require_once('DB.php');
|
||||
require_once('PHPUnit.php');
|
||||
//require_once 'BasicStorTests.php';
|
||||
require_once 'StoredFileTests.php';
|
||||
//require_once 'SchedulerTests.php';
|
||||
//require_once 'SchedulerExportTests.php';
|
||||
require_once 'PlayListTests.php';
|
||||
require_once 'PlaylistTests.php';
|
||||
|
||||
$suite = new PHPUnit_TestSuite("PlayListTests");
|
||||
//$suite = new PHPUnit_TestSuite("BasicStorTest");
|
||||
//$suite = new PHPUnit_TestSuite("PlayListTests");
|
||||
$suite = new PHPUnit_TestSuite("StoredFileTest");
|
||||
//$suite = new PHPUnit_TestSuite("SchedulerTests");
|
||||
//$suite->addTestSuite("BasicStorTest");
|
||||
//$suite->addTestSuite("SchedulerTests");
|
||||
//$suite->addTestSuite("SchedulerExportTests");
|
||||
//$suite->addTestSuite("PlayListTests");
|
||||
$suite->addTestSuite("PlaylistTests");
|
||||
$result = PHPUnit::run($suite);
|
||||
|
||||
echo $result->toString();
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -16,8 +16,10 @@ require_once('PHPUnit.php');
|
|||
|
||||
require_once(dirname(__FILE__).'/../../conf.php');
|
||||
require_once(dirname(__FILE__).'/../GreenBox.php');
|
||||
echo "got here\n";
|
||||
require_once(dirname(__FILE__).'/../Playlist.php');
|
||||
|
||||
|
||||
$dsn = $CC_CONFIG['dsn'];
|
||||
$CC_DBC = DB::connect($dsn, TRUE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
|
@ -26,7 +28,7 @@ if (PEAR::isError($CC_DBC)) {
|
|||
}
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
class PlayListTests extends PHPUnit_TestCase {
|
||||
class PlaylistTests extends PHPUnit_TestCase {
|
||||
|
||||
private $greenbox;
|
||||
|
||||
|
@ -37,121 +39,133 @@ class PlayListTests extends PHPUnit_TestCase {
|
|||
function setup() {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$this->greenbox = new GreenBox();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
function testGBCreatePlaylist() {
|
||||
|
||||
|
||||
$pl = new Playlist();
|
||||
$pl_id = $pl->create("create");
|
||||
|
||||
|
||||
if (PEAR::isError($pl_id)) {
|
||||
$this->fail("problems creating playlist.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function testGBLock() {
|
||||
$pl = new Playlist();
|
||||
$pl_id = $pl->create("lock test");
|
||||
|
||||
|
||||
$sessid = Alib::Login('root', 'q');
|
||||
|
||||
|
||||
$res = $this->greenbox->lockPlaylistForEdit($pl_id, $sessid);
|
||||
|
||||
|
||||
if($res !== TRUE) {
|
||||
$this->fail("problems locking playlist for editing.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function testGBUnLock() {
|
||||
$pl = new Playlist();
|
||||
$pl_id = $pl->create("unlock test");
|
||||
|
||||
|
||||
$sessid = Alib::Login('root', 'q');
|
||||
|
||||
|
||||
$this->greenbox->lockPlaylistForEdit($pl_id, $sessid);
|
||||
$res = $this->greenbox->releaseLockedPlaylist($pl_id, $sessid);
|
||||
|
||||
|
||||
if($res !== TRUE) {
|
||||
$this->fail("problems unlocking playlist.");
|
||||
$this->fail("problems unlocking playlist.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
function testGBSetPLMetaData() {
|
||||
$pl = new Playlist();
|
||||
$pl_id = $pl->create("set meta data test");
|
||||
|
||||
|
||||
$res = $this->greenbox->setPLMetadataValue($pl_id, "dc:title", "A Title");
|
||||
|
||||
|
||||
if($res !== TRUE) {
|
||||
$this->fail("problems setting playlist metadata.");
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
function testGBGetPLMetaData() {
|
||||
$pl = new Playlist();
|
||||
$name = "Testing";
|
||||
$pl_id = $pl->create($name);
|
||||
|
||||
|
||||
$res = $this->greenbox->getPLMetadataValue($pl_id, "dc:title");
|
||||
|
||||
|
||||
if($res !== $name) {
|
||||
$this->fail("problems getting playlist metadata.");
|
||||
$this->fail("problems getting playlist metadata.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
function testAddAudioClip() {
|
||||
// Add a file
|
||||
$values = array("filepath" => dirname(__FILE__)."/test10001.mp3");
|
||||
$this->storedFile = StoredFile::Insert($values, false);
|
||||
|
||||
// Add a file
|
||||
$values = array("filepath" => dirname(__FILE__)."/test10002.mp3");
|
||||
$this->storedFile2 = StoredFile::Insert($values, false);
|
||||
|
||||
$pl = new Playlist();
|
||||
$pl_id = $pl->create("Add");
|
||||
|
||||
$res = $this->greenbox->addAudioClipToPlaylist($pl_id, '1');
|
||||
|
||||
$pl_id = $pl->create("Playlist Unit Test ". uniqid());
|
||||
$res = $pl->addAudioClip($this->storedFile->getId());
|
||||
if($res !== TRUE) {
|
||||
$this->fail("problems adding audioclip to playlist.");
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
$res = $pl->addAudioClip($this->storedFile2->getId());
|
||||
if($res !== TRUE) {
|
||||
$this->fail("problems adding audioclip 2 to playlist.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
function testMoveAudioClip() {
|
||||
$pl = new Playlist();
|
||||
$pl_id = $pl->create("Move");
|
||||
|
||||
|
||||
$this->greenbox->addAudioClipToPlaylist($pl_id, '1');
|
||||
$this->greenbox->addAudioClipToPlaylist($pl_id, '2');
|
||||
|
||||
|
||||
$res = $this->greenbox->moveAudioClipInPlaylist($pl_id, 0, 1);
|
||||
|
||||
|
||||
if($res !== TRUE) {
|
||||
$this->fail("problems moving audioclip in playlist.");
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function testDeleteAudioClip() {
|
||||
$pl = new Playlist();
|
||||
$pl_id = $pl->create("Delete");
|
||||
|
||||
|
||||
$this->greenbox->addAudioClipToPlaylist($pl_id, '1');
|
||||
$res = $this->greenbox->delAudioClipFromPlaylist($pl_id, 0);
|
||||
|
||||
|
||||
if($res !== TRUE) {
|
||||
$this->fail("problems deleting audioclip from playlist.");
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
|
@ -60,7 +60,7 @@ class SchedulerTests extends PHPUnit_TestCase {
|
|||
function testAddAndRemovePlaylist() {
|
||||
// Create a playlist
|
||||
$playlist = new Playlist();
|
||||
$playlist->create("Scheduler Unit Test");
|
||||
$playlist->create("Scheduler Unit Test ".uniqid());
|
||||
$result = $playlist->addAudioClip($this->storedFile->getId());
|
||||
$result = $playlist->addAudioClip($this->storedFile2->getId());
|
||||
$result = $playlist->addAudioClip($this->storedFile2->getId());
|
||||
|
@ -76,7 +76,7 @@ class SchedulerTests extends PHPUnit_TestCase {
|
|||
$this->fail("Wrong number of items added.");
|
||||
}
|
||||
$items = $group->getItems();
|
||||
if ($items[1]["starts"] != "2010-11-11 01:30:34.231") {
|
||||
if (!is_array($items) || ($items[1]["starts"] != "2010-11-11 01:30:34.231")) {
|
||||
$this->fail("Wrong start time for 2nd item.");
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
require_once(dirname(__FILE__).'/../StoredFile.php');
|
||||
require_once(dirname(__FILE__).'/../BasicStor.php');
|
||||
require_once(dirname(__FILE__).'/../GreenBox.php');
|
||||
//require_once(dirname(__FILE__).'/../BasicStor.php');
|
||||
//require_once(dirname(__FILE__).'/../GreenBox.php');
|
||||
|
||||
$dsn = $CC_CONFIG['dsn'];
|
||||
$CC_DBC = DB::connect($dsn, TRUE);
|
||||
|
@ -11,16 +11,13 @@ if (PEAR::isError($CC_DBC)) {
|
|||
}
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
class BasicStorTest extends PHPUnit_TestCase {
|
||||
class StoredFileTest extends PHPUnit_TestCase {
|
||||
|
||||
private $greenbox;
|
||||
|
||||
// function __construct($name) {
|
||||
// parent::__construct($name);
|
||||
// }
|
||||
function __construct($name) {
|
||||
parent::__construct($name);
|
||||
}
|
||||
|
||||
function setup() {
|
||||
$this->greenbox = new GreenBox();
|
||||
}
|
||||
|
||||
function testGetAudioMetadata() {
|
||||
|
@ -53,11 +50,13 @@ class BasicStorTest extends PHPUnit_TestCase {
|
|||
}
|
||||
|
||||
$values = array("filepath" => $filePath);
|
||||
$storedFile = $this->greenbox->bsPutFile($values, false);
|
||||
// Insert and link to file, dont copy it
|
||||
$storedFile = StoredFile::Insert($values, false);
|
||||
if (PEAR::isError($storedFile)) {
|
||||
$this->fail("Failed to create StoredFile: ".$storedFile->getMessage());
|
||||
return;
|
||||
}
|
||||
//var_dump($storedFile);
|
||||
$id = $storedFile->getId();
|
||||
if (!is_numeric($id)) {
|
||||
$this->fail("StoredFile not created correctly. id = ".$id);
|
|
@ -269,7 +269,8 @@ class uiBase
|
|||
$this->id = $this->gb->storId;
|
||||
}
|
||||
if (!is_null($this->id)) {
|
||||
$this->type = Greenbox::getFileType($this->id);
|
||||
$f = StoredFile::Recall($this->id);
|
||||
$this->type = $f->getType();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -481,35 +482,35 @@ class uiBase
|
|||
* local ID of file
|
||||
* @param string $format
|
||||
*/
|
||||
public function analyzeFile($id, $format)
|
||||
{
|
||||
$ia = $this->gb->analyzeFile($id, $this->sessid);
|
||||
$s = $ia['playtime_seconds'];
|
||||
$extent = date('H:i:s', floor($s)-date('Z')).substr(number_format($s, 6), strpos(number_format($s, 6), '.'));
|
||||
|
||||
if ($format=='text') {
|
||||
return "<div align='left'><pre>".var_export($ia, TRUE)."</pre></div>";
|
||||
}
|
||||
return FALSE;
|
||||
} // fn analyzeFile
|
||||
// public function analyzeFile($id, $format)
|
||||
// {
|
||||
// $ia = $this->gb->analyzeFile($id, $this->sessid);
|
||||
// $s = $ia['playtime_seconds'];
|
||||
// $extent = date('H:i:s', floor($s)-date('Z')).substr(number_format($s, 6), strpos(number_format($s, 6), '.'));
|
||||
//
|
||||
// if ($format=='text') {
|
||||
// return "<div align='left'><pre>".var_export($ia, TRUE)."</pre></div>";
|
||||
// }
|
||||
// return FALSE;
|
||||
// }
|
||||
|
||||
|
||||
public function toHex($gunid)
|
||||
{
|
||||
global $CC_DBC;
|
||||
$res = $CC_DBC->query("SELECT to_hex($gunid)");
|
||||
$row = $res->fetchRow();
|
||||
return $row['to_hex'];
|
||||
}
|
||||
// public function toHex($gunid)
|
||||
// {
|
||||
// global $CC_DBC;
|
||||
// $res = $CC_DBC->query("SELECT to_hex($gunid)");
|
||||
// $row = $res->fetchRow();
|
||||
// return $row['to_hex'];
|
||||
// }
|
||||
|
||||
|
||||
public function toInt8($gunid)
|
||||
{
|
||||
global $CC_DBC;
|
||||
$res = $CC_DBC->query("SELECT x'$gunid'::bigint");
|
||||
$row = $res->fetchRow();
|
||||
return $row['int8'];
|
||||
}
|
||||
// public function toInt8($gunid)
|
||||
// {
|
||||
// global $CC_DBC;
|
||||
// $res = $CC_DBC->query("SELECT x'$gunid'::bigint");
|
||||
// $row = $res->fetchRow();
|
||||
// return $row['int8'];
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
|
@ -540,17 +541,17 @@ class uiBase
|
|||
|
||||
public function getMetaInfo($id)
|
||||
{
|
||||
$type = strtolower(GreenBox::getFileType($id));
|
||||
|
||||
$media = StoredFile::Recall($id);
|
||||
$type = strtolower($media->getType());
|
||||
$data = array('id' => $id,
|
||||
'gunid' => BasicStor::GunidFromId($id),
|
||||
'title' => $this->getMetadataValue($id, UI_MDATA_KEY_TITLE),
|
||||
'creator' => $this->getMetadataValue($id, UI_MDATA_KEY_CREATOR),
|
||||
'duration' => $this->getMetadataValue($id, UI_MDATA_KEY_DURATION),
|
||||
'gunid' => $media->getGunid(),
|
||||
'title' => $media->getMetadataValue($id, UI_MDATA_KEY_TITLE),
|
||||
'creator' => $media->getMetadataValue($id, UI_MDATA_KEY_CREATOR),
|
||||
'duration' => $media->getMetadataValue($id, UI_MDATA_KEY_DURATION),
|
||||
'type' => $type,
|
||||
'source' => $type == 'audioclip' ? $this->getMetadataValue($id, UI_MDATA_KEY_SOURCE) : NULL,
|
||||
'bitRate' => $type == 'audioclip' ? $this->getMetadataValue($id, UI_MDATA_KEY_BITRATE) : NULL,
|
||||
'sampleRate' => $type == 'audioclip' ? $this->getMetadataValue($id, UI_MDATA_KEY_SAMPLERATE) : NULL,
|
||||
'source' => $type == 'audioclip' ? $media->getMetadataValue($id, UI_MDATA_KEY_SOURCE) : NULL,
|
||||
'bitRate' => $type == 'audioclip' ? $media->getMetadataValue($id, UI_MDATA_KEY_BITRATE) : NULL,
|
||||
'sampleRate' => $type == 'audioclip' ? $media->getMetadataValue($id, UI_MDATA_KEY_SAMPLERATE) : NULL,
|
||||
);
|
||||
return ($data);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
/**
|
||||
* @package Campcaster
|
||||
* @subpackage htmlUI
|
||||
|
||||
*/
|
||||
class uiBrowser extends uiBase {
|
||||
|
||||
|
@ -389,8 +388,8 @@ class uiBrowser extends uiBase {
|
|||
function listen2Audio($clipid)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
$id = BasicStor::IdFromGunid($clipid);
|
||||
$type = Greenbox::getFileType($id);
|
||||
$media = StoredFile::RecallByGunid($clipid);
|
||||
$type = $media->getType();
|
||||
|
||||
if (1) {
|
||||
header("Location: http://{$_SERVER['SERVER_NAME']}".$CC_CONFIG['accessRawAudioUrl']."?sessid={$this->sessid}&id=$clipid\n");
|
||||
|
|
|
@ -137,20 +137,21 @@ if (isset($_REQUEST['popup']) && is_array($_REQUEST['popup'])){
|
|||
break;
|
||||
|
||||
case "PL.downloadExportedFile":
|
||||
$exportedPlaylist = $uiBrowser->gb->exportPlaylistOpen($uiBrowser->sessid,
|
||||
BasicStor::GunidFromId($_REQUEST['id']),
|
||||
$_REQUEST['playlisttype'],
|
||||
$_REQUEST['exporttype']=='playlistOnly'?true:false);
|
||||
$fp = fopen($exportedPlaylist['fname'],'r');
|
||||
if (is_resource($fp)) {
|
||||
header("Content-Type: application/octet-stream");
|
||||
header("Content-Length: " . filesize($exportedPlaylist['fname']));
|
||||
header('Content-Disposition: attachment; filename="playlist.tar"');
|
||||
header("Content-Transfer-Encoding: binary\n");
|
||||
fpassthru($fp);
|
||||
$uiBrowser->gb->exportPlaylistClose($exportedPlaylist['token']);
|
||||
}
|
||||
//$Smarty->display('popup/PLAYLIST.downloadExportedFile.tpl');
|
||||
|
||||
// $exportedPlaylist = $uiBrowser->gb->exportPlaylistOpen($uiBrowser->sessid,
|
||||
// BasicStor::GunidFromId($_REQUEST['id']),
|
||||
// $_REQUEST['playlisttype'],
|
||||
// $_REQUEST['exporttype']=='playlistOnly'?true:false);
|
||||
// $fp = fopen($exportedPlaylist['fname'],'r');
|
||||
// if (is_resource($fp)) {
|
||||
// header("Content-Type: application/octet-stream");
|
||||
// header("Content-Length: " . filesize($exportedPlaylist['fname']));
|
||||
// header('Content-Disposition: attachment; filename="playlist.tar"');
|
||||
// header("Content-Transfer-Encoding: binary\n");
|
||||
// fpassthru($fp);
|
||||
// $uiBrowser->gb->exportPlaylistClose($exportedPlaylist['token']);
|
||||
// }
|
||||
// //$Smarty->display('popup/PLAYLIST.downloadExportedFile.tpl');
|
||||
break;
|
||||
|
||||
case "SCHEDULER.addItem":
|
||||
|
@ -354,10 +355,10 @@ if ($uiBrowser->userid) {
|
|||
$Smarty->assign('showFile', TRUE);
|
||||
break;
|
||||
|
||||
case "_analyzeFile":
|
||||
$Smarty->assign('_analyzeFile', $uiBrowser->analyzeFile($uiBrowser->id, 'text'));
|
||||
$Smarty->assign('showFile', TRUE);
|
||||
break;
|
||||
// case "_analyzeFile":
|
||||
// $Smarty->assign('_analyzeFile', $uiBrowser->analyzeFile($uiBrowser->id, 'text'));
|
||||
// $Smarty->assign('showFile', TRUE);
|
||||
// break;
|
||||
|
||||
case "changeStationPrefs":
|
||||
$Smarty->assign('dynform', $uiBrowser->changeStationPrefs($ui_fmask['stationPrefs']));
|
||||
|
|
|
@ -124,7 +124,7 @@ class uiHandler extends uiBase {
|
|||
$metadata['ls:filename'] = basename($audio_file);
|
||||
}
|
||||
|
||||
// bsSetMetadataBatch doesnt like these values
|
||||
// setMetadataBatch doesnt like these values
|
||||
unset($metadata['audio']);
|
||||
unset($metadata['playtime_seconds']);
|
||||
|
||||
|
@ -141,7 +141,7 @@ class uiHandler extends uiBase {
|
|||
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": ' + $storedFile->getMessage() + '}}');
|
||||
}
|
||||
|
||||
$result = $this->gb->bsSetMetadataBatch($storedFile->getId(), $metadata);
|
||||
$result = $storedFile->setMetadataBatch($metadata);
|
||||
|
||||
return $storedFile->getId();
|
||||
}
|
||||
|
@ -263,12 +263,6 @@ class uiHandler extends uiBase {
|
|||
$id = $formdata['id'];
|
||||
$folderId = $formdata['folderId'];
|
||||
|
||||
if (Greenbox::getFileType($folderId) != 'Folder') {
|
||||
$this->_retMsg('The target is not a folder.');
|
||||
$this->redirUrl = UI_BROWSER."?act=fileList";
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!$this->_validateForm($formdata, $mask)) {
|
||||
$this->redirUrl = UI_BROWSER."?act=editFile&id=".$id;
|
||||
return FALSE;
|
||||
|
@ -301,7 +295,7 @@ class uiHandler extends uiBase {
|
|||
$metadata['ls:filename'] = $formdata['mediafile']['name'];
|
||||
}
|
||||
|
||||
// bsSetMetadataBatch doesnt like these values
|
||||
// setMetadataBatch doesnt like these values
|
||||
unset($metadata['audio']);
|
||||
unset($metadata['playtime_seconds']);
|
||||
|
||||
|
@ -326,7 +320,7 @@ class uiHandler extends uiBase {
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
$result = $this->gb->bsSetMetadataBatch($storedFile->getId(), $metadata);
|
||||
$result = $storedFile->setMetadataBatch($metadata);
|
||||
|
||||
$this->redirUrl = UI_BROWSER."?act=addFileMData&id=".$storedFile->getId();
|
||||
$this->_retMsg('Audioclip has been uploaded successfully.');
|
||||
|
@ -353,45 +347,45 @@ class uiHandler extends uiBase {
|
|||
* @param unknown_type $langid
|
||||
* @return void
|
||||
*/
|
||||
function translateMetadata($id, $langid=UI_DEFAULT_LANGID)
|
||||
{
|
||||
include(dirname(__FILE__).'/formmask/metadata.inc.php');
|
||||
|
||||
$ia = $this->gb->analyzeFile($id, $this->sessid);
|
||||
if (PEAR::isError($ia)) {
|
||||
$this->_retMsg($ia->getMessage());
|
||||
return;
|
||||
}
|
||||
// This is really confusing: the import script does not do it
|
||||
// this way. Which way is the right way?
|
||||
$this->setMetadataValue($id, UI_MDATA_KEY_DURATION, Playlist::secondsToPlaylistTime($ia['playtime_seconds']));
|
||||
// $this->setMetadataValue($id, UI_MDATA_KEY_FORMAT, UI_MDATA_VALUE_FORMAT_FILE);
|
||||
|
||||
// some data from raw audio
|
||||
// if (isset($ia['audio']['channels'])) {
|
||||
// $this->setMetadataValue($id, UI_MDATA_KEY_CHANNELS, $ia['audio']['channels']);
|
||||
// function translateMetadata($id, $langid=UI_DEFAULT_LANGID)
|
||||
// {
|
||||
// include(dirname(__FILE__).'/formmask/metadata.inc.php');
|
||||
//
|
||||
// $ia = $this->gb->analyzeFile($id, $this->sessid);
|
||||
// if (PEAR::isError($ia)) {
|
||||
// $this->_retMsg($ia->getMessage());
|
||||
// return;
|
||||
// }
|
||||
// if (isset($ia['audio']['sample_rate'])) {
|
||||
// $this->setMetadataValue($id, UI_MDATA_KEY_SAMPLERATE, $ia['audio']['sample_rate']);
|
||||
// // This is really confusing: the import script does not do it
|
||||
// // this way. Which way is the right way?
|
||||
// $this->setMetadataValue($id, UI_MDATA_KEY_DURATION, Playlist::secondsToPlaylistTime($ia['playtime_seconds']));
|
||||
//// $this->setMetadataValue($id, UI_MDATA_KEY_FORMAT, UI_MDATA_VALUE_FORMAT_FILE);
|
||||
//
|
||||
// // some data from raw audio
|
||||
//// if (isset($ia['audio']['channels'])) {
|
||||
//// $this->setMetadataValue($id, UI_MDATA_KEY_CHANNELS, $ia['audio']['channels']);
|
||||
//// }
|
||||
//// if (isset($ia['audio']['sample_rate'])) {
|
||||
//// $this->setMetadataValue($id, UI_MDATA_KEY_SAMPLERATE, $ia['audio']['sample_rate']);
|
||||
//// }
|
||||
//// if (isset($ia['audio']['bitrate'])) {
|
||||
//// $this->setMetadataValue($id, UI_MDATA_KEY_BITRATE, $ia['audio']['bitrate']);
|
||||
//// }
|
||||
//// if (isset($ia['audio']['codec'])) {
|
||||
//// $this->setMetadataValue($id, UI_MDATA_KEY_ENCODER, $ia['audio']['codec']);
|
||||
//// }
|
||||
//
|
||||
// // from id3 Tags
|
||||
// // loop main, music, talk
|
||||
// foreach ($mask['pages'] as $key => $val) {
|
||||
// // loop through elements
|
||||
// foreach ($mask['pages'][$key] as $k => $v) {
|
||||
// if (isset($v['element']) && isset($ia[$v['element']])) {
|
||||
// $this->setMetadataValue($id, $v['element'], $ia[$v['element']], $langid);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (isset($ia['audio']['bitrate'])) {
|
||||
// $this->setMetadataValue($id, UI_MDATA_KEY_BITRATE, $ia['audio']['bitrate']);
|
||||
// }
|
||||
// if (isset($ia['audio']['codec'])) {
|
||||
// $this->setMetadataValue($id, UI_MDATA_KEY_ENCODER, $ia['audio']['codec']);
|
||||
// }
|
||||
|
||||
// from id3 Tags
|
||||
// loop main, music, talk
|
||||
foreach ($mask['pages'] as $key => $val) {
|
||||
// loop through elements
|
||||
foreach ($mask['pages'][$key] as $k => $v) {
|
||||
if (isset($v['element']) && isset($ia[$v['element']])) {
|
||||
$this->setMetadataValue($id, $v['element'], $ia[$v['element']], $langid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
|
@ -403,13 +397,8 @@ class uiHandler extends uiBase {
|
|||
function addWebstream($formdata, $mask)
|
||||
{
|
||||
$id = $formdata['id'];
|
||||
$folderId = $formdata['folderId'];
|
||||
//$folderId = $formdata['folderId'];
|
||||
|
||||
if (Greenbox::getFileType($folderId) != 'Folder') {
|
||||
$this->_retMsg ('The target is not a folder.');
|
||||
$this->redirUrl = UI_BROWSER."?act=fileList";
|
||||
return FALSE;
|
||||
}
|
||||
if (!$this->_validateForm($formdata, $mask)) {
|
||||
$this->redirUrl = UI_BROWSER."?act=editWebstream&id=".$id;
|
||||
return FALSE;
|
||||
|
@ -534,16 +523,13 @@ class uiHandler extends uiBase {
|
|||
}
|
||||
|
||||
foreach ($ids as $id) {
|
||||
if (Greenbox::getFileType($id) == 'playlist') {
|
||||
$r = $this->gb->deletePlaylist($id, $this->sessid);
|
||||
} else {
|
||||
$r = $this->gb->deleteFile($id, $this->sessid);
|
||||
}
|
||||
$media = StoredFile::Recall($id);
|
||||
$r = $media->delete();
|
||||
|
||||
if (PEAR::isError($r)) {
|
||||
$this->_retMsg($r->getMessage());
|
||||
return FALSE;
|
||||
}
|
||||
if (PEAR::isError($r)) {
|
||||
$this->_retMsg($r->getMessage());
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
|
|
@ -11,7 +11,7 @@ class uiPlaylist
|
|||
public $activeId;
|
||||
public $title;
|
||||
public $duration;
|
||||
|
||||
|
||||
private $Base;
|
||||
private $reloadUrl;
|
||||
private $redirectUrl;
|
||||
|
@ -33,10 +33,10 @@ class uiPlaylist
|
|||
public function setReload($url=NULL)
|
||||
{
|
||||
if($url)
|
||||
$this->Base->redirUrl = $url;
|
||||
$this->Base->redirUrl = $url;
|
||||
else
|
||||
$this->Base->redirUrl = $this->reloadUrl;
|
||||
|
||||
|
||||
} // fn setReload
|
||||
|
||||
|
||||
|
@ -65,7 +65,7 @@ class uiPlaylist
|
|||
|
||||
|
||||
public function getActiveArr()
|
||||
{
|
||||
{
|
||||
if (!$this->activeId) {
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ class uiPlaylist
|
|||
if ($this->activeId) {
|
||||
$this->release();
|
||||
}
|
||||
|
||||
|
||||
$userid = $this->Base->gb->playlistIsAvailable($plid, $this->Base->sessid);
|
||||
if ($userid !== TRUE) {
|
||||
if (UI_WARNING) {
|
||||
|
@ -107,10 +107,10 @@ class uiPlaylist
|
|||
$this->Base->_retMsg('Unable to open playlist "$1".', $this->Base->getMetadataValue($plid, UI_MDATA_KEY_TITLE));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
$this->Base->gb->savePref($this->Base->sessid, UI_PL_ACCESSTOKEN_KEY, $plid);
|
||||
$this->activeId = $plid;
|
||||
|
||||
|
||||
if ($msg && UI_VERBOSE) {
|
||||
$this->Base->_retMsg('Playlist "$1" opened.', $this->Base->getMetadataValue($plid, UI_MDATA_KEY_TITLE));
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ class uiPlaylist
|
|||
|
||||
|
||||
public function release($msg=TRUE)
|
||||
{
|
||||
{
|
||||
// release PL
|
||||
// delete PL from session
|
||||
if (!$this->activeId) {
|
||||
|
@ -139,12 +139,9 @@ class uiPlaylist
|
|||
}
|
||||
return FALSE;
|
||||
}
|
||||
if ($msg && UI_VERBOSE) {
|
||||
$this->Base->_retMsg('Playlist "$1" released.', $this->Base->getMetadataValue(BasicStor::IdFromGunid($plgunid), UI_MDATA_KEY_TITLE));
|
||||
}
|
||||
$this->activeId = NULL;
|
||||
$this->Base->gb->delPref($this->Base->sessid, UI_PL_ACCESSTOKEN_KEY);
|
||||
|
||||
|
||||
return TRUE;
|
||||
} // fn release
|
||||
|
||||
|
@ -164,16 +161,16 @@ class uiPlaylist
|
|||
public function loadLookedFromPref()
|
||||
{
|
||||
if (is_string($plid = $this->Base->gb->loadPref($this->Base->sessid, UI_PL_ACCESSTOKEN_KEY))) {
|
||||
|
||||
|
||||
if (!$this->Base->gb->existsPlaylist($plid)) {
|
||||
$this->Base->gb->delPref($this->Base->sessid, UI_PL_ACCESSTOKEN_KEY);
|
||||
$this->Base->_retMsg('Playlist not found in database.');
|
||||
$this->Base->redirUrl = UI_BROWSER.'?popup[]=_2PL.simpleManagement&popup[]=_close';
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
$this->activeId = $plid;
|
||||
|
||||
|
||||
$this->Base->redirUrl = UI_BROWSER.'?popup[]=_2PL.simpleManagement&popup[]=_close';
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -195,7 +192,7 @@ class uiPlaylist
|
|||
$cliplength = NULL;
|
||||
$cueIn = NULL;
|
||||
$cueIn = NULL;
|
||||
|
||||
|
||||
/*
|
||||
gstreamer bug:
|
||||
Warning: The clipEnd can't be bigger than ninety nine percent (99%) of the clipLength,
|
||||
|
@ -208,14 +205,14 @@ class uiPlaylist
|
|||
$this->Base->_retMsg('No item(s) selected.');
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
if (!is_array($elemIds)) {
|
||||
$elemIds = array($elemIds);
|
||||
}
|
||||
}
|
||||
if (isset($duration)) {
|
||||
$length = sprintf('%02d', $duration['H']).':'.sprintf('%02d', $duration['i']).':'.sprintf('%02d', $duration['s']).'.000000';
|
||||
}
|
||||
|
||||
|
||||
foreach ($elemIds as $elemId) {
|
||||
$r = $this->Base->gb->addAudioClipToPlaylist($this->activeId, $elemId, $pos, $fadeIn, $fadeOut, $cliplength, $cueIn, $cueOut);
|
||||
if (PEAR::isError($r)) {
|
||||
|
@ -226,9 +223,9 @@ class uiPlaylist
|
|||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->Base->SCRATCHPAD->reloadActivePLMetadata($this->activeId);
|
||||
|
||||
|
||||
return TRUE;
|
||||
} // fn addItem
|
||||
|
||||
|
@ -243,20 +240,20 @@ class uiPlaylist
|
|||
}
|
||||
if (!is_array($positions))
|
||||
$positions = array($positions);
|
||||
|
||||
|
||||
//so the automatic updating of playlist positioning doesn't affect removal.
|
||||
sort($positions);
|
||||
$positions = array_reverse($positions);
|
||||
|
||||
|
||||
foreach ($positions as $pos) {
|
||||
if ($this->Base->gb->delAudioClipFromPlaylist($this->activeId, $pos) !== TRUE) {
|
||||
$this->Base->_retMsg('Cannot remove item from playlist.');
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->Base->SCRATCHPAD->reloadActivePLMetadata($this->activeId);
|
||||
|
||||
|
||||
return TRUE;
|
||||
} // fn removeItem
|
||||
|
||||
|
@ -274,14 +271,14 @@ class uiPlaylist
|
|||
// create PL
|
||||
// activate
|
||||
// add clip if $id is set
|
||||
|
||||
|
||||
if ($this->activeId) {
|
||||
$this->release();
|
||||
}
|
||||
|
||||
|
||||
$datetime = strftime('%Y-%m-%d %H:%M:%S');
|
||||
$plid = $this->Base->gb->createPlaylist($datetime, $this->Base->sessid);
|
||||
|
||||
|
||||
if (!$plid) {
|
||||
$this->Base->_retMsg('Cannot create playlist.');
|
||||
return FALSE;
|
||||
|
@ -290,7 +287,7 @@ class uiPlaylist
|
|||
$this->Base->gb->setPLMetadataValue($plid, UI_MDATA_KEY_CREATOR, $this->Base->login);
|
||||
$this->Base->gb->setPLMetadataValue($plid, UI_MDATA_KEY_DESCRIPTION, tra('created at $1', $datetime));
|
||||
|
||||
|
||||
|
||||
if ($this->activate($plid)===FALSE) {
|
||||
$this->Base->_retMsg('Cannot activate playlist.');
|
||||
return FALSE;
|
||||
|
@ -300,14 +297,14 @@ class uiPlaylist
|
|||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $plid;
|
||||
} // fn create
|
||||
|
||||
public function moveItem($oldPos, $newPos)
|
||||
{
|
||||
$response = array();
|
||||
|
||||
|
||||
$r = $this->Base->gb->moveAudioClipInPlaylist($this->activeId, $oldPos, $newPos);
|
||||
if (PEAR::isError($r) || $r === FALSE) {
|
||||
$response["error"] = "Failed to Move file.";
|
||||
|
@ -315,9 +312,9 @@ class uiPlaylist
|
|||
$response["newPos"] = $newPos;
|
||||
}
|
||||
else{
|
||||
$response["error"] = FALSE;
|
||||
$response["error"] = FALSE;
|
||||
}
|
||||
|
||||
|
||||
die(json_encode($response));
|
||||
} // fn moveItem
|
||||
|
||||
|
@ -325,22 +322,22 @@ class uiPlaylist
|
|||
public function setClipLength($pos, $cueIn, $cueOut)
|
||||
{
|
||||
$response = array();
|
||||
|
||||
|
||||
$res = $this->Base->gb->changeClipLength($this->activeId, $pos, $cueIn, $cueOut);
|
||||
|
||||
$response = $res;
|
||||
|
||||
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
|
||||
public function setFadeLength($pos, $fadeIn, $fadeOut)
|
||||
{
|
||||
$response = array();
|
||||
|
||||
|
||||
$res = $this->Base->gb->changeFadeInfo($this->activeId, $pos, $fadeIn, $fadeOut);
|
||||
|
||||
|
||||
$response = $res;
|
||||
|
||||
|
||||
die(json_encode($response));
|
||||
} // fn setFade
|
||||
|
||||
|
@ -353,7 +350,7 @@ class uiPlaylist
|
|||
|
||||
foreach ($mask['playlist'] as $k=>$v) {
|
||||
$mask['playlist'][$k]['element'] = uiBase::formElementEncode($v['element']);
|
||||
|
||||
|
||||
$getval = $this->Base->gb->getPLMetadataValue($id, $v['element'], $langid);
|
||||
if ($getval) {
|
||||
$mask['playlist'][$k]['default'] = $getval;
|
||||
|
@ -398,9 +395,9 @@ class uiPlaylist
|
|||
} else {
|
||||
$this->Base->redirUrl = UI_BROWSER."?act=PL.editMetaData&id=$id&curr_langid=".$formdata['target_langid'];
|
||||
}
|
||||
|
||||
|
||||
foreach ($mask['playlist'] as $k=>$v) {
|
||||
|
||||
|
||||
$formdata[uiBase::formElementEncode($v['element'])] ? $mData[uiBase::formElementDecode($v['element'])] = $formdata[uiBase::formElementEncode($v['element'])] : NULL;
|
||||
}
|
||||
|
||||
|
@ -419,7 +416,7 @@ class uiPlaylist
|
|||
}
|
||||
if (UI_VERBOSE) {
|
||||
$this->Base->_retMsg('Metadata saved.');
|
||||
}
|
||||
}
|
||||
|
||||
$this->Base->SCRATCHPAD->reloadMetadata();
|
||||
} // fn editMetadata
|
||||
|
@ -429,7 +426,7 @@ class uiPlaylist
|
|||
{
|
||||
$id = $this->activeId;
|
||||
$this->release(FALSE);
|
||||
|
||||
|
||||
$res = $this->Base->gb->deletePlaylist($id);
|
||||
if ($res === TRUE) {
|
||||
return $id;
|
||||
|
@ -438,7 +435,7 @@ class uiPlaylist
|
|||
$this->Base->_retMsg('Cannot delete this playlist.');
|
||||
return FALSE;
|
||||
} // fn deleteActive
|
||||
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
$res = $this->Base->gb->deletePlaylist($id);
|
||||
|
|
|
@ -209,7 +209,7 @@ class uiScheduler extends uiCalendar {
|
|||
// $hour = $arr['hour'];
|
||||
// $minute = $arr['minute'];
|
||||
// $second = $arr['second'];
|
||||
|
||||
|
||||
extract($arr);
|
||||
|
||||
if (isset($today)) {
|
||||
|
@ -456,25 +456,6 @@ class uiScheduler extends uiCalendar {
|
|||
return $items;
|
||||
} // fn getDayEntrys
|
||||
|
||||
/*
|
||||
function getDayHourlyEntrys($year, $month, $day)
|
||||
{
|
||||
$date = $year.'-'.$month.'-'.$day;
|
||||
$arr = $this->displayScheduleMethod($date.' 00:00:00', $date.' 23:59:59.999999');
|
||||
if (!count($arr))
|
||||
return FALSE;
|
||||
foreach ($arr as $key => $val) {
|
||||
$items[date('H', self::datetimeToTimestamp($val['start']))][]= array (
|
||||
'start' => substr($val['start'], strpos($val['start'], 'T')+1),
|
||||
'end' => substr($val['end'], strpos($val['end'], 'T') + 1),
|
||||
'title' => $this->Base->getMetadataValue(BasicStor::IdFromGunid($val['playlistId']), UI_MDATA_KEY_TITLE),
|
||||
'creator' => $this->Base->getMetadataValue(BasicStor::IdFromGunid($val['playlistId']), UI_MDATA_KEY_CREATOR),
|
||||
);
|
||||
}
|
||||
#print_r($items);
|
||||
return $items;
|
||||
}
|
||||
*/
|
||||
|
||||
private function getDayUsage($year, $month, $day)
|
||||
{
|
||||
|
@ -487,11 +468,12 @@ class uiScheduler extends uiCalendar {
|
|||
}
|
||||
|
||||
foreach ($arr as $key => $val) {
|
||||
$id = BasicStor::IdFromGunid($val['playlistId']);
|
||||
$arr[$key]['title'] = $this->Base->getMetadataValue($id, UI_MDATA_KEY_TITLE);
|
||||
$arr[$key]['creator'] = $this->Base->getMetadataValue($id, UI_MDATA_KEY_CREATOR);
|
||||
$arr[$key]['pos'] = self::datetimeToTimestamp($val['start']);
|
||||
$arr[$key]['span'] = date('H', self::datetimeToTimestamp($val['end'])) - date('H', self::datetimeToTimestamp($val['start'])) +1;
|
||||
$pl = Playlist::Recall($val['playlistId']);
|
||||
//$id = BasicStor::IdFromGunid($val['playlistId']);
|
||||
$arr[$key]['title'] = $pl->getName(); //$this->Base->getMetadataValue($id, UI_MDATA_KEY_TITLE);
|
||||
$arr[$key]['creator'] = $pl->getPLMetaData("dc:title");// $this->Base->getMetadataValue($id, UI_MDATA_KEY_CREATOR);
|
||||
$arr[$key]['pos'] = self::datetimeToTimestamp($val['start']);
|
||||
$arr[$key]['span'] = date('H', self::datetimeToTimestamp($val['end'])) - date('H', self::datetimeToTimestamp($val['start'])) +1;
|
||||
}
|
||||
return $arr;
|
||||
} // fn getDayUsage
|
||||
|
@ -595,7 +577,7 @@ class uiScheduler extends uiCalendar {
|
|||
}
|
||||
|
||||
return TRUE;
|
||||
} // fn copyPlfromSP
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -707,22 +689,27 @@ class uiScheduler extends uiCalendar {
|
|||
{
|
||||
// just use methods which work without valid authentification
|
||||
$c_pl = self::getScheduledPlaylist();
|
||||
$pl = Playlist::Recall($c_pl['playlistId']);
|
||||
|
||||
$n_clip = null;
|
||||
if ($c_clip = $this->getClipFromCurrent($c_pl, 0)) {
|
||||
$n_clip = $this->getClipFromCurrent($c_pl, 1);
|
||||
}
|
||||
$nextClip = StoredFile::Recall($n_clip);
|
||||
$u_clip = null;
|
||||
$u_pl_start = null;
|
||||
if ($u_pl = self::getScheduledPlaylist(2)) {
|
||||
$u_clip = $this->getClipFromPlaylist($u_pl);
|
||||
$u_pl_start = explode(':', date('H:i:s', self::datetimeToTimestamp($u_pl['start'])));
|
||||
}
|
||||
$upcomingClip = StoredFile::Recall($u_pl['playlistId']);
|
||||
|
||||
return array(
|
||||
'current' => $c_clip ? 1 : 0,
|
||||
'current.title' => addcslashes($c_clip['title'], "'"),
|
||||
'current.pltitle' => addcslashes($this->Base->getMetadataValue(BasicStor::IdFromGunid($c_pl['playlistId']), UI_MDATA_KEY_TITLE), "'"),
|
||||
'current.elapsed.h' => $c_clip['elapsed']['h'],
|
||||
//'current.pltitle' => addcslashes($this->Base->getMetadataValue(BasicStor::IdFromGunid($c_pl['playlistId']), UI_MDATA_KEY_TITLE), "'"),
|
||||
'current.pltitle' => addcslashes($pl->getName(), "'"),
|
||||
'current.elapsed.h' => $c_clip['elapsed']['h'],
|
||||
'current.elapsed.m' => $c_clip['elapsed']['m'],
|
||||
'current.elapsed.s' => $c_clip['elapsed']['s'],
|
||||
'current.duration.h' => $c_clip['duration']['h'],
|
||||
|
@ -731,15 +718,17 @@ class uiScheduler extends uiCalendar {
|
|||
|
||||
'next' => $n_clip ? 1 : 0,
|
||||
'next.title' => $n_clip ? addcslashes($n_clip['title'], "'") : "",
|
||||
'next.pltitle' => addcslashes($this->Base->getMetadataValue($n_clip, UI_MDATA_KEY_TITLE), "'"),
|
||||
'next.duration.h' => $n_clip ? $n_clip['duration']['h'] : 0,
|
||||
//'next.pltitle' => addcslashes($this->Base->getMetadataValue($n_clip, UI_MDATA_KEY_TITLE), "'"),
|
||||
'next.pltitle' => addcslashes($nextClip->getTitle(), "'"),
|
||||
'next.duration.h' => $n_clip ? $n_clip['duration']['h'] : 0,
|
||||
'next.duration.m' => $n_clip ? $n_clip['duration']['m'] : 0,
|
||||
'next.duration.s' => $n_clip ? $n_clip['duration']['s'] : 0,
|
||||
|
||||
'upcoming' => $u_pl ? 1 : 0,
|
||||
'upcoming.title' => addcslashes($u_clip['title'], "'"),
|
||||
'upcoming.pltitle' => addcslashes($this->Base->getMetadataValue(BasicStor::IdFromGunid($u_pl['playlistId']), UI_MDATA_KEY_TITLE), "'"),
|
||||
'upcoming.duration.h' => $u_clip['duration']['h'],
|
||||
//'upcoming.pltitle' => addcslashes($this->Base->getMetadataValue(BasicStor::IdFromGunid($u_pl['playlistId']), UI_MDATA_KEY_TITLE), "'"),
|
||||
'upcoming.pltitle' => addcslashes($upcomingClip->getName(), "'"),
|
||||
'upcoming.duration.h' => $u_clip['duration']['h'],
|
||||
'upcoming.duration.m' => $u_clip['duration']['m'],
|
||||
'upcoming.duration.s' => $u_clip['duration']['s'],
|
||||
'upcoming.plstart.h' => $u_pl_start[0],
|
||||
|
|
|
@ -77,12 +77,12 @@ class uiScratchPad
|
|||
// get the scratchpad list
|
||||
$arr = explode(' ', $spData);
|
||||
$maxLength = $this->Base->STATIONPREFS[UI_SCRATCHPAD_MAXLENGTH_KEY];
|
||||
$arr = array_slice($arr, 0, $maxLength);
|
||||
$arr = array_slice($arr, 0, $maxLength);
|
||||
foreach ($arr as $item) {
|
||||
//for audiofiles.
|
||||
list($type, $savedId) = explode(":", $item);
|
||||
|
||||
if($type === 'pl') {
|
||||
|
||||
if($type === 'pl') {
|
||||
$id = $savedId;
|
||||
if ($i = $this->Base->getPLMetaInfo($id)) {
|
||||
$this->items[] = $i;
|
||||
|
@ -91,9 +91,10 @@ class uiScratchPad
|
|||
else {
|
||||
$gunid = $savedId;
|
||||
if (preg_match('/[0-9]{1,20}/', $gunid)) {
|
||||
$id = BasicStor::IdFromGunid($this->Base->toHex($gunid));
|
||||
if ($id != FALSE) {
|
||||
if ($i = $this->Base->getMetaInfo($id)) {
|
||||
$f = StoredFile::RecallByGunid($gunid);
|
||||
//$id = BasicStor::IdFromGunid($this->Base->toHex($gunid));
|
||||
if (!PEAR::isError($f)) {
|
||||
if ($i = $this->Base->getMetaInfo($f->getId())) {
|
||||
$this->items[] = $i;
|
||||
}
|
||||
}
|
||||
|
@ -115,7 +116,7 @@ class uiScratchPad
|
|||
$str .= 'pl:'.$val['id'].' ';
|
||||
}
|
||||
else {
|
||||
$str .= 'ac:'.$this->Base->toInt8($val['gunid']).' ';
|
||||
$str .= 'ac:'.$val['gunid'].' ';
|
||||
}
|
||||
}
|
||||
$this->Base->gb->savePref($this->Base->sessid, UI_SCRATCHPAD_KEY, $str);
|
||||
|
@ -264,7 +265,7 @@ class uiScratchPad
|
|||
$this->items[$key] = $this->Base->getMetaInfo($val['id']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function reloadActivePLMetadata($id)
|
||||
{
|
||||
foreach ($this->items as $key => $val) {
|
||||
|
@ -274,6 +275,6 @@ class uiScratchPad
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // class uiScratchPad
|
||||
?>
|
||||
|
|
|
@ -155,8 +155,9 @@ class uiTransfers
|
|||
|
||||
function upload2Hub($id)
|
||||
{
|
||||
$gunid = BasicStor::GunidFromId($id);
|
||||
$type = BasicStor::GetType($gunid);
|
||||
$media = StoredFile::Recall($id);
|
||||
$gunid = $media->getGunid();
|
||||
$type = $media->getType();
|
||||
|
||||
switch ($type) {
|
||||
case 'audioClip':
|
||||
|
|
|
@ -365,10 +365,12 @@ class uiTwitter {
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
$f = StoredFile::RecallByGunid($clip['gunid']);
|
||||
$pl = Playlist::Recall($pl['playlistId']);
|
||||
return array(
|
||||
'tracktitle' => $this->Base->gb->getMetadataValue(BasicStor::IdFromGunid($clip['gunid']), UI_MDATA_KEY_TITLE, $this->Base->sessid),
|
||||
'trackartist' => $this->Base->gb->getMetadataValue(BasicStor::IdFromGunid($clip['gunid']), UI_MDATA_KEY_CREATOR, $this->Base->sessid),
|
||||
'playlisttitle' => $this->Base->gb->getMetadataValue(BasicStor::IdFromGunid($pl['playlistId']), UI_MDATA_KEY_TITLE, $this->Base->sessid),
|
||||
'tracktitle' => $f->getMetadataValue(UI_MDATA_KEY_TITLE), //$this->Base->gb->getMetadataValue(BasicStor::IdFromGunid($clip['gunid']), UI_MDATA_KEY_TITLE, $this->Base->sessid),
|
||||
'trackartist' => $f->getMetadataValue(UI_MDATA_KEY_CREATOR), // $this->Base->gb->getMetadataValue(BasicStor::IdFromGunid($clip['gunid']), UI_MDATA_KEY_CREATOR, $this->Base->sessid),
|
||||
'playlisttitle' => $pl->getName() //$this->Base->gb->getMetadataValue(BasicStor::IdFromGunid($pl['playlistId']), UI_MDATA_KEY_TITLE, $this->Base->sessid),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,16 +26,9 @@ function admDumpFolder(&$bs, $fid, $ind='')
|
|||
// echo $name->getMessage();
|
||||
// exit;
|
||||
// }
|
||||
$type = BasicStor::GetObjType($fid);
|
||||
if (PEAR::isError($type)) {
|
||||
echo $type->getMessage();
|
||||
exit;
|
||||
}
|
||||
$gunid = BasicStor::GunidFromId($fid);
|
||||
if (PEAR::isError($gunid)) {
|
||||
echo $gunid->getMessage();
|
||||
exit;
|
||||
}
|
||||
$media = StoredFile::Recall($fid);
|
||||
$type = $media->getType();
|
||||
$gunid = $media->getGunid();
|
||||
$pars = array();
|
||||
if ($gunid) {
|
||||
$pars['id']="$gunid";
|
||||
|
|
|
@ -209,9 +209,9 @@ function camp_import_audio_file($p_filepath, $p_importMode = null, $p_testOnly =
|
|||
"filepath" => $p_filepath,
|
||||
"md5" => $md5sum,
|
||||
);
|
||||
$storedFile = $greenbox->bsPutFile($values, $doCopyFiles);
|
||||
$storedFile = StoredFile::Insert($values, $doCopyFiles);
|
||||
if (PEAR::isError($storedFile)) {
|
||||
import_err($storedFile, "Error in bsPutFile()");
|
||||
import_err($storedFile, "Error in StoredFile::Insert()");
|
||||
echo var_export($metadata)."\n";
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ function ls_restore_restoreObject($obj, /*$parid,*/ $reallyInsert=TRUE){
|
|||
"gunid" => $obj['gunid'],
|
||||
"filetype" => strtolower($obj['type'])
|
||||
);
|
||||
$r = $bs->bsPutFile($values);
|
||||
$r = StoredFile::Insert($values);
|
||||
ls_restore_checkErr($r, __LINE__);
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue