mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-03-14 20:21:14 +03: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
2 changed files with 7 additions and 16 deletions
|
@ -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) {
|
||||
|
|
|
@ -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,10 +73,7 @@ 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');
|
||||
}
|
||||
$this->assertNotEmpty($context, 'The context name cannot be empty');
|
||||
}
|
||||
|
||||
if (empty($params)) {
|
||||
|
|
Loading…
Add table
Reference in a new issue