-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Big revamp for artist and album info
- Loading branch information
Showing
31 changed files
with
608 additions
and
308 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace App\Events; | ||
|
||
use App\Models\Album; | ||
use Illuminate\Queue\SerializesModels; | ||
|
||
class AlbumInformationFetched extends Event | ||
{ | ||
use SerializesModels; | ||
|
||
private $album; | ||
private $information; | ||
|
||
public function __construct(Album $album, array $information) | ||
{ | ||
$this->album = $album; | ||
$this->information = $information; | ||
} | ||
|
||
/** | ||
* @return Album | ||
*/ | ||
public function getAlbum() | ||
{ | ||
return $this->album; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getInformation() | ||
{ | ||
return $this->information; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace App\Events; | ||
|
||
use App\Models\Artist; | ||
use Illuminate\Queue\SerializesModels; | ||
|
||
class ArtistInformationFetched | ||
{ | ||
use SerializesModels; | ||
|
||
private $artist; | ||
private $information; | ||
|
||
public function __construct(Artist $artist, array $information) | ||
{ | ||
$this->artist = $artist; | ||
$this->information = $information; | ||
} | ||
|
||
/** | ||
* @return Artist | ||
*/ | ||
public function getArtist() | ||
{ | ||
return $this->artist; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getInformation() | ||
{ | ||
return $this->information; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace App\Listeners; | ||
|
||
use App\Events\AlbumInformationFetched; | ||
use App\Services\MediaMetadataService; | ||
|
||
class DownloadAlbumCover | ||
{ | ||
private $mediaMetadataService; | ||
|
||
public function __construct(MediaMetadataService $mediaMetadataService) | ||
{ | ||
$this->mediaMetadataService = $mediaMetadataService; | ||
} | ||
|
||
public function handle(AlbumInformationFetched $event) | ||
{ | ||
$info = $event->getInformation(); | ||
$album = $event->getAlbum(); | ||
|
||
$image = array_get($info, 'image'); | ||
|
||
// If our current album has no cover, and Last.fm has one, why don't we steal it? | ||
if (!$album->has_cover && is_string($image) && ini_get('allow_url_fopen')) { | ||
$this->mediaMetadataService->downloadAlbumCover($album, $image); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace App\Listeners; | ||
|
||
use App\Events\ArtistInformationFetched; | ||
use App\Services\MediaMetadataService; | ||
|
||
class DownloadArtistImage | ||
{ | ||
private $mediaMetadataService; | ||
|
||
public function __construct(MediaMetadataService $mediaMetadataService) | ||
{ | ||
$this->mediaMetadataService = $mediaMetadataService; | ||
} | ||
|
||
public function handle(ArtistInformationFetched $event) | ||
{ | ||
$info = $event->getInformation(); | ||
$artist = $event->getArtist(); | ||
|
||
$image = array_get($info, 'image'); | ||
|
||
// If our current album has no cover, and Last.fm has one, why don't we steal it? | ||
if (!$artist->has_image && is_string($image) && ini_get('allow_url_fopen')) { | ||
$this->mediaMetadataService->downloadArtistImage($artist, $image); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.