Example #1
0
 /**
  * insert_local_video
  * This inserts a video file into the video file table the tag
  * information we can get is super sketchy so it's kind of a crap shoot
  * here
  */
 public function insert_local_video($file, $options = array())
 {
     /* Create the vainfo object and get info */
     $gtypes = $this->get_gather_types('video');
     $vainfo = new vainfo($file, $gtypes, '', '', '', $this->sort_pattern, $this->rename_pattern);
     $vainfo->get_info();
     $tag_name = vainfo::get_tag_type($vainfo->tags, 'metadata_order_video');
     $results = vainfo::clean_tag_info($vainfo->tags, $tag_name, $file);
     $results['catalog'] = $this->id;
     $id = Video::insert($results, $gtypes, $options);
     if ($results['art']) {
         $art = new Art($id, 'video');
         $art->insert_url($results['art']);
         if (AmpConfig::get('generate_video_preview')) {
             Video::generate_preview($id);
         }
     } else {
         $this->added_videos_to_gather[] = $id;
     }
     $this->_filecache[strtolower($file)] = 'v_' . $id;
     return $id;
 }
Example #2
0
 /**
  * update_media_from_tags
  * This is a 'wrapper' function calls the update function for the media
  * type in question
  */
 public static function update_media_from_tags($media, $sort_pattern = '', $rename_pattern = '')
 {
     // Check for patterns
     if (!$sort_pattern or !$rename_pattern) {
         $catalog = Catalog::create_from_id($media->catalog);
         $sort_pattern = $catalog->sort_pattern;
         $rename_pattern = $catalog->rename_pattern;
     }
     debug_event('tag-read', 'Reading tags from ' . $media->file, 5);
     $vainfo = new vainfo($media->file, '', '', '', $sort_pattern, $rename_pattern);
     $vainfo->get_info();
     $key = vainfo::get_tag_type($vainfo->tags);
     $results = vainfo::clean_tag_info($vainfo->tags, $key, $media->file);
     // Figure out what type of object this is and call the right
     // function, giving it the stuff we've figured out above
     $name = get_class($media) == 'Song' ? 'song' : 'video';
     $function = 'update_' . $name . '_from_tags';
     $return = call_user_func(array('Catalog', $function), $results, $media);
     return $return;
 }
Example #3
0
 public function gather()
 {
     if (!empty($this->source)) {
         $podcast = new Podcast($this->podcast);
         $file = $podcast->get_root_path();
         if (!empty($file)) {
             $pinfo = pathinfo($this->source);
             $file .= DIRECTORY_SEPARATOR . $this->id . '-' . $pinfo['basename'];
             debug_event('podcast_episode', 'Downloading ' . $this->source . ' to ' . $file . ' ...', 5);
             if (file_put_contents($file, fopen($this->source, 'r')) !== false) {
                 debug_event('podcast_episode', 'Download completed.', 5);
                 $this->file = $file;
                 $vainfo = new vainfo($this->file);
                 $vainfo->get_info();
                 $key = vainfo::get_tag_type($vainfo->tags);
                 $infos = vainfo::clean_tag_info($vainfo->tags, $key, $file);
                 // No time information, get it from file
                 if ($this->time <= 0) {
                     $this->time = $infos['time'];
                 }
                 $this->size = $infos['size'];
                 $sql = "UPDATE `podcast_episode` SET `file` = ?, `size` = ?, `time` = ?, `state` = 'completed' WHERE `id` = ?";
                 Dba::write($sql, array($this->file, $this->size, $this->time, $this->id));
             } else {
                 debug_event('podcast_episode', 'Error when downloading podcast episode.', 1);
             }
         }
     } else {
         debug_event('podcast_episode', 'Cannot download podcast episode ' . $this->id . ', empty source.', 3);
     }
 }
Example #4
0
 /**
  * insert_local_video
  * This inserts a video file into the video file table the tag
  * information we can get is super sketchy so it's kind of a crap shoot
  * here
  */
 public function insert_local_video($file, $filesize)
 {
     /* Create the vainfo object and get info */
     $vainfo = new vainfo($file, '', '', '', $this->sort_pattern, $this->rename_pattern);
     $vainfo->get_info();
     $tag_name = vainfo::get_tag_type($vainfo->tags);
     $results = vainfo::clean_tag_info($vainfo->tags, $tag_name, $file);
     $rezx = intval($results['resolution_x']);
     $rezy = intval($results['resolution_y']);
     // UNUSED CURRENTLY
     $comment = $results['comment'];
     $year = $results['year'];
     $disk = $results['disk'];
     $sql = "INSERT INTO `video` (`file`,`catalog`,`title`,`video_codec`,`audio_codec`,`resolution_x`,`resolution_y`,`size`,`time`,`mime`) " . " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
     $params = array($file, $this->id, $results['title'], $results['video_codec'], $results['audio_codec'], $rezx, $rezy, $filesize, $results['time'], $results['mime']);
     $db_results = Dba::write($sql, $params);
     return true;
 }
Example #5
0
 /**
  * _insert_local_song
  *
  * Insert a song that isn't already in the database.
  */
 private function insert_song($client, $file, $filesize)
 {
     if ($this->check_remote_song($this->get_virtual_path($file))) {
         debug_event('dropbox_catalog', 'Skipping existing song ' . $file, 5);
     } else {
         $origin = $file;
         $islocal = false;
         $fpchunk = 0;
         // Get temporary chunked file from Dropbox to (hope) read metadata
         if ($this->getchunk) {
             $fpchunk = tmpfile();
             $metadata = $client->getFile($file, $fpchunk, null, 40960);
             if ($metadata == null) {
                 debug_event('dropbox_catalog', 'Cannot get Dropbox file: ' . $file, 5);
             }
             $streammeta = stream_get_meta_data($fpchunk);
             $file = $streammeta['uri'];
             $islocal = true;
         }
         $vainfo = new vainfo($file, '', '', '', $this->sort_pattern, $this->rename_pattern, $islocal);
         $vainfo->forceSize($filesize);
         $vainfo->get_info();
         $key = vainfo::get_tag_type($vainfo->tags);
         $results = vainfo::clean_tag_info($vainfo->tags, $key, $file);
         // Remove temp file
         if ($fpchunk) {
             fclose($fpchunk);
         }
         // Set the remote path
         $results['file'] = $origin;
         $results['catalog'] = $this->id;
         if (!empty($results['artist']) && !empty($results['album'])) {
             $results['file'] = $this->get_virtual_path($results['file']);
             Song::insert($results);
             $this->count++;
         } else {
             debug_event('results', $results['file'] . " ignored because it is an orphan songs. Please check your catalog patterns.", 5);
         }
     }
 }