2019-02-06 19:43:20 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class AppleMusicBridge extends BridgeAbstract
|
|
|
|
{
|
|
|
|
const NAME = 'Apple Music';
|
|
|
|
const URI = 'https://www.apple.com';
|
|
|
|
const DESCRIPTION = 'Fetches the latest releases from an artist';
|
2021-05-30 21:08:39 +03:00
|
|
|
const MAINTAINER = 'bockiii';
|
2019-11-01 20:06:38 +03:00
|
|
|
const PARAMETERS = [[
|
2021-05-30 21:08:39 +03:00
|
|
|
'artist' => [
|
|
|
|
'name' => 'Artist ID',
|
|
|
|
'exampleValue' => '909253',
|
2019-02-06 19:43:20 +03:00
|
|
|
'required' => true,
|
2019-11-01 20:06:38 +03:00
|
|
|
],
|
2021-05-30 21:08:39 +03:00
|
|
|
'limit' => [
|
|
|
|
'name' => 'Latest X Releases (max 50)',
|
|
|
|
'defaultValue' => '10',
|
2019-02-06 19:43:20 +03:00
|
|
|
'required' => true,
|
2021-05-30 21:08:39 +03:00
|
|
|
],
|
2019-11-01 20:06:38 +03:00
|
|
|
]];
|
2019-02-06 19:43:20 +03:00
|
|
|
const CACHE_TIMEOUT = 21600; // 6 hours
|
|
|
|
|
|
|
|
public function collectData()
|
|
|
|
{
|
2021-05-30 21:08:39 +03:00
|
|
|
# Limit the amount of releases to 50
|
|
|
|
if ($this->getInput('limit') > 50) {
|
|
|
|
$limit = 50;
|
|
|
|
} else {
|
|
|
|
$limit = $this->getInput('limit');
|
|
|
|
}
|
|
|
|
|
|
|
|
$url = 'https://itunes.apple.com/lookup?id='
|
|
|
|
. $this->getInput('artist')
|
|
|
|
. '&entity=album&limit='
|
|
|
|
. $limit .
|
|
|
|
'&sort=recent';
|
2022-01-02 12:36:09 +03:00
|
|
|
$html = getSimpleHTMLDOM($url);
|
2019-02-06 19:43:20 +03:00
|
|
|
|
|
|
|
$json = json_decode($html);
|
|
|
|
|
2021-05-30 21:08:39 +03:00
|
|
|
foreach ($json->results as $obj) {
|
|
|
|
if ($obj->wrapperType === 'collection') {
|
2023-07-31 21:43:18 +03:00
|
|
|
$copyright = $obj->copyright ?? '';
|
|
|
|
|
2019-11-01 20:06:38 +03:00
|
|
|
$this->items[] = [
|
2021-05-30 21:08:39 +03:00
|
|
|
'title' => $obj->artistName . ' - ' . $obj->collectionName,
|
|
|
|
'uri' => $obj->collectionViewUrl,
|
|
|
|
'timestamp' => $obj->releaseDate,
|
|
|
|
'enclosures' => $obj->artworkUrl100,
|
|
|
|
'content' => '<a href=' . $obj->collectionViewUrl
|
|
|
|
. '><img src="' . $obj->artworkUrl100 . '" /></a><br><br>'
|
|
|
|
. $obj->artistName . ' - ' . $obj->collectionName
|
|
|
|
. '<br>'
|
2023-07-31 21:43:18 +03:00
|
|
|
. $copyright,
|
2019-11-01 20:06:38 +03:00
|
|
|
];
|
2019-02-06 19:43:20 +03:00
|
|
|
}
|
|
|
|
}
|
2020-11-16 20:15:39 +03:00
|
|
|
}
|
2019-02-06 19:43:20 +03:00
|
|
|
}
|