Fix bug in podcast download

This commit is contained in:
Duncan Sommerville 2015-11-27 16:48:44 -05:00
parent 5eaf74bbd9
commit eff7cd2f07
2 changed files with 9 additions and 17 deletions

View File

@ -329,8 +329,6 @@ class BandwidthLimitTask implements AirtimeTask {
/**
* Run the task
*
* @return void
*/
public function run() {
Application_Model_Preference::resetStationPodcastDownloadCounter();
@ -362,27 +360,21 @@ class TaskFactory {
*
* @return array all classes implementing the AirtimeTask interface
*/
private static function _getTaskClasses() {
public static function getTasks() {
return array_filter(get_declared_classes(), array(__CLASS__, "_isTask"));
}
/**
* @return array
*/
public static function getTasks() {
return self::_getTaskClasses();
}
/**
* Get an AirtimeTask based on a task type
* Get an AirtimeTask based on class name
*
* @param $task string the task type; uses AirtimeTask constants as an ENUM
* @param $task string name of the class implementing AirtimeTask to construct
*
* @return AirtimeTask|null return a task of the given type or null if no corresponding
* task exists or is implemented
* @return AirtimeTask|null return a task of the given type or null if no corresponding task exists
*/
public static function getTask($task) {
return new $task();
// Try to get a valid class name from the given string
if (!class_exists($task)) $task = str_replace(' ', '', ucwords($task)) . "Task";
return class_exists($task) ? new $task() : null;
}
}

View File

@ -145,7 +145,7 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir
'id' => $id,
'url' => $url,
'callback_url' => $stationUrl . 'rest/media',
'api_key' => $apiKey = $CC_CONFIG["apiKey"][0],
'api_key' => $CC_CONFIG["apiKey"][0],
);
$task = $this->_executeTask(static::$_CELERY_TASKS[self::DOWNLOAD], $data);
// Get the created ThirdPartyTaskReference and set the episode ID so
@ -251,7 +251,7 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir
public static function getStuckPendingImports() {
$timeout = gmdate(DEFAULT_TIMESTAMP_FORMAT, (microtime(true) - self::PENDING_EPISODE_TIMEOUT_SECONDS));
$episodes = PodcastEpisodesQuery::create()
->filterByDbFileId(null, Criteria::ISNULL)
->filterByDbFileId()
->find();
$stuckImports = array();
foreach ($episodes as $episode) {