mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-10 08:58:50 +00:00
fix(soundcloud): bug in prior cache refactor (#3516)
This commit is contained in:
parent
adc38e65d9
commit
1a529fac46
@ -36,13 +36,17 @@ class SoundCloudBridge extends BridgeAbstract
|
|||||||
|
|
||||||
private $feedTitle = null;
|
private $feedTitle = null;
|
||||||
private $feedIcon = null;
|
private $feedIcon = null;
|
||||||
private $clientIDCache = null;
|
private $cache = null;
|
||||||
|
|
||||||
private $clientIdRegex = '/client_id.*?"(.+?)"/';
|
private $clientIdRegex = '/client_id.*?"(.+?)"/';
|
||||||
private $widgetRegex = '/widget-.+?\.js/';
|
private $widgetRegex = '/widget-.+?\.js/';
|
||||||
|
|
||||||
public function collectData()
|
public function collectData()
|
||||||
{
|
{
|
||||||
|
$this->cache = RssBridge::getCache();
|
||||||
|
$this->cache->setScope('SoundCloudBridge');
|
||||||
|
$this->cache->setKey(['client_id']);
|
||||||
|
|
||||||
$res = $this->getUser($this->getInput('u'));
|
$res = $this->getUser($this->getInput('u'));
|
||||||
|
|
||||||
$this->feedTitle = $res->username;
|
$this->feedTitle = $res->username;
|
||||||
@ -116,22 +120,11 @@ HTML;
|
|||||||
return parent::getName();
|
return parent::getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function initClientIDCache()
|
|
||||||
{
|
|
||||||
if ($this->clientIDCache !== null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->clientIDCache = RssBridge::getCache();
|
|
||||||
$this->clientIDCache->setScope('SoundCloudBridge');
|
|
||||||
$this->clientIDCache->setKey(['client_id']);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getClientID()
|
private function getClientID()
|
||||||
{
|
{
|
||||||
$this->initClientIDCache();
|
$this->cache->setScope('SoundCloudBridge');
|
||||||
|
$this->cache->setKey(['client_id']);
|
||||||
$clientID = $this->clientIDCache->loadData();
|
$clientID = $this->cache->loadData();
|
||||||
|
|
||||||
if ($clientID == null) {
|
if ($clientID == null) {
|
||||||
return $this->refreshClientID();
|
return $this->refreshClientID();
|
||||||
@ -142,8 +135,6 @@ HTML;
|
|||||||
|
|
||||||
private function refreshClientID()
|
private function refreshClientID()
|
||||||
{
|
{
|
||||||
$this->initClientIDCache();
|
|
||||||
|
|
||||||
$playerHTML = getContents($this->playerUrl);
|
$playerHTML = getContents($this->playerUrl);
|
||||||
|
|
||||||
// Extract widget JS filenames from player page
|
// Extract widget JS filenames from player page
|
||||||
@ -161,7 +152,9 @@ HTML;
|
|||||||
|
|
||||||
if (preg_match($this->clientIdRegex, $widgetJS, $matches)) {
|
if (preg_match($this->clientIdRegex, $widgetJS, $matches)) {
|
||||||
$clientID = $matches[1];
|
$clientID = $matches[1];
|
||||||
$this->clientIDCache->saveData($clientID);
|
$this->cache->setScope('SoundCloudBridge');
|
||||||
|
$this->cache->setKey(['client_id']);
|
||||||
|
$this->cache->saveData($clientID);
|
||||||
|
|
||||||
return $clientID;
|
return $clientID;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user