SAAS-509: PYPO can't download files via the REST API
This commit is contained in:
parent
59ceb11f00
commit
ec189fc27a
|
@ -771,11 +771,10 @@ SQL;
|
||||||
* @param Array $item schedule info about one track
|
* @param Array $item schedule info about one track
|
||||||
* @param Integer $media_id scheduled item's cc_files id
|
* @param Integer $media_id scheduled item's cc_files id
|
||||||
* @param String $uri path to the scheduled item's physical location
|
* @param String $uri path to the scheduled item's physical location
|
||||||
* @param String $downloadURL URL PYPO makes to the REST API to download the file for playout
|
|
||||||
* @param Integer $filsize The file's file size in bytes
|
* @param Integer $filsize The file's file size in bytes
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static function createFileScheduleEvent(&$data, $item, $media_id, $uri, $downloadURL, $filesize)
|
private static function createFileScheduleEvent(&$data, $item, $media_id, $uri, $filesize)
|
||||||
{
|
{
|
||||||
$start = self::AirtimeTimeToPypoTime($item["start"]);
|
$start = self::AirtimeTimeToPypoTime($item["start"]);
|
||||||
$end = self::AirtimeTimeToPypoTime($item["end"]);
|
$end = self::AirtimeTimeToPypoTime($item["end"]);
|
||||||
|
@ -810,7 +809,6 @@ SQL;
|
||||||
'show_name' => $item["show_name"],
|
'show_name' => $item["show_name"],
|
||||||
'replay_gain' => $replay_gain,
|
'replay_gain' => $replay_gain,
|
||||||
'independent_event' => $independent_event,
|
'independent_event' => $independent_event,
|
||||||
'download_url' => $downloadURL,
|
|
||||||
'filesize' => $filesize,
|
'filesize' => $filesize,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -948,10 +946,9 @@ SQL;
|
||||||
$uri = $file->getAbsoluteFilePath();
|
$uri = $file->getAbsoluteFilePath();
|
||||||
|
|
||||||
$baseUrl = Application_Common_OsPath::getBaseDir();
|
$baseUrl = Application_Common_OsPath::getBaseDir();
|
||||||
$downloadURL = "http://".$_SERVER['HTTP_HOST'].$baseUrl."rest/media/$media_id/download";
|
|
||||||
$filesize = $file->getFileSize();
|
$filesize = $file->getFileSize();
|
||||||
|
|
||||||
self::createFileScheduleEvent($data, $item, $media_id, $uri, $downloadURL, $filesize);
|
self::createFileScheduleEvent($data, $item, $media_id, $uri, $filesize);
|
||||||
}
|
}
|
||||||
elseif (!is_null($item['stream_id'])) {
|
elseif (!is_null($item['stream_id'])) {
|
||||||
//row is type "webstream"
|
//row is type "webstream"
|
||||||
|
|
|
@ -62,15 +62,12 @@ class PypoFile(Thread):
|
||||||
if do_copy:
|
if do_copy:
|
||||||
self.logger.debug("copying from %s to local cache %s" % (src, dst))
|
self.logger.debug("copying from %s to local cache %s" % (src, dst))
|
||||||
try:
|
try:
|
||||||
|
|
||||||
"""
|
|
||||||
copy will overwrite dst if it already exists
|
|
||||||
"""
|
|
||||||
#shutil.copy(src, dst)
|
|
||||||
config = self.read_config_file(CONFIG_PATH)
|
config = self.read_config_file(CONFIG_PATH)
|
||||||
CONFIG_SECTION = "general"
|
CONFIG_SECTION = "general"
|
||||||
username = config.get(CONFIG_SECTION, 'api_key')
|
username = config.get(CONFIG_SECTION, 'api_key')
|
||||||
url = media_item['download_url']
|
|
||||||
|
host = config.get(CONFIG_SECTION, 'base_url')
|
||||||
|
url = "http://%s/rest/media/%s/download" % (host, media_item["id"])
|
||||||
|
|
||||||
with open(dst, "wb") as handle:
|
with open(dst, "wb") as handle:
|
||||||
response = requests.get(url, auth=requests.auth.HTTPBasicAuth(username, ''), stream=True)
|
response = requests.get(url, auth=requests.auth.HTTPBasicAuth(username, ''), stream=True)
|
||||||
|
|
Loading…
Reference in New Issue