aboutsummaryrefslogtreecommitdiff
path: root/bridges/WorldCosplayBridge.php
diff options
context:
space:
mode:
Diffstat (limited to 'bridges/WorldCosplayBridge.php')
-rw-r--r--bridges/WorldCosplayBridge.php266
1 files changed, 135 insertions, 131 deletions
diff --git a/bridges/WorldCosplayBridge.php b/bridges/WorldCosplayBridge.php
index b60d7948..cb28eee2 100644
--- a/bridges/WorldCosplayBridge.php
+++ b/bridges/WorldCosplayBridge.php
@@ -1,142 +1,146 @@
<?php
-class WorldCosplayBridge extends BridgeAbstract {
- const NAME = 'WorldCosplay Bridge';
- const URI = 'https://worldcosplay.net/';
- const DESCRIPTION = 'Returns WorldCosplay photos';
- const MAINTAINER = 'AxorPL';
- const API_CHARACTER = 'api/photo/list.json?character_id=%u&limit=%u';
- const API_COSPLAYER = 'api/member/photos.json?member_id=%u&limit=%u';
- const API_SERIES = 'api/photo/list.json?title_id=%u&limit=%u';
- const API_TAG = 'api/tag/photo_list.json?id=%u&limit=%u';
+class WorldCosplayBridge extends BridgeAbstract
+{
+ const NAME = 'WorldCosplay Bridge';
+ const URI = 'https://worldcosplay.net/';
+ const DESCRIPTION = 'Returns WorldCosplay photos';
+ const MAINTAINER = 'AxorPL';
- const CONTENT_HTML
- = '<a href="%s" target="_blank"><img src="%s" alt="%s" title="%s"></a>';
+ const API_CHARACTER = 'api/photo/list.json?character_id=%u&limit=%u';
+ const API_COSPLAYER = 'api/member/photos.json?member_id=%u&limit=%u';
+ const API_SERIES = 'api/photo/list.json?title_id=%u&limit=%u';
+ const API_TAG = 'api/tag/photo_list.json?id=%u&limit=%u';
- const ERR_CONTEXT = 'No context provided';
- const ERR_QUERY = 'Unable to query: %s';
+ const CONTENT_HTML
+ = '<a href="%s" target="_blank"><img src="%s" alt="%s" title="%s"></a>';
- const LIMIT_MIN = 1;
- const LIMIT_MAX = 24;
+ const ERR_CONTEXT = 'No context provided';
+ const ERR_QUERY = 'Unable to query: %s';
- const PARAMETERS = array(
- 'Character' => array(
- 'cid' => array(
- 'name' => 'Character ID',
- 'type' => 'number',
- 'required' => true,
- 'title' => 'WorldCosplay character ID',
- 'exampleValue' => 18204
- )
- ),
- 'Cosplayer' => array(
- 'uid' => array(
- 'name' => 'Cosplayer ID',
- 'type' => 'number',
- 'required' => true,
- 'title' => 'Cosplayer\'s WorldCosplay profile ID',
- 'exampleValue' => 406782
- )
- ),
- 'Series' => array(
- 'sid' => array(
- 'name' => 'Series ID',
- 'type' => 'number',
- 'required' => true,
- 'title' => 'WorldCosplay series ID',
- 'exampleValue' => 3139
- )
- ),
- 'Tag' => array(
- 'tid' => array(
- 'name' => 'Tag ID',
- 'type' => 'number',
- 'required' => true,
- 'title' => 'WorldCosplay tag ID',
- 'exampleValue' => 33643
- )
- ),
- 'global' => array(
- 'limit' => array(
- 'name' => 'Limit',
- 'type' => 'number',
- 'required' => false,
- 'title' => 'Maximum number of photos to return',
- 'exampleValue' => 5,
- 'defaultValue' => 5
- )
- )
- );
+ const LIMIT_MIN = 1;
+ const LIMIT_MAX = 24;
- public function collectData() {
- $limit = $this->getInput('limit');
- $limit = min(self::LIMIT_MAX, max(self::LIMIT_MIN, $limit));
- switch($this->queriedContext) {
- case 'Character':
- $id = $this->getInput('cid');
- $url = self::API_CHARACTER;
- break;
- case 'Cosplayer':
- $id = $this->getInput('uid');
- $url = self::API_COSPLAYER;
- break;
- case 'Series':
- $id = $this->getInput('sid');
- $url = self::API_SERIES;
- break;
- case 'Tag':
- $id = $this->getInput('tid');
- $url = self::API_TAG;
- break;
- default:
- returnClientError(self::ERR_CONTEXT);
- }
- $url = self::URI . sprintf($url, $id, $limit);
+ const PARAMETERS = [
+ 'Character' => [
+ 'cid' => [
+ 'name' => 'Character ID',
+ 'type' => 'number',
+ 'required' => true,
+ 'title' => 'WorldCosplay character ID',
+ 'exampleValue' => 18204
+ ]
+ ],
+ 'Cosplayer' => [
+ 'uid' => [
+ 'name' => 'Cosplayer ID',
+ 'type' => 'number',
+ 'required' => true,
+ 'title' => 'Cosplayer\'s WorldCosplay profile ID',
+ 'exampleValue' => 406782
+ ]
+ ],
+ 'Series' => [
+ 'sid' => [
+ 'name' => 'Series ID',
+ 'type' => 'number',
+ 'required' => true,
+ 'title' => 'WorldCosplay series ID',
+ 'exampleValue' => 3139
+ ]
+ ],
+ 'Tag' => [
+ 'tid' => [
+ 'name' => 'Tag ID',
+ 'type' => 'number',
+ 'required' => true,
+ 'title' => 'WorldCosplay tag ID',
+ 'exampleValue' => 33643
+ ]
+ ],
+ 'global' => [
+ 'limit' => [
+ 'name' => 'Limit',
+ 'type' => 'number',
+ 'required' => false,
+ 'title' => 'Maximum number of photos to return',
+ 'exampleValue' => 5,
+ 'defaultValue' => 5
+ ]
+ ]
+ ];
- $json = json_decode(getContents($url));
- if($json->has_error) {
- returnServerError($json->message);
- }
- $list = $json->list;
+ public function collectData()
+ {
+ $limit = $this->getInput('limit');
+ $limit = min(self::LIMIT_MAX, max(self::LIMIT_MIN, $limit));
+ switch ($this->queriedContext) {
+ case 'Character':
+ $id = $this->getInput('cid');
+ $url = self::API_CHARACTER;
+ break;
+ case 'Cosplayer':
+ $id = $this->getInput('uid');
+ $url = self::API_COSPLAYER;
+ break;
+ case 'Series':
+ $id = $this->getInput('sid');
+ $url = self::API_SERIES;
+ break;
+ case 'Tag':
+ $id = $this->getInput('tid');
+ $url = self::API_TAG;
+ break;
+ default:
+ returnClientError(self::ERR_CONTEXT);
+ }
+ $url = self::URI . sprintf($url, $id, $limit);
- foreach($list as $img) {
- $image = isset($img->photo) ? $img->photo : $img;
- $item = array(
- 'uri' => self::URI . substr($image->url, 1),
- 'title' => $image->subject,
- 'timestamp' => $image->created_at,
- 'author' => $img->member->global_name,
- 'enclosures' => array($image->large_url),
- 'uid' => $image->id,
- );
- $item['content'] = sprintf(
- self::CONTENT_HTML,
- $item['uri'],
- $item['enclosures'][0],
- $item['title'],
- $item['title']
- );
- $this->items[] = $item;
- }
- }
+ $json = json_decode(getContents($url));
+ if ($json->has_error) {
+ returnServerError($json->message);
+ }
+ $list = $json->list;
- public function getName() {
- switch($this->queriedContext) {
- case 'Character':
- $id = $this->getInput('cid');
- break;
- case 'Cosplayer':
- $id = $this->getInput('uid');
- break;
- case 'Series':
- $id = $this->getInput('sid');
- break;
- case 'Tag':
- $id = $this->getInput('tid');
- break;
- default:
- return parent::getName();
- }
- return sprintf('%s %u - ', $this->queriedContext, $id) . self::NAME;
- }
+ foreach ($list as $img) {
+ $image = isset($img->photo) ? $img->photo : $img;
+ $item = [
+ 'uri' => self::URI . substr($image->url, 1),
+ 'title' => $image->subject,
+ 'timestamp' => $image->created_at,
+ 'author' => $img->member->global_name,
+ 'enclosures' => [$image->large_url],
+ 'uid' => $image->id,
+ ];
+ $item['content'] = sprintf(
+ self::CONTENT_HTML,
+ $item['uri'],
+ $item['enclosures'][0],
+ $item['title'],
+ $item['title']
+ );
+ $this->items[] = $item;
+ }
+ }
+
+ public function getName()
+ {
+ switch ($this->queriedContext) {
+ case 'Character':
+ $id = $this->getInput('cid');
+ break;
+ case 'Cosplayer':
+ $id = $this->getInput('uid');
+ break;
+ case 'Series':
+ $id = $this->getInput('sid');
+ break;
+ case 'Tag':
+ $id = $this->getInput('tid');
+ break;
+ default:
+ return parent::getName();
+ }
+ return sprintf('%s %u - ', $this->queriedContext, $id) . self::NAME;
+ }
}
'2023-04-06 04:18:17 -0700'>2023-04-06fix(ws): export Server (#2575)Gravatar hiroki osame 1-13/+30 2023-04-06docs(CONTRIBUTING): referece development guide (#2576)Gravatar hiroki osame 1-1/+5 2023-04-05rebase (#1501)Gravatar dave caruso 2-144/+305 2023-04-05Update `typecheck` (#2572)Gravatar Colin McDonnell 3-4/+8 2023-04-05prependGravatar Jarred Sumner 1-7/+3 2023-04-05Add tests for `bun test` with preload scripts (#2566)Gravatar Jake Boone 2-1/+107 2023-04-05Disable buffering when we clear terminalGravatar Jarred Sumner 1-0/+2 2023-04-05PrettierGravatar Jarred Sumner 3-4/+4 2023-04-05fix(fetch.proxy) fix proxy authentication (#2554)Gravatar Ciro Spaciari 3-31/+186 2023-04-05fix: build warnings (#2562)Gravatar hiroki osame 4-4/+1 2023-04-05In Documentation, move --watch before the script name (#2569)Gravatar Lawlzer 1-4/+5 2023-04-05fix `deepEquals` with array holes and accessors (#2557)Gravatar Dylan Conway 2-10/+249 2023-04-05fix: modules to have null prototype (#2561)Gravatar hiroki osame 2-2/+9 2023-04-04:clock1: :clock2: :clock3:Gravatar Jarred Sumner 1-1/+1 2023-04-04Implement `import.meta.main` (#2556)Gravatar Jarred Sumner 10-8/+89 2023-04-04Dylan/fix some failing tests (#2544)Gravatar Jarred Sumner 10-29/+72 2023-04-04Add npm benchmark (#2555)Gravatar Colin McDonnell 13-1/+271 2023-04-03Use absolute paths morebun-v0.5.9Gravatar Jarred Sumner 2-6/+11 2023-04-03Fix test failureGravatar Jarred Sumner 1-15/+18