function addProg($prg, $fileid = '')
 {
     if (empty($fileid)) {
         // find a file to listen
         $fileid = $prg->selectFileToListen();
         if (!$fileid) {
             raiseError("no_file_to_listen");
         }
     }
     $file = new sotf_NodeObject("sotf_media_files", $fileid);
     if (!$prg->isLocal()) {
         $node = sotf_Node::getNodeById($file->getNodeId());
         $path = $node->get('url') . "/listen.php?id=" . $prg->id . "&fileid=" . $file->id;
         $this->add(array('path' => $path, 'url' => $path));
         return;
     }
     #	 if($prg->get('published') != 't' || $file->get('stream_access') != 't') {
     #		raiseError("no_listen_access");
     #	 }
     if (!$prg->isPublished()) {
         raiseError("not_published_yet");
     }
     if (!$file->getBool('stream_access')) {
         raiseError("no_listen_access");
     }
     if (!$prg->canListen()) {
         raiseError("no_listen_access");
     }
     $filepath = $prg->getFilePath($file);
     $index = sotf_AudioCheck::getRequestIndex(new sotf_AudioFile($filepath));
     debug("audio index", $index);
     if (!$index) {
         $index = '0';
     }
     // add jingle for station (if exists)
     $station = $prg->getStation();
     $jfile = $station->getJingle($index);
     if ($jfile) {
         $this->add(array('id' => $station->id, 'path' => $jfile, 'jingle' => 1, 'name' => '_station_jingle'));
     }
     // add jingle for series (if exists)
     $series = $prg->getSeries();
     if ($series) {
         $jfile = $series->getJingle($index);
         if ($jfile) {
             $this->add(array('id' => $series->id, 'path' => $jfile, 'jingle' => 1, 'name' => '_series_jingle'));
         }
     }
     // add program file
     $filepath = $prg->getFilePath($file);
     $this->add(array('id' => $prg->id, 'path' => $filepath, 'name' => urlencode($prg->get('title')), 'length' => $prg->get('length')));
     // temp: set title
     $title = $prg->get("title");
     $title = preg_replace('/\\s+/', '_', $title);
     $this->name = urlencode($title);
     // save stats
     $prg->addStat($file->get('id'), 'listens');
 }