Merge branch 'cc-5709-airtime-analyzer-cloud-storage' into cc-5709-airtime-analyzer-cloud-storage-saas
Conflicts: airtime_mvc/application/models/Schedule.php
This commit is contained in:
commit
97b74a0997
|
@ -85,7 +85,7 @@ class ApiController extends Zend_Controller_Action
|
||||||
// Make sure we don't have some wrong result beecause of caching
|
// Make sure we don't have some wrong result beecause of caching
|
||||||
clearstatcache();
|
clearstatcache();
|
||||||
|
|
||||||
if ($media->getPropelOrm()->isValidFile()) {
|
if ($media->getPropelOrm()->isValidPhysicalFile()) {
|
||||||
$filename = $media->getPropelOrm()->getFilename();
|
$filename = $media->getPropelOrm()->getFilename();
|
||||||
|
|
||||||
//Download user left clicks a track and selects Download.
|
//Download user left clicks a track and selects Download.
|
||||||
|
@ -168,15 +168,9 @@ class ApiController extends Zend_Controller_Action
|
||||||
//http://www.php.net/manual/en/function.ob-end-flush.php
|
//http://www.php.net/manual/en/function.ob-end-flush.php
|
||||||
while (@ob_end_flush());
|
while (@ob_end_flush());
|
||||||
|
|
||||||
/*$cur = $begin;
|
// NOTE: We can't use fseek here because it does not work with streams
|
||||||
fseek($fm, $begin, 0);
|
// (a.k.a. Files stored on Amazon S3)
|
||||||
|
while(!feof($fm) && (connection_status() == 0)) {
|
||||||
while (!feof($fm) && $cur <= $end && (connection_status() == 0)) {
|
|
||||||
echo fread($fm, min(1024 * 16, ($end - $cur) + 1));
|
|
||||||
$cur += 1024 * 16;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
while(!feof($fm)) {
|
|
||||||
echo fread($fm, 1024 * 8);
|
echo fread($fm, 1024 * 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -768,7 +768,19 @@ SQL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function createFileScheduleEvent(&$data, $item, $media_id, $uri, $object_name=null)
|
/**
|
||||||
|
*
|
||||||
|
* Appends schedule "events" to an array of schedule events that gets
|
||||||
|
* sent to PYPO. Each schedule event contains information PYPO and
|
||||||
|
* Liquidsoap need for playout.
|
||||||
|
*
|
||||||
|
* @param Array $data array to be filled with schedule info - $item(s)
|
||||||
|
* @param Array $item schedule info about one track
|
||||||
|
* @param Integer $media_id scheduled item's cc_files id
|
||||||
|
* @param String $uri path to the scheduled item's physical location
|
||||||
|
* @param String $amazonS3ResourceId scheduled item's Amazon S3 resource id, if applicable
|
||||||
|
*/
|
||||||
|
private static function createFileScheduleEvent(&$data, $item, $media_id, $uri, $amazonS3ResourceId)
|
||||||
{
|
{
|
||||||
$start = self::AirtimeTimeToPypoTime($item["start"]);
|
$start = self::AirtimeTimeToPypoTime($item["start"]);
|
||||||
$end = self::AirtimeTimeToPypoTime($item["end"]);
|
$end = self::AirtimeTimeToPypoTime($item["end"]);
|
||||||
|
@ -804,8 +816,8 @@ SQL;
|
||||||
'replay_gain' => $replay_gain,
|
'replay_gain' => $replay_gain,
|
||||||
'independent_event' => $independent_event
|
'independent_event' => $independent_event
|
||||||
);
|
);
|
||||||
if (!is_null($object_name)) {
|
if (!is_null($amazonS3ResourceId)) {
|
||||||
$schedule_item["object_name"] = $object_name;
|
$schedule_item["amazonS3_resource_id"] = $amazonS3ResourceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($schedule_item['cue_in'] > $schedule_item['cue_out']) {
|
if ($schedule_item['cue_in'] > $schedule_item['cue_out']) {
|
||||||
|
@ -938,15 +950,11 @@ SQL;
|
||||||
//row is from "file"
|
//row is from "file"
|
||||||
$media_id = $item['file_id'];
|
$media_id = $item['file_id'];
|
||||||
$storedFile = Application_Model_StoredFile::RecallById($media_id);
|
$storedFile = Application_Model_StoredFile::RecallById($media_id);
|
||||||
|
|
||||||
$file = $storedFile->getPropelOrm();
|
$file = $storedFile->getPropelOrm();
|
||||||
$uri = $file->getAbsoluteFilePath();
|
$uri = $file->getAbsoluteFilePath();
|
||||||
|
$amazonS3ResourceId = $file->getResourceId();
|
||||||
|
|
||||||
$object_name = null;
|
self::createFileScheduleEvent($data, $item, $media_id, $uri, $amazonS3ResourceId);
|
||||||
if ($file instanceof CloudFile) {
|
|
||||||
$object_name = $storedFile->getResourceId();
|
|
||||||
}
|
|
||||||
self::createFileScheduleEvent($data, $item, $media_id, $uri, $object_name);
|
|
||||||
}
|
}
|
||||||
elseif (!is_null($item['stream_id'])) {
|
elseif (!is_null($item['stream_id'])) {
|
||||||
//row is type "webstream"
|
//row is type "webstream"
|
||||||
|
|
|
@ -111,7 +111,7 @@ class CcFiles extends BaseCcFiles {
|
||||||
/**
|
/**
|
||||||
* Checks if the file is a regular file that can be previewed and downloaded.
|
* Checks if the file is a regular file that can be previewed and downloaded.
|
||||||
*/
|
*/
|
||||||
public function isValidFile()
|
public function isValidPhysicalFile()
|
||||||
{
|
{
|
||||||
return is_file($this->getAbsoluteFilePath());
|
return is_file($this->getAbsoluteFilePath());
|
||||||
}
|
}
|
||||||
|
@ -130,4 +130,14 @@ class CcFiles extends BaseCcFiles {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* This function refers to the file's Amazon S3 resource id.
|
||||||
|
* Returns null because cc_files are stored on local disk.
|
||||||
|
*/
|
||||||
|
public function getResourceId()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
} // CcFiles
|
} // CcFiles
|
||||||
|
|
|
@ -93,7 +93,7 @@ class CloudFile extends BaseCloudFile
|
||||||
/**
|
/**
|
||||||
* Checks if the file is a regular file that can be previewed and downloaded.
|
* Checks if the file is a regular file that can be previewed and downloaded.
|
||||||
*/
|
*/
|
||||||
public function isValidFile()
|
public function isValidPhysicalFile()
|
||||||
{
|
{
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
curl_setopt_array($ch, array(
|
curl_setopt_array($ch, array(
|
||||||
|
|
|
@ -232,7 +232,7 @@ class Rest_MediaController extends Zend_Rest_Controller
|
||||||
$file->setDbFilepath($requestData["filename"]);
|
$file->setDbFilepath($requestData["filename"]);
|
||||||
|
|
||||||
$fileSizeBytes = $requestData["filesize"];
|
$fileSizeBytes = $requestData["filesize"];
|
||||||
if ($fileSizeBytes === false)
|
if (!isset($fileSizeBytes) || $fileSizeBytes === false)
|
||||||
{
|
{
|
||||||
$file->setDbImportStatus(2)->save();
|
$file->setDbImportStatus(2)->save();
|
||||||
$this->fileNotFoundResponse();
|
$this->fileNotFoundResponse();
|
||||||
|
@ -247,7 +247,7 @@ class Rest_MediaController extends Zend_Rest_Controller
|
||||||
//we should get rid of this since we're removing local file storage
|
//we should get rid of this since we're removing local file storage
|
||||||
} else if (isset($requestData["full_path"])) {
|
} else if (isset($requestData["full_path"])) {
|
||||||
$fileSizeBytes = filesize($requestData["full_path"]);
|
$fileSizeBytes = filesize($requestData["full_path"]);
|
||||||
if ($fileSizeBytes === false)
|
if (!isset($fileSizeBytes) || $fileSizeBytes === false)
|
||||||
{
|
{
|
||||||
$file->setDbImportStatus(2)->save();
|
$file->setDbImportStatus(2)->save();
|
||||||
$this->fileNotFoundResponse();
|
$this->fileNotFoundResponse();
|
||||||
|
|
|
@ -30,6 +30,11 @@ setup(name='airtime_analyzer',
|
||||||
'python-daemon',
|
'python-daemon',
|
||||||
'requests',
|
'requests',
|
||||||
'apache-libcloud',
|
'apache-libcloud',
|
||||||
|
# These next 3 are required for requests to support SSL with SNI. Learned this the hard way...
|
||||||
|
# What sucks is that GCC is required to pip install these.
|
||||||
|
#'ndg-httpsclient',
|
||||||
|
#'pyasn1',
|
||||||
|
#'pyopenssl'
|
||||||
],
|
],
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
data_files=data_files)
|
data_files=data_files)
|
||||||
|
|
|
@ -136,9 +136,9 @@ class PypoFile(Thread):
|
||||||
"""
|
"""
|
||||||
If an object_name exists the file is stored on Amazon S3
|
If an object_name exists the file is stored on Amazon S3
|
||||||
"""
|
"""
|
||||||
if 'object_name' in media_item:
|
if 'amazonS3_resource_id' in media_item:
|
||||||
csd = CloudStorageDownloader()
|
csd = CloudStorageDownloader()
|
||||||
csd.download_obj(media_item['dst'], media_item['object_name'])
|
csd.download_obj(media_item['dst'], media_item['amazonS3_resource_id'])
|
||||||
media_item['file_ready'] = True
|
media_item['file_ready'] = True
|
||||||
else:
|
else:
|
||||||
self.copy_file(media_item)
|
self.copy_file(media_item)
|
||||||
|
|
Loading…
Reference in New Issue