private function getInvalidMetadata(FileUpload $song) : array
 {
     $invalidMetadata = [];
     $songReader = new \SongReader($song->getTemporaryFile());
     if (!$songReader->getDuration()) {
         $invalidMetadata[] = 'playtime_string';
     }
     if (!$songReader->getAuthor()) {
         $invalidMetadata[] = 'artist';
     }
     if (!$songReader->getTitle()) {
         $invalidMetadata[] = 'title';
     }
     if (!$songReader->getAlbum()) {
         $invalidMetadata[] = 'album';
     }
     return $invalidMetadata;
 }
 public function getAlbumCoverURL(string $songPath) : string
 {
     $songReader = new \SongReader($songPath);
     $client = new Client(['base_uri' => 'http://www.slothradio.com/', 'timeout' => 2.0]);
     $response = $client->request('GET', 'covers/', ['query' => ['artist' => $songReader->getAuthor(), 'album' => $songReader->getAlbum()]]);
     $html = $response->getBody()->getContents();
     $dom = new Dom();
     $dom->load($html);
     $images = $dom->find('#content > div.album0 > img');
     if (count($images) > 0) {
         /** @var Dom\HtmlNode $image */
         $image = $images[0];
         $albumURL = $image->getAttribute('src');
     } else {
         $albumURL = '';
     }
     return $albumURL;
 }
Пример #3
0
 public function loadMetadata(\SongReader $songReader)
 {
     $songReader->getTitle() ? $this->title = $songReader->getTitle() : null;
     $songReader->getAuthor() ? $this->artist = $songReader->getAuthor() : null;
     $songReader->getDuration() ? $this->duration = $songReader->getDuration() : null;
 }