Ejemplo n.º 1
0
    exit;
}
switch ($_REQUEST['action']) {
    case 'sync':
        if (!Access::check('interface', '75')) {
            debug_event('DENIED', $GLOBALS['user']->username . ' attempted to sync podcast', 1);
            exit;
        }
        if (isset($_REQUEST['podcast_id'])) {
            $podcast = new Podcast($_REQUEST['podcast_id']);
            if ($podcast->id) {
                $podcast->sync_episodes(true);
            } else {
                debug_event('podcast', 'Cannot found podcast', 1);
            }
        } elseif (isset($_REQUEST['podcast_episode_id'])) {
            $episode = new Podcast_Episode($_REQUEST['podcast_episode_id']);
            if ($episode->id) {
                $episode->gather();
            } else {
                debug_event('podcast', 'Cannot found podcast episode', 1);
            }
        }
        $results['rfc3514'] = '0x1';
        break;
    default:
        $results['rfc3514'] = '0x1';
        break;
}
// We always do this
echo xoutput_from_array($results);
Ejemplo n.º 2
0
 /**
  * downloadPodcastEpisode
  * Request the server to download a podcast episode
  * Takes the podcast episode id in parameter.
  */
 public static function downloadpodcastepisode($input)
 {
     self::check_version($input, "1.9.0");
     $id = self::check_parameter($input, 'id');
     if (AmpConfig::get('podcast') && Access::check('interface', 75)) {
         $episode = new Podcast_Episode(Subsonic_XML_Data::getAmpacheId($id));
         if ($episode->id) {
             $episode->gather();
             $r = Subsonic_XML_Data::createSuccessResponse();
         } else {
             $r = Subsonic_XML_Data::createError(Subsonic_XML_Data::SSERROR_DATA_NOTFOUND);
         }
     } else {
         $r = Subsonic_XML_Data::createError(Subsonic_XML_Data::SSERROR_UNAUTHORIZED);
     }
     self::apiOutput($input, $r);
 }
Ejemplo n.º 3
0
 public function add_episodes($episodes, $afterdate = 0, $gather = false)
 {
     foreach ($episodes as $episode) {
         $this->add_episode($episode, $afterdate);
     }
     // Select episodes to download
     $dlnb = AmpConfig::get('podcast_new_download');
     if ($dlnb != 0) {
         $sql = "SELECT `podcast_episode`.`id` FROM `podcast_episode` INNER JOIN `podcast` ON `podcast`.`id` = `podcast_episode`.`podcast` " . "WHERE `podcast`.`id` = ? AND `podcast_episode`.`addition_time` > `podcast`.`lastsync` " . "ORDER BY `podcast_episode`.`pubdate` DESC";
         if ($dlnb != -1) {
             $sql .= " LIMIT " . $dlnb;
         }
         $db_results = Dba::read($sql, array($this->id));
         while ($row = Dba::fetch_row($db_results)) {
             $episode = new Podcast_Episode($row[0]);
             $episode->change_state('pending');
             if ($gather) {
                 $episode->gather();
             }
         }
     }
     // Remove items outside limit
     $keepnb = AmpConfig::get('podcast_keep');
     if ($keepnb > 0) {
         $sql = "SELECT `podcast_episode`.`id` FROM `podcast_episode` WHERE `podcast_episode`.`podcast` = ? " . "ORDER BY `podcast_episode`.`pubdate` DESC LIMIT " . $keepnb . ",18446744073709551615";
         $db_results = Dba::read($sql, array($this->id));
         while ($row = Dba::fetch_row($db_results)) {
             $episode = new Podcast_Episode($row[0]);
             $episode->remove();
         }
     }
     $this->update_lastsync(time());
 }