[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/')
),
),
// Backwards compatibility: Original bridge only had tags
'' => array(
'Tag' => array(
'tag' => array(
'name' => 'Query to search',
'exampleValue' => 'オリジナル',
@ -47,7 +46,7 @@ class PixivBridge extends BridgeAbstract {
// maps from URLs to json keys by context
const JSON_KEY_MAP = array(
'' => array(
'Tag' => array(
'illustrations/' => 'illust',
'manga/' => 'manga',
'novels/' => 'novel'
@ -64,8 +63,7 @@ class PixivBridge extends BridgeAbstract {
public function getName() {
switch($this->queriedContext) {
// Tags context
case '':
case 'Tag':
$context = 'Tag';
$query = $this->getInput('tag');
break;
@ -83,8 +81,7 @@ class PixivBridge extends BridgeAbstract {
public function getURI() {
switch($this->queriedContext) {
// Tags context
case '':
case 'Tag':
$uri = static::URI . 'tags/' . urlencode($this->getInput('tag') ?? '');
break;
case 'User':
@ -101,8 +98,7 @@ class PixivBridge extends BridgeAbstract {
private function getSearchURI($mode) {
switch($this->queriedContext) {
// Tags context
case '':
case 'Tag':
$query = urlencode($this->getInput('tag'));
$uri = static::URI . 'ajax/search/top/' . $query;
break;
@ -119,7 +115,7 @@ class PixivBridge extends BridgeAbstract {
private function getDataFromJSON($json, $json_key) {
$json = $json['body'][$json_key];
// Tags context contains subkey
if ($this->queriedContext == '') {
if ($this->queriedContext == 'Tag') {
$json = $json['data'];
}
return $json;
@ -143,7 +139,6 @@ class PixivBridge extends BridgeAbstract {
}
public function collectData() {
$content = $this->collectWorksArray();
$content = array_filter($content, function($v, $k) {

View File

@ -5,7 +5,6 @@ namespace RssBridge\Tests\Bridges;
use BridgeAbstract;
use BridgeInterface;
use FeedExpander;
use PixivBridge;
use PHPUnit\Framework\TestCase;
class BridgeImplementationTest extends TestCase {
@ -74,11 +73,8 @@ class BridgeImplementationTest extends TestCase {
if ($multiContexts) {
$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');
}
}
if (empty($params)) {
continue;