[AppleMusicBridge] Use title from website (#1855)

This commit is contained in:
David Pedersen 2020-11-16 18:15:39 +01:00 committed by GitHub
parent 0b494d9c0e
commit 5729e069e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -20,6 +20,8 @@ class AppleMusicBridge extends BridgeAbstract {
)); ));
const CACHE_TIMEOUT = 21600; // 6 hours const CACHE_TIMEOUT = 21600; // 6 hours
private $title;
public function collectData() { public function collectData() {
$url = $this->getInput('url'); $url = $this->getInput('url');
$html = getSimpleHTMLDOM($url) $html = getSimpleHTMLDOM($url)
@ -27,6 +29,8 @@ class AppleMusicBridge extends BridgeAbstract {
$imgSize = $this->getInput('imgSize'); $imgSize = $this->getInput('imgSize');
$this->title = $html->find('title', 0)->innertext;
// Grab the json data from the page // Grab the json data from the page
$html = $html->find('script[id=shoebox-ember-data-store]', 0); $html = $html->find('script[id=shoebox-ember-data-store]', 0);
$html = strstr($html, '{'); $html = strstr($html, '{');
@ -59,4 +63,8 @@ class AppleMusicBridge extends BridgeAbstract {
return $a['timestamp'] < $b['timestamp']; return $a['timestamp'] < $b['timestamp'];
}); });
} }
public function getName() {
return $this->title ?: parent::getName();
}
} }