Beispiel #1
0
 public function uploadSong($local_path)
 {
     if (!$this->title) {
         $this->title = 'No Title';
     }
     if (!$this->artist) {
         $this->artist = 'Various Artists';
     }
     // Create a new path based on the song metadata.
     $song_path_base = $this->artist . ' - ' . $this->title;
     $song_path_base = preg_replace('/[^\\w\\s-]+/', '', $song_path_base);
     $song_path_base = preg_replace('/\\s\\s+/', ' ', $song_path_base);
     $new_path = 'song_uploads/' . $song_path_base . '.' . \DF\File::getFileExtension($local_path);
     // Upload to remote service.
     \PVL\Service\AmazonS3::upload($local_path, $new_path);
     $this->song_url = $new_path;
     return \PVL\Service\AmazonS3::url($new_path);
 }
Beispiel #2
0
 public static function getEpisodeRotatorUrl($episode, $podcast = NULL, $source = NULL)
 {
     if ($episode instanceof self) {
         if ($podcast === null) {
             $podcast = $episode->podcast;
         }
         if ($source === null) {
             $source = $episode->source;
         }
     }
     if ($episode['banner_url'] && !$podcast['is_adult'] && !$podcast['always_use_banner_url']) {
         $image_path_base = 'podcast_episodes/' . $episode['guid'] . '.jpg';
         $image_path = AmazonS3::path($image_path_base);
         // Crop remote banner URL if the local version doesn't already exist.
         if (file_exists($image_path)) {
             return AmazonS3::url($image_path_base);
         } else {
             $temp_path_ext = \DF\File::getFileExtension($episode['banner_url']);
             $temp_path = DF_INCLUDE_TEMP . DIRECTORY_SEPARATOR . '/podcast_episodes/podcast_episode_' . $episode['id'] . '_temp.' . $temp_path_ext;
             @mkdir(dirname($temp_path));
             @copy($episode['banner_url'], $temp_path);
             if (file_exists($temp_path)) {
                 try {
                     Image::resizeImage($temp_path, $temp_path, 600, 300, TRUE);
                     AmazonS3::upload($temp_path, $image_path_base);
                     return AmazonS3::url($image_path_base);
                 } catch (\Exception $e) {
                 }
             }
         }
     }
     if ($podcast !== null && !empty($podcast['banner_url'])) {
         // Reference the podcast's existing banner URL.
         return AmazonS3::url($podcast['banner_url']);
     }
     if ($source !== null) {
         return Url::content('images/podcast_' . $source['type'] . '_banner.png');
     }
     return Url::content('images/podcast_default.png');
 }