mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-12 01:48:48 +00:00
[PixivBridge] Remove backwards compatability hack (#2846)
There is no need for this since the context is guessed if it's not provided.
This commit is contained in:
parent
92782e6c34
commit
1e7ad6ed51
@ -28,8 +28,7 @@ class PixivBridge extends BridgeAbstract {
|
|||||||
'Novels' => 'novels/')
|
'Novels' => 'novels/')
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// Backwards compatibility: Original bridge only had tags
|
'Tag' => array(
|
||||||
'' => array(
|
|
||||||
'tag' => array(
|
'tag' => array(
|
||||||
'name' => 'Query to search',
|
'name' => 'Query to search',
|
||||||
'exampleValue' => 'オリジナル',
|
'exampleValue' => 'オリジナル',
|
||||||
@ -47,7 +46,7 @@ class PixivBridge extends BridgeAbstract {
|
|||||||
|
|
||||||
// maps from URLs to json keys by context
|
// maps from URLs to json keys by context
|
||||||
const JSON_KEY_MAP = array(
|
const JSON_KEY_MAP = array(
|
||||||
'' => array(
|
'Tag' => array(
|
||||||
'illustrations/' => 'illust',
|
'illustrations/' => 'illust',
|
||||||
'manga/' => 'manga',
|
'manga/' => 'manga',
|
||||||
'novels/' => 'novel'
|
'novels/' => 'novel'
|
||||||
@ -64,8 +63,7 @@ class PixivBridge extends BridgeAbstract {
|
|||||||
|
|
||||||
public function getName() {
|
public function getName() {
|
||||||
switch($this->queriedContext) {
|
switch($this->queriedContext) {
|
||||||
// Tags context
|
case 'Tag':
|
||||||
case '':
|
|
||||||
$context = 'Tag';
|
$context = 'Tag';
|
||||||
$query = $this->getInput('tag');
|
$query = $this->getInput('tag');
|
||||||
break;
|
break;
|
||||||
@ -83,8 +81,7 @@ class PixivBridge extends BridgeAbstract {
|
|||||||
|
|
||||||
public function getURI() {
|
public function getURI() {
|
||||||
switch($this->queriedContext) {
|
switch($this->queriedContext) {
|
||||||
// Tags context
|
case 'Tag':
|
||||||
case '':
|
|
||||||
$uri = static::URI . 'tags/' . urlencode($this->getInput('tag') ?? '');
|
$uri = static::URI . 'tags/' . urlencode($this->getInput('tag') ?? '');
|
||||||
break;
|
break;
|
||||||
case 'User':
|
case 'User':
|
||||||
@ -101,8 +98,7 @@ class PixivBridge extends BridgeAbstract {
|
|||||||
|
|
||||||
private function getSearchURI($mode) {
|
private function getSearchURI($mode) {
|
||||||
switch($this->queriedContext) {
|
switch($this->queriedContext) {
|
||||||
// Tags context
|
case 'Tag':
|
||||||
case '':
|
|
||||||
$query = urlencode($this->getInput('tag'));
|
$query = urlencode($this->getInput('tag'));
|
||||||
$uri = static::URI . 'ajax/search/top/' . $query;
|
$uri = static::URI . 'ajax/search/top/' . $query;
|
||||||
break;
|
break;
|
||||||
@ -119,7 +115,7 @@ class PixivBridge extends BridgeAbstract {
|
|||||||
private function getDataFromJSON($json, $json_key) {
|
private function getDataFromJSON($json, $json_key) {
|
||||||
$json = $json['body'][$json_key];
|
$json = $json['body'][$json_key];
|
||||||
// Tags context contains subkey
|
// Tags context contains subkey
|
||||||
if ($this->queriedContext == '') {
|
if ($this->queriedContext == 'Tag') {
|
||||||
$json = $json['data'];
|
$json = $json['data'];
|
||||||
}
|
}
|
||||||
return $json;
|
return $json;
|
||||||
@ -143,7 +139,6 @@ class PixivBridge extends BridgeAbstract {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function collectData() {
|
public function collectData() {
|
||||||
|
|
||||||
$content = $this->collectWorksArray();
|
$content = $this->collectWorksArray();
|
||||||
|
|
||||||
$content = array_filter($content, function($v, $k) {
|
$content = array_filter($content, function($v, $k) {
|
||||||
|
@ -5,7 +5,6 @@ namespace RssBridge\Tests\Bridges;
|
|||||||
use BridgeAbstract;
|
use BridgeAbstract;
|
||||||
use BridgeInterface;
|
use BridgeInterface;
|
||||||
use FeedExpander;
|
use FeedExpander;
|
||||||
use PixivBridge;
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class BridgeImplementationTest extends TestCase {
|
class BridgeImplementationTest extends TestCase {
|
||||||
@ -74,10 +73,7 @@ class BridgeImplementationTest extends TestCase {
|
|||||||
if ($multiContexts) {
|
if ($multiContexts) {
|
||||||
$this->assertIsString($context, 'invalid context name');
|
$this->assertIsString($context, 'invalid context name');
|
||||||
|
|
||||||
// Pixiv has a context that is the empty string, for BC.
|
$this->assertNotEmpty($context, 'The context name cannot be empty');
|
||||||
if (! ($this->obj instanceof PixivBridge)) {
|
|
||||||
$this->assertNotEmpty($context, 'The context name cannot be empty');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($params)) {
|
if (empty($params)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user