mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-03-14 20:21:14 +03:00
fix(soundcloud): bug in prior cache refactor (#3516)
This commit is contained in:
parent
adc38e65d9
commit
1a529fac46
1 changed files with 11 additions and 18 deletions
|
@ -36,13 +36,17 @@ class SoundCloudBridge extends BridgeAbstract
|
|||
|
||||
private $feedTitle = null;
|
||||
private $feedIcon = null;
|
||||
private $clientIDCache = null;
|
||||
private $cache = null;
|
||||
|
||||
private $clientIdRegex = '/client_id.*?"(.+?)"/';
|
||||
private $widgetRegex = '/widget-.+?\.js/';
|
||||
|
||||
public function collectData()
|
||||
{
|
||||
$this->cache = RssBridge::getCache();
|
||||
$this->cache->setScope('SoundCloudBridge');
|
||||
$this->cache->setKey(['client_id']);
|
||||
|
||||
$res = $this->getUser($this->getInput('u'));
|
||||
|
||||
$this->feedTitle = $res->username;
|
||||
|
@ -116,22 +120,11 @@ HTML;
|
|||
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()
|
||||
{
|
||||
$this->initClientIDCache();
|
||||
|
||||
$clientID = $this->clientIDCache->loadData();
|
||||
$this->cache->setScope('SoundCloudBridge');
|
||||
$this->cache->setKey(['client_id']);
|
||||
$clientID = $this->cache->loadData();
|
||||
|
||||
if ($clientID == null) {
|
||||
return $this->refreshClientID();
|
||||
|
@ -142,8 +135,6 @@ HTML;
|
|||
|
||||
private function refreshClientID()
|
||||
{
|
||||
$this->initClientIDCache();
|
||||
|
||||
$playerHTML = getContents($this->playerUrl);
|
||||
|
||||
// Extract widget JS filenames from player page
|
||||
|
@ -161,7 +152,9 @@ HTML;
|
|||
|
||||
if (preg_match($this->clientIdRegex, $widgetJS, $matches)) {
|
||||
$clientID = $matches[1];
|
||||
$this->clientIDCache->saveData($clientID);
|
||||
$this->cache->setScope('SoundCloudBridge');
|
||||
$this->cache->setKey(['client_id']);
|
||||
$this->cache->saveData($clientID);
|
||||
|
||||
return $clientID;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue