function saveFileInfo($filepath, $mainContent = false)
 {
     global $db;
     // convert boolean into pgsql format
     if ($mainContent) {
         $mainContent = 'true';
     } else {
         $mainContent = 'false';
     }
     // get audio properties of file
     $file = new sotf_AudioFile($filepath);
     //ADDED BY BUDDHAFLY 06-02-20
     if ($file->isVideo()) {
         $file = new sotf_VideoFile($filepath);
     }
     //--------------------------
     // find if this is an existing file
     if ($file->isAudio() || $file->isVideo()) {
         //CHANGED BY BUDDHAFLY 06-02-20
         $fileInfo = new sotf_NodeObject('sotf_media_files');
     } else {
         $fileInfo = new sotf_NodeObject('sotf_other_files');
     }
     $fileInfo->set("prog_id", $this->id);
     $fileInfo->set("filename", $file->name);
     $fileInfo->find();
     // save file info into database
     //ADDED BY BUDDHAFLY 06-02-20
     if ($file->isVideo()) {
         $fileInfo->set('play_length', round($file->duration));
         $fileInfo->set('type', $file->type);
         if (is_numeric($file->bitrate)) {
             // constant bitrate
             $fileInfo->set('kbps', round($file->bitrate));
             $fileInfo->set('vbr', 'f');
         } else {
             // variable bitrate
             $fileInfo->set('kbps', round($file->average_bitrate));
             $fileInfo->set('vbr', 't');
         }
         $fileInfo->set('format', $file->getFormatFilename());
         $fileInfo->set('main_content', $mainContent);
         $fileInfo->set('codec', $file->codec);
         $fileInfo->set('frame_rate', $file->frame_rate);
         $fileInfo->set('resolution_x', $file->resolution_x);
         $fileInfo->set('resolution_y', $file->resolution_y);
         $fileInfo->set('pixel_aspect_ratio', $file->pixel_aspect_ratio);
         //manage access rights for video
         $fileInfo->set('download_access', 't');
         $fileInfo->set('stream_access', 'f');
     } else {
         if ($file->isAudio()) {
             $fileInfo->set('play_length', round($file->duration));
             $fileInfo->set('type', $file->type);
             if (is_numeric($file->bitrate)) {
                 // constant bitrate
                 $fileInfo->set('kbps', round($file->bitrate));
                 $fileInfo->set('vbr', 'f');
             } else {
                 // variable bitrate
                 $fileInfo->set('kbps', round($file->average_bitrate));
                 $fileInfo->set('vbr', 't');
             }
             $fileInfo->set('format', $file->getFormatFilename());
             $fileInfo->set('main_content', $mainContent);
         }
     }
     $fstat = stat($filepath);
     $fileInfo->set('filesize', $fstat['size']);
     $fileInfo->set('last_modified', $db->getTimestampTz($fstat['mtime']));
     $fileInfo->set('mime_type', $file->mimetype);
     $success = $fileInfo->save();
     //if(!$success)
     //	raiseError("could not write into database");
     // change id3 tags in file
     $this->saveID3($file);
     return $fileInfo->id;
 }