aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CONTRIBUTORS.md2
-rw-r--r--bridges/Formula1Bridge.php12
-rw-r--r--bridges/WorldCosplayBridge.php149
3 files changed, 9 insertions, 154 deletions
diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md
index 922d9453..ec05a2bd 100644
--- a/CONTRIBUTORS.md
+++ b/CONTRIBUTORS.md
@@ -15,7 +15,7 @@
* [Astalaseven](https://github.com/Astalaseven)
* [Astyan-42](https://github.com/Astyan-42)
* [austinhuang0131](https://github.com/austinhuang0131)
-* [AxorPL](https://github.com/AxorPL)
+* [axor-mst](https://github.com/axor-mst)
* [ayacoo](https://github.com/ayacoo)
* [az5he6ch](https://github.com/az5he6ch)
* [b1nj](https://github.com/b1nj)
diff --git a/bridges/Formula1Bridge.php b/bridges/Formula1Bridge.php
index f84b1ca7..19a84e2e 100644
--- a/bridges/Formula1Bridge.php
+++ b/bridges/Formula1Bridge.php
@@ -5,13 +5,13 @@ class Formula1Bridge extends BridgeAbstract
const NAME = 'Formula1 Bridge';
const URI = 'https://formula1.com/';
const DESCRIPTION = 'Returns latest official Formula 1 news';
- const MAINTAINER = 'AxorPL';
+ const MAINTAINER = 'axor-mst';
- const API_KEY = 'qPgPPRJyGCIPxFT3el4MF7thXHyJCzAP';
+ const API_KEY = 'xZ7AOODSjiQadLsIYWefQrpCSQVDbHGC';
const API_URL = 'https://api.formula1.com/v1/editorial/articles?limit=%u';
const ARTICLE_AUTHOR = 'Formula 1';
- const ARTICLE_URL = 'https://formula1.com/en/latest/article.%s.%s.html';
+ const ARTICLE_URL = 'https://formula1.com/en/latest/article/%s.%s';
const LIMIT_MIN = 1;
const LIMIT_DEFAULT = 10;
@@ -36,7 +36,11 @@ class Formula1Bridge extends BridgeAbstract
$limit = min(self::LIMIT_MAX, max(self::LIMIT_MIN, $limit));
$url = sprintf(self::API_URL, $limit);
- $json = json_decode(getContents($url, ['apikey: ' . self::API_KEY]));
+ $json = json_decode(getContents($url, [
+ 'Accept: application/json',
+ 'apikey: ' . self::API_KEY,
+ 'locale: en'
+ ]));
if (property_exists($json, 'error')) {
returnServerError($json->message);
}
diff --git a/bridges/WorldCosplayBridge.php b/bridges/WorldCosplayBridge.php
deleted file mode 100644
index 721c545f..00000000
--- a/bridges/WorldCosplayBridge.php
+++ /dev/null
@@ -1,149 +0,0 @@
-<?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';
-
- const CONTENT_HTML
- = '<a href="%s" target="_blank"><img src="%s" alt="%s" title="%s"></a>';
-
- const ERR_CONTEXT = 'No context provided';
- const ERR_QUERY = 'Unable to query: %s';
-
- const LIMIT_MIN = 1;
- const LIMIT_MAX = 24;
-
- 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
- ]
- ]
- ];
-
- 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);
-
- $json = json_decode(getContents($url));
- if ($json->has_error) {
- returnServerError($json->message);
- }
- $list = $json->list;
-
- foreach ($list as $img) {
- $image = $img->photo ?? $img;
- $item = [
- 'uri' => self::URI . substr($image->url, 1),
- 'title' => $image->subject,
- 'author' => $img->member->global_name,
- 'enclosures' => [$image->large_url],
- 'uid' => $image->id,
- ];
- // Context cosplayer don't have created_at
- if (isset($image->created_at)) {
- $item['timestamp'] = $image->created_at;
- }
- $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;
- }
-}