Temporary fix to make enclosure urls iTunes compatible

This commit is contained in:
Duncan Sommerville 2015-11-17 21:06:51 -05:00
parent ef87ad8a51
commit eae8c7b638
4 changed files with 25 additions and 8 deletions

View file

@ -535,11 +535,11 @@ class ApiController extends Zend_Controller_Action
$mime_type = finfo_buffer($f, $blob, FILEINFO_MIME_TYPE); $mime_type = finfo_buffer($f, $blob, FILEINFO_MIME_TYPE);
finfo_close($f); finfo_close($f);
header("Content-type: " . $mime_type); header("Content-Type: " . $mime_type);
echo $blob; echo $blob;
} else { } else {
header('HTTP/1.0 401 Unauthorized'); header('HTTP/1.0 401 Unauthorized');
print _('You are not allowed to access this resource. '); print _('You are not allowed to access this resource.');
exit; exit;
} }
} }

View file

@ -31,8 +31,11 @@ class PodcastEpisodes extends BasePodcastEpisodes
$podcast = StationPodcastQuery::create()->findOneByDbPodcastId($podcastId); $podcast = StationPodcastQuery::create()->findOneByDbPodcastId($podcastId);
if ($podcast) { if ($podcast) {
$fileId = $this->getDbFileId(); $fileId = $this->getDbFileId();
// FIXME: this is an interim solution until we can do better...
$file = CcFilesQuery::create()->findPk($fileId);
$ext = FileDataHelper::getAudioMimeTypeArray()[$file->getDbMime()];
$key = Application_Model_Preference::getStationPodcastDownloadKey(); $key = Application_Model_Preference::getStationPodcastDownloadKey();
return Application_Common_HTTPHelper::getStationUrl(false)."rest/media/$fileId/download/$key"; return Application_Common_HTTPHelper::getStationUrl(false)."rest/media/$fileId/download/$key.$ext";
} }
return parent::getDbDownloadUrl(); return parent::getDbDownloadUrl();
} }

View file

@ -60,19 +60,33 @@ class Rest_Bootstrap extends Zend_Application_Module_Bootstrap
/** MediaController Routes **/ /** MediaController Routes **/
$downloadRoute = new Zend_Controller_Router_Route( $downloadRoute = new Zend_Controller_Router_Route(
'rest/media/:id/download/:download_key', 'rest/media/:id/download',
array( array(
'controller' => 'media', 'controller' => 'media',
'action' => 'download', 'action' => 'download',
'module' => 'rest' 'module' => 'rest'
), ),
array( array(
'id' => '\d+', 'id' => '\d+'
'download_key' => '\w*'
) )
); );
$router->addRoute('download', $downloadRoute); $router->addRoute('download', $downloadRoute);
$podcastEpisodeDownloadRoute = new Zend_Controller_Router_Route_Regex(
'rest/media/(?<id>\d+)/download/(?<download_key>.+)\.(?<file_ext>\w+)',
array(
'controller' => 'media',
'action' => 'download',
'module' => 'rest'
),
array(
1 => "id",
2 => "download_key",
3 => "file_ext"
)
);
$router->addRoute('podcast-episode-download', $podcastEpisodeDownloadRoute);
$clearLibraryRoute = new Zend_Controller_Router_Route( $clearLibraryRoute = new Zend_Controller_Router_Route(
'rest/media/clear', 'rest/media/clear',
array( array(

View file

@ -16,7 +16,7 @@
$logoImg = $this->element->getView()->logoImg; $logoImg = $this->element->getView()->logoImg;
$src = "data:image/png;base64,".$logoImg; $src = "data:image/png;base64,".$logoImg;
?> ?>
<img onError="this.onerror = '';this.style.visibility='hidden';$('#logo-remove-btn').hide();$('[id^=stationLogoRemove]').each(function(i,v){v.style.width=v.style.height=v.style.margin=v.style.padding='0px';});" id="logo-img" onload='resizeImg(this, 450, 450);' src="<?php echo $src ?>" /> <img onError="this.onerror = '';this.style.visibility='hidden';$('#logo-remove-btn').hide();$('[id^=stationLogoRemove]').each(function(i,v){v.style.width=v.style.height=v.style.margin=v.style.padding='0px';});" id="logo-img" onload='/*resizeImg(this, 450, 450);*/' src="<?php echo $src ?>" />
</div> </div>
<?php echo $this->element->getElement('locale')->render() ?> <?php echo $this->element->getElement('locale')->render() ?>