[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:
Yaman Qalieh 2022-06-24 05:31:24 -04:00 committed by GitHub
parent 92782e6c34
commit 1e7ad6ed51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 16 deletions

View File

@ -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) {

View File

@ -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,11 +73,8 @@ 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.
if (! ($this->obj instanceof PixivBridge)) {
$this->assertNotEmpty($context, 'The context name cannot be empty'); $this->assertNotEmpty($context, 'The context name cannot be empty');
} }
}
if (empty($params)) { if (empty($params)) {
continue; continue;