1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-07-31 13:50:23 +02:00

fix(soundcloud): bug in prior cache refactor (#3516)

This commit is contained in:
Dag
2023-07-08 22:53:23 +02:00
committed by GitHub
parent adc38e65d9
commit 1a529fac46

View File

@@ -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;
}